Famousmai's blog Famousmai's blog
首页
👍 网站介绍
💯 编程分享
✍️ 生活感悟
🎮 游戏人生
📈 网站动态
💌 收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Famous Mai

爱玩辅助的后端小哥
首页
👍 网站介绍
💯 编程分享
✍️ 生活感悟
🎮 游戏人生
📈 网站动态
💌 收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 算法

  • 学习笔记

  • 踩坑记录

    • PHP踩坑记录
    • Node踩坑记录
    • Mac系统踩坑记录
      • 1. 「文件已损坏」解决方法
      • 2. M1 安装Kafka并运行Golang
        • 2.1 用brew安装
        • 2.2 安装后启动服务
        • 2.3 检查是否启动成功
        • 2.4 运行 Golang 程序,报错
        • 2.5 谷歌搜索找解决方案
        • 2.6 加上 -tags dynamic 重新运行Golang程序
      • 3. ControlCe 占用5000端口
        • 3.1 Docker 启动 Logstash
        • 3.2 发现端口5000被占用
        • 3.3 解除端口占用
    • go-vue-admin踩坑记录
  • 面试分享

  • 技术方案文章梳理

  • 设计模式

  • 编程分享
  • 踩坑记录
famousmai
2023-02-17
目录

Mac系统踩坑记录

# Mac常见问题处理

# 1. 「文件已损坏」解决方法

下面以PicGo解决方案为例,文档来自:https://github.com/Molunerfinn/PicGo/blob/dev/FAQ.md (opens new window)

因为 PicGo 没有签名,所以会被 macOS 的安全检查所拦下。

  1. 安装后打开遇到「文件已损坏」的情况,请按如下方式操作:

信任开发者,会要求输入密码:

sudo spctl --master-disable
1

然后放行 PicGo :

xattr -cr /Applications/PicGo.app
1

然后就能正常打开。

如果提示以下内容

option -r not recognized

usage: xattr [-slz] file [file ...]
       xattr -p [-slz] attr_name file [file ...]
       xattr -w [-sz] attr_name attr_value file [file ...]
       xattr -d [-s] attr_name file [file ...]
       xattr -c [-s] file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to attr_value.
The fourth form (-d) deletes the xattr attr_name.
The fifth form (-c) deletes (clears) all xattrs.

options:
  -h: print this help
  -s: act on symbolic links themselves rather than their targets
  -l: print long format (attr_name: attr_value)
  -z: compress or decompress (if compressed) attribute value in zip format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

执行命令

xattr -c /Applications/PicGo.app/*
1
  1. 如果安装打开后没有反应,请按下方顺序排查:
    1. macOS安装好之后,PicGo 是不会弹出主窗口的,因为 PicGo 在 macOS 系统里设计是个顶部栏应用。注意看你顶部栏的图标,如果有 PicGo 的图标,说明安装成功了,点击图标即可打开顶部栏窗口。参考上述第八点 (opens new window)。
    2. 如果你是 M1 的系统,此前装过 PicGo 的 x64 版本,但是后来更新了 arm64 的版本发现打开后没反应,请重启电脑即可。

# 2. M1 安装Kafka并运行Golang (opens new window)

# 2.1 用brew安装

brew install kafka # 时间比较久,要耐心
1

# 2.2 安装后启动服务

  • Kafka依赖 Zookeeper,过程中会顺带安装 Zookeeper

  • 启动 Kafka前,要先启动 Zookeeper

  • 启动 Zookeeper

    brew restart zookeeper
    
    1
  • 启动 Kafka

    brew restart kafka
    
    1

# 2.3 检查是否启动成功

# 创建 Topic
kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic mymtopic

# 查看 Topic
kafka-topics --bootstrap-server localhost:9092 --list
mymtopic

# 监听当前 Topic 消息
kafka-console-consumer --bootstrap-server localhost:9092 --topic mymtopic

# 查看 Topic 配置信息
kafka-topics --bootstrap-server localhost:9092 --describe  --topic mymtopic
Topic: mymtopic TopicId: ouzL8Jf9RuqcYMkYnRqENQ PartitionCount: 1 ReplicationFactor: 1  Configs: segment.bytes=1073741824
  Topic: mymtopic Partition: 0  Leader: 0 Replicas: 0 Isr: 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 2.4 运行 Golang 程序,报错

git:(master) ✗ go run main.go
# command-line-arguments
/opt/homebrew/Cellar/go/1.19.1/libexec/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
ld: warning: ignoring file /Users/mym/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.6.1/kafka/librdkafka_vendor/librdkafka_darwin.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
1
2
3
4

# 2.5 谷歌搜索找解决方案

发现这个issues:https://github.com/confluentinc/confluent-kafka-go/issues/591 (opens new window)(虽然这个issues没有关闭,但里面有解决方法,总结如下)

  • 安装 librdkafka

    brew install librdkafka
    
    1
  • 配置环境变量

    export PKG_CONFIG_PATH="/opt/homebrew/Cellar/openssl@1.1/1.1.1q/lib/pkgconfig"
    
    1

# 2.6 加上 -tags dynamic 重新运行Golang程序

git:(master) ✗ go run -tags dynamic main.go
1

正常了!亲测有效,不过原理不是完全清楚,有兄弟明白的话,评论让我学习一下吧

# 3. ControlCe 占用5000端口

系统版本 : macOS Monterey 版本12.5.1

# 3.1 Docker 启动 Logstash

  logstash:
    image: logstash:8.6.0
    ports:
      - "5044:5004"
      - "5000:5000"
      - "9600:9600"
    volumes:
      - ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml
      - ./logstash/pipeline/logstash.config:/usr/share/logstash/pipeline/logstash.config
    environment:
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
1
2
3
4
5
6
7
8
9
10
11

# 3.2 发现端口5000被占用

可是我并没有其他服务占用此端口

Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:5000 -> 0.0.0.0:0: listen tcp 0.0.0.0:5000: bind: address already in use
1

执行以下命令,发现 ControlCe 占用了5000端口

$ lsof -i tcp:5000
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ControlCe 548  mym   21u  IPv4 0x8b34fc14db78307f      0t0  TCP *:commplex-main (LISTEN)
ControlCe 548  mym   22u  IPv6 0x8b34fc19a841efcf      0t0  TCP *:commplex-main (LISTEN)
1
2
3
4

搜索查到:https://discussionschinese.apple.com/thread/253342604

# 3.3 解除端口占用

  1. 服务换个端口监听
  2. 系统偏好设置/共享/隔空播放接收器 关闭即可解除占用
编辑 (opens new window)
上次更新: 2023/02/19, 00:03:59
Node踩坑记录
go-vue-admin踩坑记录

← Node踩坑记录 go-vue-admin踩坑记录→

最近更新
01
策略模式
03-13
02
单例模式
03-05
03
设计模式介绍
03-05
更多文章>
Theme by Vdoing | Copyright © 2022-2023 Evan Xu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式