1. 第一步:单机搭建
单机搭建:
安装完后,默认自动安装对应版本zookeeper
brew install kafka
2.第二步:修改配置文件:
配置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
3.第三步:查看启动服务位置
brew list kafka
4.第四步:服务启动/关闭
启动kafka之前必须启动zookeeper,上面已查出👆(步骤3)。
先启动zookeeper
/opt/homebrew/Cellar/kafka/3.3.1_1/bin/zookeeper-server-start /opt/homebrew/etc/kafka/zookeeper.properties &
再启动kafka
/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 &
关闭kafka
/opt/homebrew/Cellar/kafka/3.3.1_1bin/kafka-server-stop
关闭zookeeper
/opt/homebrew/Cellar/kafka/3.3.1_1/bin/zookeeper-server-stop
5.最后:查看启动
查看端口命令
lsof -i :9092
根据进程名查看进程信息
ps aux | grep zookeeper