kafkaデバッグ中にConnection to node-1 could not be estableshed.Broker may not be availableに遭遇しました.

7308 ワード

以前kafkaをインストールしたばかりで、独自のshellスクリプトを使用してtopicを作成しました.testはtestの生産者と消費者を開きました.テストは問題ありません.今日は再びデバッグして突然エラーを報告します.
生産者を作成するには、次の手順に従います.
 bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
 >test1
[2018-03-08 13:59:36,276] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2018-03-08 14:01:43,637] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2018-03-08 14:03:51,125] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2018-03-08 14:05:58,741] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2018-03-08 14:08:06,741] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2018-03-08 14:10:14,995] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

ここはとても気がふさいで、前に詰めたばかりの時まだ問題がなくて、この命令で、半日探しました:私のkafkaプロファイルの中でbroker=0はzookeeeperの配置情報を見てみます
>^C[root@test-lufei-6ec9ba1e-3ed1-4409-97dc-4089e858268b kafka_2.11-1.0.0]# bin/zookeeper-shell.sh localhost:2181 <<< "get /brokers/ids/0"
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is disabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
{"listener_security_protocol_map":{"PLAINTEXT":"PLAINTEXT"},"endpoints":["PLAINTEXT://172.28.50.143:9092"],"jmx_port":-1,"host":"172.28.50.143","timestamp":"1520487672966","port":9092,"version":4}
cZxid = 0x41
ctime = Thu Mar 08 13:41:12 CST 2018
mZxid = 0x41
mtime = Thu Mar 08 13:41:12 CST 2018
pZxid = 0x41
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x162041f2de00000
dataLength = 196
numChildren = 0

>

ここでは、「endpoints」:["PLAINTEXT://172.8.5.0.143:9092"]の作成時に生産者がlocalhostを使用していましたが、ここでは
bin/kafka-console-consumer.sh --bootstrap-server PLAINTEXT://172.28.50.143:9092 --topic test --from-beginning

topicにメッセージを送信できました!