单机搭建:
安装完后,默认自动安装对应版本zookeeper
brew install kafka
配置3个Kafka
第一个(使用默认配置)
vi /opt/homebrew/etc/kafka/server.properties
第二个
cp /opt/homebrew/etc/kafka/server.properties /opt/homebrew/etc/kafka/server-1.properties
第三个
cp /opt/homebrew/etc/kafka/server.properties /opt/homebrew/etc/kafka/server-2.properties
第二个和第三个修改配置文件
vi /opt/homebrew/etc/kafka/server-1.properties
broker.id=1
listeners=PLAINTEXT://:9093
log.dir=/tmp/kafka-logs-1
vi /opt/homebrew/etc/kafka/server-1.properties
broker.id=2
listeners=PLAINTEXT://:9094
log.dir=/tmp/kafka-logs-2
brew list kafka
启动kafka之前必须启动zookeeper,上面已查出(步骤3)。
/opt/homebrew/Cellar/kafka/3.3.1_1/bin/zookeeper-server-start /opt/homebrew/etc/kafka/zookeeper.properties &
/opt/homebrew/Cellar/kafka/3.3.1_1/bin/kafka-server-start /opt/homebrew/etc/kafka/server.properties &
/opt/homebrew/Cellar/kafka/3.3.1_1/bin/kafka-server-start /opt/homebrew/etc/kafka/server-1.properties &
/opt/homebrew/Cellar/kafka/3.3.1_1/bin/kafka-server-start /opt/homebrew/etc/kafka/server-2.properties &
/opt/homebrew/Cellar/kafka/3.3.1_1bin/kafka-server-stop
/opt/homebrew/Cellar/kafka/3.3.1_1/bin/zookeeper-server-stop
查看端口命令
lsof -i :9092
根据进程名查看进程信息
ps aux | grep zookeeper
不过有个问题,需要一直挂着终端,不然9093、9094端口自己会断掉。