CentOS 7.9 安装 kafka_2.13( 二 )

5 生产者(消息发送程序)
./bin/kafka-console-producer.sh --broker-list 192.168.0.98:8091 --topic iyuyixyz6 消费者(消息接收程序)
./bin/kafka-console-consumer.sh --bootstrap-server 192.168.0.98:8091 --topic iyuyixyz【CentOS 7.9 安装 kafka_2.13】六、配置系统环境变量
vim /etc/profileexport PATH=$PATH:/opt/kafka_2.13-3.0.1/bin# 使配置生效source /etc/profile七、报错1 zookeeper is not a recognized option
新版已不支持zookeeper参数,需要换成bootstrap-server参数 。
./bin/kafka-topics.sh --create --zookeeper 192.168.0.98:2181 --replication-factor 1 --partitions 1 --topic iyuyixyz原来新版本的kafka,已经不需要依赖zookeeper来创建topic,新版的kafka创建topic指令为下
./bin/kafka-topics.sh --bootstrap-server 192.168.0.98:8091 --create --topic iyuyixyz --partitions 2 --replication-factor 1

CentOS 7.9 安装 kafka_2.13

文章插图
2 节点响应超时(请求超时)
[2022-10-13 01:11:34,670] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (/192.168.0.92:8092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)[2022-10-13 01:11:37,676] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (/192.168.0.92:8092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)[2022-10-13 01:11:40,682] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (/192.168.0.92:8092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)Error while executing topic command : Timed out waiting for a node assignment. Call: createTopics[2022-10-13 01:11:43,600] ERROR org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: createTopics (kafka.admin.TopicCommand$)该错误是由于没有用对应版本的命令,访问了错的主机名(或IP)和端口,所以请求失败导致超时 。
其中的createTopics、listTopics等都会出现该错误 。如果没配置server.properties文件的listeners值,也会报以上错误 。
listeners值默认是PLAINTEXT://:9092,要改为PLAINTEXT://localhost:9092或PLAINTEXT://IP:9092等
CentOS 7.9 安装 kafka_2.13

文章插图

经验总结扩展阅读