自己的机器搭建kafka环境,测试过程中发现,写数据的时候一直报错
(base) leonlai@LEONLAI-MB0 kafka_2.11-0.9.0.1 % ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic
aa
[2020-08-22 00:29:52,814] WARN Error while fetching metadata with correlation id 0 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:52,915] WARN Error while fetching metadata with correlation id 1 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:53,021] WARN Error while fetching metadata with correlation id 2 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:53,127] WARN Error while fetching metadata with correlation id 3 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:53,234] WARN Error while fetching metadata with correlation id 4 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:53,341] WARN Error while fetching metadata with correlation id 5 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:53,443] WARN Error while fetching metadata with correlation id 6 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:53,549] WARN Error while fetching metadata with correlation id 7 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-08-22 00:29:53,653] WARN Error while fetching metadata with correlation id 8 : {test_topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
解决方法:修改onfig/server.properties,重新启动kafka
advertised.host.name=localhost