apache-kafka - 如果 ID=0 的代理关闭,Kafka 集群将无法工作
问题描述
我有一个带有 3 个代理的 Kafka 集群,配置如下:
Broker-0 : broker.id=0 ; listeners=PLAINTEXT://localhost:9092 ; log.dirs=/opt/data/kafka/logs-0
Broker-1 : broker.id=1 ; listeners=PLAINTEXT://localhost:9093 ; log.dirs=/opt/data/kafka/logs-1
Broker-2 : broker.id=2 ; listeners=PLAINTEXT://localhost:9094 ; log.dirs=/opt/data/kafka/logs-2
生产者以 Broker-2 为目标发布消息
sh-3.2# ./kafka-console-producer.sh --broker-list localhost:9094 --topic clusterTopic
我开始测试所有启动并运行的代理
sh-3.2# ./bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic clusterTopic
Topic:clusterTopic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: clusterTopic Partition: 0 Leader: 0 Replicas: 0,1,2 Isr: 2,0,1
sh-3.2#
A至此,生产者发布的所有消息都被消费者接收到了
然后我杀了Broker-0(现任领导)
sh-3.2# ./bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic clusterTopic
Topic:clusterTopic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: clusterTopic Partition: 0 Leader: 1 Replicas: 0,1,2 Isr: 2,1
sh-3.2#
此时,消费者不再收到生产者发布的消息
然后,我启用了 Broker-0
sh-3.2# ./bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic clusterTopic
Topic:clusterTopic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: clusterTopic Partition: 0 Leader: 1 Replicas: 0,1,2 Isr: 2,1,0
sh-3.2#
此时,生产者发布的所有消息都被消费者正确接收
然后我杀了Broker-1(现任领导)
sh-3.2# ./bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic clusterTopic
Topic:clusterTopic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: clusterTopic Partition: 0 Leader: 0 Replicas: 0,1,2 Isr: 2,0
sh-3.2#
此时,生产者发布的所有消息仍然被消费者正确接收。
为什么经纪人之间的行为如此不同?
更新 #1
我注意到一些可能有用的东西:
当我杀死 Broker-1 时,我在消费者控制台上看到以下警告(很多次)
[2018-06-07 13:59:00,866] WARN [Consumer clientId=consumer-1, groupId=console-consumer-20882] Connection to node 1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
但是当我杀死 Broker-0 时,我看到了这些警告消息(很多次)
[2018-06-07 14:04:08,433] WARN [Consumer clientId=consumer-1, groupId=console-consumer-20882] Connection to node 2147483647 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2018-06-07 14:04:08,434] WARN [Consumer clientId=consumer-1, groupId=console-consumer-20882] Connection to node 0 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
我想知道 ID=2147483647 的经纪人是什么?
解决方案
推荐阅读
- android - 有没有办法检查媒体何时开始流式传输并开始播放
- jquery - CSS 动画 - 请告诉我为什么案例 #1 有效,但案例 #2 无效
- java - 除了 Java 中的非编译时常量,接口是否还有其他字段?
- powershell - 如何使用任务计划程序在 Powershell 中修复“无法在空值表达式上调用方法”
- java - 带有继承的 Dagger-Android Activity 注入:“这种类型支持成员注入,但不能隐式提供。”
- python - 如何修复石头剪刀布中的计算机选择
- javascript - threejs几何三角形旋转不居中
- python - 从 tkinter filedialog 返回文件的文件路径
- php - 检查电报登录的输入
- javascript - 即使用户存在于 nodejs 应用程序的 mongodb 中,model.findOne() 也会返回 null