[英]How to detect unreachable brokers Kafka and reconnect?
scheme: 2 broker -2 hosts Java clients - org.apache.kafka.clients.producer.KafkaProducer or org.apache.kafka.clients.consumer.KafkaConsumer Bootsrap servers property contain 2 ip address (2 brokers) Zookeeper - distributed coordinator 方案:2个代理-2托管Java客户端-org.apache.kafka.clients.producer.KafkaProducer或org.apache.kafka.clients.consumer.KafkaConsumer Bootsrap服务器属性包含2个IP地址(2个代理)Zookeeper-分布式管理员
Invocation Method at constructor org.apache.kafka.clients.ClientUtil#parseAndValidateAddresses check only network up servers without validate instance (check broken state server or doesn't start) 构造函数org.apache.kafka.clients.ClientUtil#parseAndValidateAddresses处的调用方法仅检查网络服务器而不验证实例(检查损坏的状态服务器或不启动)
By default, Zookeeper keep tracks of all nodes connected and reachable brokers. 默认情况下,Zookeeper跟踪所有连接的节点和可访问的代理。 You can query ZK to see what nodes are connected at present. 您可以查询ZK以查看当前连接了哪些节点。
# Connect to ZooKeeper
bin/zookeeper-shell.sh localhost:2181
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is disabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
>> ls /brokers/ids
[1, 2, 3]
>> ls /brokers/topics
[myTopic, __consumer_offsets]
>> get /brokers/ids/0
Node does not exist: /brokers/ids/0
>> get /brokers/ids/1
{"listener_security_protocol_map":{"PLAINTEXT":"PLAINTEXT","SSL":"SSL"},"endpoints":["PLAINTEXT://172.31.4.17:9092","SSL://18.216.252.106:9093"],"jmx_port":9999,"host":"172.31.4.17","timestamp":"1522349056258","port":9092,"version":4}
cZxid = 0x3000005f3
ctime = Thu Mar 29 18:44:16 UTC 2018
mZxid = 0x3000005f3
mtime = Thu Mar 29 18:44:16 UTC 2018
pZxid = 0x3000005f3
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x2625d127c0b0003
dataLength = 234
numChildren = 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.