测试向kafka中发消息
unset JMX_PORT; bin/kafka-console-producer.sh \--broker-list localhost:9092 \--topic test-topic 123
然后随便输入数据, 回车, 报错:
WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
实际上是地址的问题, 改成下面的就可以了(实际地址取决于你的kafka配置)
unset JMX_PORT; bin/kafka-console-producer.sh \--broker-list PLAINTEXT://192.168.3.125:9092 \--topic test-topic 123
实际中应该看自己kafka的配置(默认是:${KAFKA_ROOT}/config/server.properties)
(完)