安装 、启动zk
brew install zookeeper
brew services start zookeeper
安装 kafka
brew install kafka
配置 kafka server.properties
vi /data/conf/kafka/server.properties
# server basics
broker.id=0
delete.topic.enable=true
# socket server settings
listeners=PLAINTEXT://0.0.0.0:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
# log basics
log.dirs=/usr/local/var/lib/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
# log flush policy
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
# zk
zookeeper.connect=localhost:2181
zookeeper.connection.timeout.ms=6000
使用 kafka
1.查看 kafka 进程号
ps -def | grep kafka | awk '{print $2}'
2.常用命令
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test1
kafka-console-producer --broker-list localhost:9092 --topic test1
kafka-console-consumer --bootstrap-server localhost:9092 --topic test1
kafka-consumer-offset-checker --zookeeper localhost:2181 --topic test1 --group console-consumer-94508
3.查看kafka在zk中相关节点
get /brokers/topics/aso_logout_act/partitions/0
get /brokers/ids/0
# get consumer groups
ls /consumers