#Docker 部署kafka集群
基于 zookeeper 集群,需要先部署zookeeper
https://yhyr.github.io/2018/12/15/Kafka%E7%90%86%E8%AE%BA%E4%B9%8BPartition-Replication/
server.properties 配置文件
# broker.id=1 #broker的全局唯一编号,不能重复. 给集群中的每个broker配置一个不同的id
# delete.topic.enable=true # 允许删除topic
# num.network.threads=3 #处理网络请求的线程数量
# num.io.threads=8 #用来处理磁盘IO的现成数量
# socket.send.buffer.bytes=102400 #发送套接字的缓冲区大小
# socket.receive.buffer.bytes=102400 #接收套接字的缓冲区大小
# socket.request.max.bytes=104857600 #请求套接字的缓冲区大小
# log.dirs=/opt/module/kafka/logs #kafka运行日志存放的路径
# num.partitions=1 #topic在当前broker上的分区个数
# num.recovery.threads.per.data.dir=1 #用来恢复和清理data下数据的线程数量
# log.retention.hours=168 #segment文件保留的最长时间,超时将被删除
# zookeeper.connect=hadoop201:2181,hadoop202:2181,hadoop203:2181 #配置连接Zookeeper集群地址
节点1:
docker run -d --net host --restart unless-stopped -p 9092:9092 \
-e CLUSTER_NAME=KAFKA \
-e KAFKA_ADVERTISED_HOST_NAME=10.180.50.4 \
-e KAFKA_ADVERTISED_PORT=9092 \
-e KAFKA_ZOOKEEPER_CONNECT=10.180.50.4:2181,10.180.50.220:2181,10.180.50.171:2181 \
-e KAFKA_HOST_NAME=10.180.50.4 \
-e KAFKA_BROKER_ID=1 \
-e KAFKA_LISTENERS=PLAINTEXT://10.180.50.4:9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://10.180.50.4:9092 \
-e KAFKA_DELETE_TOPIC_ENABLE=true \
-v /docker/kafka/logs:/kafka \
--name kafka1 wurstmeister/kafka
节点2:
docker run -d --net host --restart unless-stopped -p 9092:9092 \
-e CLUSTER_NAME=KAFKA \
-e KAFKA_ADVERTISED_HOST_NAME=10.180.50.220 \
-e KAFKA_ADVERTISED_PORT=9092 \
-e KAFKA_ZOOKEEPER_CONNECT=10.180.50.4:2181,10.180.50.220:2181,10.180.50.171:2181 \
-e KAFKA_HOST_NAME=10.180.50.220 \
-e KAFKA_BROKER_ID=2 \
-e KAFKA_LISTENERS=PLAINTEXT://10.180.50.220:9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://10.180.50.220:9092 \
-e KAFKA_DELETE_TOPIC_ENABLE=true \
-v /docker/kafka/l