简体   繁体   English

如何检测不可达的经纪人Kafka并重新连接?

[英]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.

相关问题 在所有 kafka-pod 升级后,java 中的 kafka 消费者客户端无法重新连接到 kubernetes kafka 代理 - kafka consumer client in java can't reconnect to kubernetes kafka brokers after all of kafka-pods are upgraded 如何解决 Kafka 代理中的网络和 memory 问题? - How to solve network and memory issues in Kafka brokers? 如何在 Apache Beam 中使用 KafkaIO 指定 kafka 代理 - how to specify kafka brokers with KafkaIO in Apache Beam Kafka重新启动时如何使Kafka Source重新连接 - How to make Kafka Source reconnect when Kafka restarts 如何为不同的测试环境配置不同的 Kafka Brokers/endpoints? - How to configure different Kafka Brokers/endpoints for different test environments? 如何在一个应用程序中与两个未互连的卡夫卡经纪人一起工作? - How to work with two not interconnected Kafka brokers in one app? 如何使用 Java API 列出 Kafka 集群中的所有可用代理? - How to list all available brokers in Kafka cluster using Java API? 当所有经纪人破产时,卡夫卡如何处理生产者? - How does Kafka handles producers when all brokers go down? 如何使用 jhipster 在 Kafka 集群上设置多个代理 - How to set up multiple brokers on the Kafka Cluster with jhipster 从应用程序创建到 Kafka 代理的连接数 - How many Connections are created to Kafka brokers from a application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM