具体报错:[Producer clientId=console-producer] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
使用的指令:
之后输入数据回车报错
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic clicks
看了下相关配置文件
[root@master kafka]# cat config/server.properties | grep 9092 # listeners = PLAINTEXT://your.host.name:9092 #listeners=PLAINTEXT://:9092 listeners=PLAINTEXT://master:9092 #advertised.listeners=PLAINTEXT://your.host.name:9092 [root@master kafka]# pwd /export/server/kafka [root@master kafka]#
从上述结果来看,是报错和配置里面的地址有关系,只需要改用配置里的hostname启动就好了
./bin/kafka-console-producer.sh --broker-list master:9092 --topic clicks