Kafka没有外挂宿主机的盘,日志过大问题需要解决
docker run -d --name=zk1_2181 --net=host --restart=always --privileged -e SERVER_ID=1 -e ADDITIONAL_ZOOKEEPER_1=server.1=zookeeper1:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=zookeeper2:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=zookeeper3:2888:3888 registry.aliyuncs.com/acs-sample/zookeeper:3.4.8
docker run -d --name=zk2_2181 --net=host --restart=always --privileged -e SERVER_ID=2 -e ADDITIONAL_ZOOKEEPER_1=server.1=zookeeper1:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=zookeeper2:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=zookeeper3:2888:3888 registry.aliyuncs.com/acs-sample/zookeeper:3.4.8
docker run -d --name=zk3_2181 --net=host --restart=always --privileged -e SERVER_ID=3 -e ADDITIONAL_ZOOKEEPER_1=server.1=zookeeper1:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=zookeeper2:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=zookeeper3:2888:3888 registry.aliyuncs.com/acs-sample/zookeeper:3.4.8
- -e 为设置参数
- SERVER_ID 多台机器不能重复
- zookeeper1、zookeeper2是在本机做的HOST名字映射
docker run -d --name kafka1 --net=host --restart=always --privileged -e KAFKA_HOST_NAME=192.168.31.146 -e KAFKA_ADVERTISED_HOST_NAME=192.168.31.146 -e KAFKA_ADVERTISED_PORT=9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.168.31.146:2181,192.168.31.147:2181,192.168.31.167:2181 wurstmeister/kafka:latest
docker run -d --name kafka2 --net=host --restart=always --privileged -e KAFKA_HOST_NAME=192.168.31.147 -e KAFKA_ADVERTISED_HOST_NAME=192.168.31.147 -e KAFKA_ADVERTISED_PORT=9092 -e KAFKA_BROKER_ID=1 -e KAFKA_ZOOKEEPER_CONNECT=192.168.31.146:2181,192.168.31.147:2181,192.168.31.167:2181 wurstmeister/kafka:latest
docker run -d --name kafka3 --net=host --restart=always --privileged -e KAFKA_HOST_NAME=192.168.31.167 -e KAFKA_ADVERTISED_HOST_NAME=192.168.31.167 -e KAFKA_ADVERTISED_PORT=9092 -e KAFKA_BROKER_ID=2 -e KAFKA_ZOOKEEPER_CONNECT=192.168.31.146:2181,192.168.31.147:2181,192.168.31.167:2181 wurstmeister/kafka:latest
- -e 为设置参数
- KAFKA_HOST_NAME:本机的ip
- KAFKA_ADVERTISED_HOST_NAME: 本机的ip
- KAFKA_ADVERTISED_PORT:端口号
- KAFKA_BROKER_ID: 从0开始,不能重复