docker-compose.yml 有 3 个 zookeeper 和 1 个代理设置 public IP - 代理启动失败,没有有意义的日志(但与 1 个 zookeeper 一起工作)
docker-compose.yml with 3 zookepers and 1 broker set up with public IP - broker failed to start with no meaningful logs (but works with 1 zookeeper)
我有以下 docker-compose.yml 文件:
version: '3.7'
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-1
container_name: zookeeper-1
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "localhost:2888:3888;192.168.100.14:12888:13888;192.168.100.14:22888:23888"
volumes:
- ./kafka-data/zookeeper-1:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-1:/var/lib/zookeeper/log
networks:
- mynet
zookeeper-2:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-2
container_name: zookeeper-2
ports:
- "12181:12181"
- "12888:12888"
- "13888:13888"
environment:
ZOOKEEPER_SERVER_ID: 2
ZOOKEEPER_CLIENT_PORT: 12181
ZOOKEEPER_PEER_PORT: 12888
ZOOKEEPER_LEADER_PORT: 13888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;localhost:12888:13888;192.168.100.14:22888:23888"
volumes:
- ./kafka-data/zookeeper-2:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-2:/var/lib/zookeeper/log
networks:
- mynet
zookeeper-3:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-3
container_name: zookeeper-3
ports:
- "22181:22181"
- "22888:22888"
- "23888:23888"
environment:
ZOOKEEPER_SERVER_ID: 3
ZOOKEEPER_CLIENT_PORT: 22181
ZOOKEEPER_PEER_PORT: 22888
ZOOKEEPER_LEADER_PORT: 23888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;192.168.100.14:12888:13888;localhost:22888:23888"
volumes:
- ./kafka-data/zookeeper-3:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-3:/var/lib/zookeeper/log
networks:
- mynet
broker-1:
image: confluentinc/cp-kafka:6.2.1
hostname: broker-1
container_name: broker-1
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: OUTSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: OUTSIDE://192.168.100.14:9092
KAFKA_INTER_BROKER_LISTENER_NAME: OUTSIDE
KAFKA_ZOOKEEPER_CONNECT: "192.168.100.14:2181,192.168.100.14:12181,192.168.100.14:22181"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LOG_MESSAGE_TIMESTAMP_TYPE: 'LogAppendTime'
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONNECTIONS_MAX_IDLE_MS: 31536000000 # 1 year
volumes:
- ./kafka-data/kafka-1:/var/lib/kafka/data
networks:
- mynet
# PORT 8081 reserved for Schema Registry
kafka-rest-1:
image: confluentinc/cp-kafka-rest:6.2.1
hostname: kafka-rest-1
container_name: kafka-rest-1
depends_on:
- broker-1
ports:
- "8082:8082"
environment:
KAFKA_REST_HOST_NAME: 192.168.100.14
KAFKA_REST_LISTENERS: http://0.0.0.0:8082
KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092
networks:
- mynet
# PORT 8083 reserved for Kafka-Connect REST API
kafka-ui-1:
image: provectuslabs/kafka-ui:0.2.1
hostname: kafka-ui-1
container_name: kafka-ui-1
depends_on:
- broker-1
ports:
- "8084:8080"
environment:
KAFKA_CLUSTERS_0_NAME: lab
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 192.168.100.14:9092
KAFKA_CLUSTERS_0_ZOOKEEPER: "192.168.100.14:2181;192.168.100.14:12181;192.168.100.14:22181"
networks:
- mynet
kafdrop-1:
image: obsidiandynamics/kafdrop:3.27.0
hostname: kafrop-1
container_name: kafdrop-1
depends_on:
- broker-1
ports:
- "8085:9000"
environment:
KAFKA_BROKERCONNECT: 192.168.100.14:9092
JVM_OPTS: "-Xms32M -Xmx64M"
SERVER_SERVLET_CONTEXTPATH: "/"
networks:
- mynet
networks:
mynet:
driver: bridge
还在 Whosebug 上发现 zookeeper ZOOKEEPER_SERVERS 本身不应该有外部 IP(那里应该是 'localhost'),所以我的 3 个 zookeeper 开始一起工作。
但我的 broker-1 无法启动并退出,代码为 'Exit 1',日志始终为:
# docker-compose up broker-1
zookeeper-1 is up-to-date
Starting broker-1 ... done
Attaching to broker-1
broker-1 | ===> User
broker-1 | uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
broker-1 | ===> Configuring ...
broker-1 | ===> Running preflight checks ...
broker-1 | ===> Check if /var/lib/kafka/data is writable ...
broker-1 | ===> Check if Zookeeper is healthy ...
broker-1 | SLF4J: Class path contains multiple SLF4J bindings.
broker-1 | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
broker-1 | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
broker-1 | SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
broker-1 | SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
broker-1 | log4j:WARN No appenders could be found for logger (io.confluent.admin.utils.cli.ZookeeperReadyCommand).
broker-1 | log4j:WARN Please initialize the log4j system properly.
broker-1 | log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
broker-1 exited with code 1
但是如果我注释掉额外的动物园管理员,那么 broker-1 启动良好,这是有效的配置:
version: '3.7'
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-1
container_name: zookeeper-1
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "localhost:2888:3888" #;192.168.100.14:12888:13888;192.168.100.14:22888:23888"
volumes:
- ./kafka-data/zookeeper-1:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-1:/var/lib/zookeeper/log
networks:
- mynet
# zookeeper-2:
# image: confluentinc/cp-zookeeper:6.2.1
# hostname: zookeeper-2
# container_name: zookeeper-2
# ports:
# - "12181:12181"
# - "12888:12888"
# - "13888:13888"
# environment:
# ZOOKEEPER_SERVER_ID: 2
# ZOOKEEPER_CLIENT_PORT: 12181
# ZOOKEEPER_PEER_PORT: 12888
# ZOOKEEPER_LEADER_PORT: 13888
# ZOOKEEPER_TICK_TIME: 2000
# ZOOKEEPER_INIT_LIMIT: 5
# ZOOKEEPER_SYNC_LIMIT: 2
# ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;localhost:12888:13888;192.168.100.14:22888:23888"
# volumes:
# - ./kafka-data/zookeeper-2:/var/lib/zookeeper/data
# - ./kafka-data/zookeeper-logs-2:/var/lib/zookeeper/log
# networks:
# - mynet
#
# zookeeper-3:
# image: confluentinc/cp-zookeeper:6.2.1
# hostname: zookeeper-3
# container_name: zookeeper-3
# ports:
# - "22181:22181"
# - "22888:22888"
# - "23888:23888"
# environment:
# ZOOKEEPER_SERVER_ID: 3
# ZOOKEEPER_CLIENT_PORT: 22181
# ZOOKEEPER_PEER_PORT: 22888
# ZOOKEEPER_LEADER_PORT: 23888
# ZOOKEEPER_TICK_TIME: 2000
# ZOOKEEPER_INIT_LIMIT: 5
# ZOOKEEPER_SYNC_LIMIT: 2
# ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;192.168.100.14:12888:13888;localhost:22888:23888"
# volumes:
# - ./kafka-data/zookeeper-3:/var/lib/zookeeper/data
# - ./kafka-data/zookeeper-logs-3:/var/lib/zookeeper/log
# networks:
# - mynet
broker-1:
image: confluentinc/cp-kafka:6.2.1
hostname: broker-1
container_name: broker-1
depends_on:
- zookeeper-1
# - zookeeper-2
# - zookeeper-3
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: OUTSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: OUTSIDE://192.168.100.14:9092
KAFKA_INTER_BROKER_LISTENER_NAME: OUTSIDE
KAFKA_ZOOKEEPER_CONNECT: "192.168.100.14:2181" #,192.168.100.14:12181,192.168.100.14:22181"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LOG_MESSAGE_TIMESTAMP_TYPE: 'LogAppendTime'
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONNECTIONS_MAX_IDLE_MS: 31536000000 # 1 year
volumes:
- ./kafka-data/kafka-1:/var/lib/kafka/data
networks:
- mynet
# PORT 8081 reserved for Schema Registry
kafka-rest-1:
image: confluentinc/cp-kafka-rest:6.2.1
hostname: kafka-rest-1
container_name: kafka-rest-1
depends_on:
- broker-1
ports:
- "8082:8082"
environment:
KAFKA_REST_HOST_NAME: 192.168.100.14
KAFKA_REST_LISTENERS: http://0.0.0.0:8082
KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092
networks:
- mynet
# PORT 8083 reserved for Kafka-Connect REST API
kafka-ui-1:
image: provectuslabs/kafka-ui:0.2.1
hostname: kafka-ui-1
container_name: kafka-ui-1
depends_on:
- broker-1
ports:
- "8084:8080"
environment:
KAFKA_CLUSTERS_0_NAME: lab
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 192.168.100.14:9092
KAFKA_CLUSTERS_0_ZOOKEEPER: "192.168.100.14:2181" #;192.168.100.14:12181;192.168.100.14:22181"
networks:
- mynet
kafdrop-1:
image: obsidiandynamics/kafdrop:3.27.0
hostname: kafrop-1
container_name: kafdrop-1
depends_on:
- broker-1
ports:
- "8085:9000"
environment:
KAFKA_BROKERCONNECT: 192.168.100.14:9092
JVM_OPTS: "-Xms32M -Xmx64M"
SERVER_SERVLET_CONTEXTPATH: "/"
networks:
- mynet
networks:
mynet:
driver: bridge
3-zookeepers 配置有什么问题,为什么 1-zookeeperper 配置对单个 kafka broker 没问题?
更新: 当然,我知道 3 个动物园管理员和 3 个经纪人(现在一个)在同一台主机上没有任何意义:-)
我需要通过使用 docker 容器在我拥有的单个主机上模拟多个主机环境。
计划是关闭一些 docker 容器,然后模拟不同的“主机”(zookeper、代理)故障。
这就是为什么我在这种模拟的配置中使用“public”IP 地址 192.168.100.14(“public”从容器的角度来看)和不同的端口。
Docker bridged 使用的网络,即从容器内部通过 IP 访问网络主机甚至互联网主机是 np - 我测试过。
您似乎误解了Docker Compose 网络。您应该始终使用服务名称,而不是 IP 地址
如果您使用一台 Zookeeper 服务器,ZOOKEEPER_SERVERS
不会执行任何操作。这用于加入集群
那么,您正在寻找这个
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-1
container_name: zookeeper-1
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
...
ZOOKEEPER_SERVERS: "localhost:2888:3888;zookeeper-1:12888:13888;zookeeper-2:22888:23888"
...
zookeeper-2:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-2
container_name: zookeeper-2
ports:
- "12181:12181"
- "12888:12888"
- "13888:13888"
environment:
ZOOKEEPER_SERVER_ID: 2
ZOOKEEPER_CLIENT_PORT: 12181
ZOOKEEPER_PEER_PORT: 12888
ZOOKEEPER_LEADER_PORT: 13888
...
ZOOKEEPER_SERVERS: "zookeeper-1:2888:3888;localhost:12888:13888;zookeeper-2:22888:23888"
...
zookeeper-3:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-3
container_name: zookeeper-3
ports:
- "22181:22181"
- "22888:22888"
- "23888:23888"
environment:
ZOOKEEPER_SERVER_ID: 3
ZOOKEEPER_CLIENT_PORT: 22181
ZOOKEEPER_PEER_PORT: 22888
ZOOKEEPER_LEADER_PORT: 23888
...
ZOOKEEPER_SERVERS: "zookeeper-1:2888:3888;zookeeper-2:12888:13888;localhost:22888:23888"
...
broker-1:
image: confluentinc/cp-kafka:6.2.1
hostname: broker-1
container_name: broker-1
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
# ports removed because the listener is internal to the docker network only
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: INSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: INSIDE://broker-1:9092
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_ZOOKEEPER_CONNECT: "zookeeper-1:zookeeper-2:12181,zookeeper-3:22181"
...
...等等...
其他容器的 bootstrap 服务器也使用 broker-1:9092
请记住,您使用的是单个主机,这是单点故障,因此多个 ZK 服务器毫无意义
我的问题完全解决了! :-)
似乎Docker 容器桥接网络增加了互连集群中所有东西的问题。
添加 ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true' 到 zookeper env 和 extra_hosts: 到所有容器解决了我所有的问题! :-)
所以我在每个服务的每个配置中添加了以下行 extra_hosts :
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
添加 ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true' 到 zookeper 环境也很重要。
完整示例:
version: '3.7'
x-zoo: &zoo "kafka-1:2888:3888;kafka-2:2888:3888;kafka-3:2888:3888"
x-kafkaZookeepers: &kafkaZookeepers "kafka-1:2181,kafka-2:2181,kafka-3:2181"
x-kafkaBrokers: &kafkaBrokers "kafka-1:9092"
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: *zoo
volumes:
- ./kafka-data/zookeeper:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs:/var/lib/zookeeper/log
networks:
- mynet
broker:
image: confluentinc/cp-kafka:6.2.1
hostname: broker
container_name: broker
depends_on:
- zookeeper
ports:
- "9092:9092"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: OUTSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: OUTSIDE://192.168.1.11:9092
KAFKA_INTER_BROKER_LISTENER_NAME: OUTSIDE
KAFKA_ZOOKEEPER_CONNECT: *kafkaZookeepers
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LOG_MESSAGE_TIMESTAMP_TYPE: 'LogAppendTime'
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONNECTIONS_MAX_IDLE_MS: 31536000000 # 1 year
volumes:
- ./kafka-data/kafka:/var/lib/kafka/data
networks:
- mynet
kafka-ui:
image: provectuslabs/kafka-ui:0.2.1
hostname: kafka-ui
container_name: kafka-ui
depends_on:
- broker
ports:
- "8084:8080"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
KAFKA_CLUSTERS_0_NAME: local_kafka
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: *kafkaBrokers
KAFKA_CLUSTERS_0_ZOOKEEPER: *kafkaZookeepers
networks:
- mynet
networks:
mynet:
driver: bridge
docker-compose.yml 其他虚拟机上的文件看起来相似(我现在只设置了 3 个动物园管理员),在第二个虚拟机上:
version: '3.7'
x-zoo: &zoo "kafka-1:2888:3888;kafka-2:2888:3888;kafka-3:2888:3888"
x-kafkaZookeepers: &kafkaZookeepers "kafka-1:2181,kafka-2:2181,kafka-3:2181"
x-kafkaBrokers: &kafkaBrokers "kafka-1:9092"
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
ZOOKEEPER_SERVER_ID: 2
ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: *zoo
volumes:
- ./kafka-data/zookeeper:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs:/var/lib/zookeeper/log
networks:
- mynet
networks:
mynet:
driver: bridge
在第 3 个虚拟机上:
version: '3.7'
x-zoo: &zoo "kafka-1:2888:3888;kafka-2:2888:3888;kafka-3:2888:3888"
x-kafkaZookeepers: &kafkaZookeepers "kafka-1:2181,kafka-2:2181,kafka-3:2181"
x-kafkaBrokers: &kafkaBrokers "kafka-1:9092"
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
ZOOKEEPER_SERVER_ID: 3
ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: *zoo
volumes:
- ./kafka-data/zookeeper:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs:/var/lib/zookeeper/log
networks:
- mynet
networks:
mynet:
driver: bridge
根据日志,所有 Docker 个容器现在可以相互连接。
我还将主机 kafka-1、kafka-2、kafka-3 添加到虚拟机上的 /etc/hosts 文件中:
test@kafka-1:~/Kafka-Docker$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 kafka-1
192.168.1.11 kafka-1
192.168.1.12 kafka-2
192.168.1.13 kafka-3
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
希望它能节省一些人的时间和精力,也许这就是我一直在等待的答案! :-)
另请注意,我使用的是最新的 atm(查看日期)docker 图片(cp-zookeper、cp-kafka 等)6.2.1 来自docker来自官方合流发布者的集线器。
更新: 我在每个动物园管理员上转发端口 4888->8080 并获得 简单的 REST 管理页面 ( https://zookeeper.apache.org/doc/r3.5.9/zookeeperAdmin.html#sc_zkCommands )我可以在哪里看到谁是“领导者”,谁是“追随者”,例如:
enter image description here
enter image description here
我有以下 docker-compose.yml 文件:
version: '3.7'
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-1
container_name: zookeeper-1
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "localhost:2888:3888;192.168.100.14:12888:13888;192.168.100.14:22888:23888"
volumes:
- ./kafka-data/zookeeper-1:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-1:/var/lib/zookeeper/log
networks:
- mynet
zookeeper-2:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-2
container_name: zookeeper-2
ports:
- "12181:12181"
- "12888:12888"
- "13888:13888"
environment:
ZOOKEEPER_SERVER_ID: 2
ZOOKEEPER_CLIENT_PORT: 12181
ZOOKEEPER_PEER_PORT: 12888
ZOOKEEPER_LEADER_PORT: 13888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;localhost:12888:13888;192.168.100.14:22888:23888"
volumes:
- ./kafka-data/zookeeper-2:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-2:/var/lib/zookeeper/log
networks:
- mynet
zookeeper-3:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-3
container_name: zookeeper-3
ports:
- "22181:22181"
- "22888:22888"
- "23888:23888"
environment:
ZOOKEEPER_SERVER_ID: 3
ZOOKEEPER_CLIENT_PORT: 22181
ZOOKEEPER_PEER_PORT: 22888
ZOOKEEPER_LEADER_PORT: 23888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;192.168.100.14:12888:13888;localhost:22888:23888"
volumes:
- ./kafka-data/zookeeper-3:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-3:/var/lib/zookeeper/log
networks:
- mynet
broker-1:
image: confluentinc/cp-kafka:6.2.1
hostname: broker-1
container_name: broker-1
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: OUTSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: OUTSIDE://192.168.100.14:9092
KAFKA_INTER_BROKER_LISTENER_NAME: OUTSIDE
KAFKA_ZOOKEEPER_CONNECT: "192.168.100.14:2181,192.168.100.14:12181,192.168.100.14:22181"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LOG_MESSAGE_TIMESTAMP_TYPE: 'LogAppendTime'
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONNECTIONS_MAX_IDLE_MS: 31536000000 # 1 year
volumes:
- ./kafka-data/kafka-1:/var/lib/kafka/data
networks:
- mynet
# PORT 8081 reserved for Schema Registry
kafka-rest-1:
image: confluentinc/cp-kafka-rest:6.2.1
hostname: kafka-rest-1
container_name: kafka-rest-1
depends_on:
- broker-1
ports:
- "8082:8082"
environment:
KAFKA_REST_HOST_NAME: 192.168.100.14
KAFKA_REST_LISTENERS: http://0.0.0.0:8082
KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092
networks:
- mynet
# PORT 8083 reserved for Kafka-Connect REST API
kafka-ui-1:
image: provectuslabs/kafka-ui:0.2.1
hostname: kafka-ui-1
container_name: kafka-ui-1
depends_on:
- broker-1
ports:
- "8084:8080"
environment:
KAFKA_CLUSTERS_0_NAME: lab
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 192.168.100.14:9092
KAFKA_CLUSTERS_0_ZOOKEEPER: "192.168.100.14:2181;192.168.100.14:12181;192.168.100.14:22181"
networks:
- mynet
kafdrop-1:
image: obsidiandynamics/kafdrop:3.27.0
hostname: kafrop-1
container_name: kafdrop-1
depends_on:
- broker-1
ports:
- "8085:9000"
environment:
KAFKA_BROKERCONNECT: 192.168.100.14:9092
JVM_OPTS: "-Xms32M -Xmx64M"
SERVER_SERVLET_CONTEXTPATH: "/"
networks:
- mynet
networks:
mynet:
driver: bridge
还在 Whosebug 上发现 zookeeper ZOOKEEPER_SERVERS 本身不应该有外部 IP(那里应该是 'localhost'),所以我的 3 个 zookeeper 开始一起工作。
但我的 broker-1 无法启动并退出,代码为 'Exit 1',日志始终为:
# docker-compose up broker-1
zookeeper-1 is up-to-date
Starting broker-1 ... done
Attaching to broker-1
broker-1 | ===> User
broker-1 | uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
broker-1 | ===> Configuring ...
broker-1 | ===> Running preflight checks ...
broker-1 | ===> Check if /var/lib/kafka/data is writable ...
broker-1 | ===> Check if Zookeeper is healthy ...
broker-1 | SLF4J: Class path contains multiple SLF4J bindings.
broker-1 | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
broker-1 | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
broker-1 | SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
broker-1 | SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
broker-1 | log4j:WARN No appenders could be found for logger (io.confluent.admin.utils.cli.ZookeeperReadyCommand).
broker-1 | log4j:WARN Please initialize the log4j system properly.
broker-1 | log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
broker-1 exited with code 1
但是如果我注释掉额外的动物园管理员,那么 broker-1 启动良好,这是有效的配置:
version: '3.7'
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-1
container_name: zookeeper-1
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: "localhost:2888:3888" #;192.168.100.14:12888:13888;192.168.100.14:22888:23888"
volumes:
- ./kafka-data/zookeeper-1:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs-1:/var/lib/zookeeper/log
networks:
- mynet
# zookeeper-2:
# image: confluentinc/cp-zookeeper:6.2.1
# hostname: zookeeper-2
# container_name: zookeeper-2
# ports:
# - "12181:12181"
# - "12888:12888"
# - "13888:13888"
# environment:
# ZOOKEEPER_SERVER_ID: 2
# ZOOKEEPER_CLIENT_PORT: 12181
# ZOOKEEPER_PEER_PORT: 12888
# ZOOKEEPER_LEADER_PORT: 13888
# ZOOKEEPER_TICK_TIME: 2000
# ZOOKEEPER_INIT_LIMIT: 5
# ZOOKEEPER_SYNC_LIMIT: 2
# ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;localhost:12888:13888;192.168.100.14:22888:23888"
# volumes:
# - ./kafka-data/zookeeper-2:/var/lib/zookeeper/data
# - ./kafka-data/zookeeper-logs-2:/var/lib/zookeeper/log
# networks:
# - mynet
#
# zookeeper-3:
# image: confluentinc/cp-zookeeper:6.2.1
# hostname: zookeeper-3
# container_name: zookeeper-3
# ports:
# - "22181:22181"
# - "22888:22888"
# - "23888:23888"
# environment:
# ZOOKEEPER_SERVER_ID: 3
# ZOOKEEPER_CLIENT_PORT: 22181
# ZOOKEEPER_PEER_PORT: 22888
# ZOOKEEPER_LEADER_PORT: 23888
# ZOOKEEPER_TICK_TIME: 2000
# ZOOKEEPER_INIT_LIMIT: 5
# ZOOKEEPER_SYNC_LIMIT: 2
# ZOOKEEPER_SERVERS: "192.168.100.14:2888:3888;192.168.100.14:12888:13888;localhost:22888:23888"
# volumes:
# - ./kafka-data/zookeeper-3:/var/lib/zookeeper/data
# - ./kafka-data/zookeeper-logs-3:/var/lib/zookeeper/log
# networks:
# - mynet
broker-1:
image: confluentinc/cp-kafka:6.2.1
hostname: broker-1
container_name: broker-1
depends_on:
- zookeeper-1
# - zookeeper-2
# - zookeeper-3
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: OUTSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: OUTSIDE://192.168.100.14:9092
KAFKA_INTER_BROKER_LISTENER_NAME: OUTSIDE
KAFKA_ZOOKEEPER_CONNECT: "192.168.100.14:2181" #,192.168.100.14:12181,192.168.100.14:22181"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LOG_MESSAGE_TIMESTAMP_TYPE: 'LogAppendTime'
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONNECTIONS_MAX_IDLE_MS: 31536000000 # 1 year
volumes:
- ./kafka-data/kafka-1:/var/lib/kafka/data
networks:
- mynet
# PORT 8081 reserved for Schema Registry
kafka-rest-1:
image: confluentinc/cp-kafka-rest:6.2.1
hostname: kafka-rest-1
container_name: kafka-rest-1
depends_on:
- broker-1
ports:
- "8082:8082"
environment:
KAFKA_REST_HOST_NAME: 192.168.100.14
KAFKA_REST_LISTENERS: http://0.0.0.0:8082
KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092
networks:
- mynet
# PORT 8083 reserved for Kafka-Connect REST API
kafka-ui-1:
image: provectuslabs/kafka-ui:0.2.1
hostname: kafka-ui-1
container_name: kafka-ui-1
depends_on:
- broker-1
ports:
- "8084:8080"
environment:
KAFKA_CLUSTERS_0_NAME: lab
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 192.168.100.14:9092
KAFKA_CLUSTERS_0_ZOOKEEPER: "192.168.100.14:2181" #;192.168.100.14:12181;192.168.100.14:22181"
networks:
- mynet
kafdrop-1:
image: obsidiandynamics/kafdrop:3.27.0
hostname: kafrop-1
container_name: kafdrop-1
depends_on:
- broker-1
ports:
- "8085:9000"
environment:
KAFKA_BROKERCONNECT: 192.168.100.14:9092
JVM_OPTS: "-Xms32M -Xmx64M"
SERVER_SERVLET_CONTEXTPATH: "/"
networks:
- mynet
networks:
mynet:
driver: bridge
3-zookeepers 配置有什么问题,为什么 1-zookeeperper 配置对单个 kafka broker 没问题?
更新: 当然,我知道 3 个动物园管理员和 3 个经纪人(现在一个)在同一台主机上没有任何意义:-) 我需要通过使用 docker 容器在我拥有的单个主机上模拟多个主机环境。 计划是关闭一些 docker 容器,然后模拟不同的“主机”(zookeper、代理)故障。 这就是为什么我在这种模拟的配置中使用“public”IP 地址 192.168.100.14(“public”从容器的角度来看)和不同的端口。 Docker bridged 使用的网络,即从容器内部通过 IP 访问网络主机甚至互联网主机是 np - 我测试过。
您似乎误解了Docker Compose 网络。您应该始终使用服务名称,而不是 IP 地址
如果您使用一台 Zookeeper 服务器,ZOOKEEPER_SERVERS
不会执行任何操作。这用于加入集群
那么,您正在寻找这个
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-1
container_name: zookeeper-1
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
...
ZOOKEEPER_SERVERS: "localhost:2888:3888;zookeeper-1:12888:13888;zookeeper-2:22888:23888"
...
zookeeper-2:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-2
container_name: zookeeper-2
ports:
- "12181:12181"
- "12888:12888"
- "13888:13888"
environment:
ZOOKEEPER_SERVER_ID: 2
ZOOKEEPER_CLIENT_PORT: 12181
ZOOKEEPER_PEER_PORT: 12888
ZOOKEEPER_LEADER_PORT: 13888
...
ZOOKEEPER_SERVERS: "zookeeper-1:2888:3888;localhost:12888:13888;zookeeper-2:22888:23888"
...
zookeeper-3:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper-3
container_name: zookeeper-3
ports:
- "22181:22181"
- "22888:22888"
- "23888:23888"
environment:
ZOOKEEPER_SERVER_ID: 3
ZOOKEEPER_CLIENT_PORT: 22181
ZOOKEEPER_PEER_PORT: 22888
ZOOKEEPER_LEADER_PORT: 23888
...
ZOOKEEPER_SERVERS: "zookeeper-1:2888:3888;zookeeper-2:12888:13888;localhost:22888:23888"
...
broker-1:
image: confluentinc/cp-kafka:6.2.1
hostname: broker-1
container_name: broker-1
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
# ports removed because the listener is internal to the docker network only
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: INSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: INSIDE://broker-1:9092
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_ZOOKEEPER_CONNECT: "zookeeper-1:zookeeper-2:12181,zookeeper-3:22181"
...
...等等...
其他容器的 bootstrap 服务器也使用 broker-1:9092
请记住,您使用的是单个主机,这是单点故障,因此多个 ZK 服务器毫无意义
我的问题完全解决了! :-)
似乎Docker 容器桥接网络增加了互连集群中所有东西的问题。
添加 ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true' 到 zookeper env 和 extra_hosts: 到所有容器解决了我所有的问题! :-)
所以我在每个服务的每个配置中添加了以下行 extra_hosts :
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
添加 ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true' 到 zookeper 环境也很重要。
完整示例:
version: '3.7'
x-zoo: &zoo "kafka-1:2888:3888;kafka-2:2888:3888;kafka-3:2888:3888"
x-kafkaZookeepers: &kafkaZookeepers "kafka-1:2181,kafka-2:2181,kafka-3:2181"
x-kafkaBrokers: &kafkaBrokers "kafka-1:9092"
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: *zoo
volumes:
- ./kafka-data/zookeeper:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs:/var/lib/zookeeper/log
networks:
- mynet
broker:
image: confluentinc/cp-kafka:6.2.1
hostname: broker
container_name: broker
depends_on:
- zookeeper
ports:
- "9092:9092"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: OUTSIDE://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: OUTSIDE://192.168.1.11:9092
KAFKA_INTER_BROKER_LISTENER_NAME: OUTSIDE
KAFKA_ZOOKEEPER_CONNECT: *kafkaZookeepers
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LOG_MESSAGE_TIMESTAMP_TYPE: 'LogAppendTime'
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONNECTIONS_MAX_IDLE_MS: 31536000000 # 1 year
volumes:
- ./kafka-data/kafka:/var/lib/kafka/data
networks:
- mynet
kafka-ui:
image: provectuslabs/kafka-ui:0.2.1
hostname: kafka-ui
container_name: kafka-ui
depends_on:
- broker
ports:
- "8084:8080"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
KAFKA_CLUSTERS_0_NAME: local_kafka
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: *kafkaBrokers
KAFKA_CLUSTERS_0_ZOOKEEPER: *kafkaZookeepers
networks:
- mynet
networks:
mynet:
driver: bridge
docker-compose.yml 其他虚拟机上的文件看起来相似(我现在只设置了 3 个动物园管理员),在第二个虚拟机上:
version: '3.7'
x-zoo: &zoo "kafka-1:2888:3888;kafka-2:2888:3888;kafka-3:2888:3888"
x-kafkaZookeepers: &kafkaZookeepers "kafka-1:2181,kafka-2:2181,kafka-3:2181"
x-kafkaBrokers: &kafkaBrokers "kafka-1:9092"
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
ZOOKEEPER_SERVER_ID: 2
ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: *zoo
volumes:
- ./kafka-data/zookeeper:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs:/var/lib/zookeeper/log
networks:
- mynet
networks:
mynet:
driver: bridge
在第 3 个虚拟机上:
version: '3.7'
x-zoo: &zoo "kafka-1:2888:3888;kafka-2:2888:3888;kafka-3:2888:3888"
x-kafkaZookeepers: &kafkaZookeepers "kafka-1:2181,kafka-2:2181,kafka-3:2181"
x-kafkaBrokers: &kafkaBrokers "kafka-1:9092"
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
extra_hosts:
- "kafka-1:192.168.1.11"
- "kafka-2:192.168.1.12"
- "kafka-3:192.168.1.13"
environment:
ZOOKEEPER_SERVER_ID: 3
ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_PEER_PORT: 2888
ZOOKEEPER_LEADER_PORT: 3888
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVERS: *zoo
volumes:
- ./kafka-data/zookeeper:/var/lib/zookeeper/data
- ./kafka-data/zookeeper-logs:/var/lib/zookeeper/log
networks:
- mynet
networks:
mynet:
driver: bridge
根据日志,所有 Docker 个容器现在可以相互连接。
我还将主机 kafka-1、kafka-2、kafka-3 添加到虚拟机上的 /etc/hosts 文件中:
test@kafka-1:~/Kafka-Docker$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 kafka-1
192.168.1.11 kafka-1
192.168.1.12 kafka-2
192.168.1.13 kafka-3
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
希望它能节省一些人的时间和精力,也许这就是我一直在等待的答案! :-)
另请注意,我使用的是最新的 atm(查看日期)docker 图片(cp-zookeper、cp-kafka 等)6.2.1 来自docker来自官方合流发布者的集线器。
更新: 我在每个动物园管理员上转发端口 4888->8080 并获得 简单的 REST 管理页面 ( https://zookeeper.apache.org/doc/r3.5.9/zookeeperAdmin.html#sc_zkCommands )我可以在哪里看到谁是“领导者”,谁是“追随者”,例如: enter image description here enter image description here