不同机器上的kafka multibroker不工作

wfypjpf4  于 2021-06-07  发布在  Kafka
关注(0)|答案(0)|浏览(174)

我正在实现一个kafka集群架构,在本地连接的两台机器上有2个代理和2个Zookeeper
machine1(10.0.215.22):(隐藏琐碎的属性)kakfa->server.properties

port=9094
broker.id=1
num.partitions=1
zookeeper.connect=10.0.215.22:2181,10.0.229.48:2181
delete.topic.enable = true
auto.create.topics.enable=true

Zookeeper->

clientPort=2181
server.1=10.0.215.22:2888:3888
server.2=10.0.229.48:2888:3888

machine2(10.0.229.48):(隐藏琐碎属性)kakfa->server.properties kakfa->server.properties

port=9094
broker.id=2
num.partitions=1
zookeeper.connect=10.0.215.22:2181,10.0.229.48:2181
delete.topic.enable = true
auto.create.topics.enable=true

Zookeeper->

clientPort=2181
server.1=10.0.215.22:2888:3888
server.2=10.0.229.48:2888:3888

在两台机器上启动zookeeper后,我启动了kafka brokers
然后我用这个从machine1创建主题

kafka/bin/kafka-topics.sh --c~reate --zookeeper 10.0.215.22:2181 --replication-factor 2 --partitions 2 --topic test
Created topic "test".

kafka/bin/kafka-topics.sh --zookeeper 10.0.215.22:2181 --topic test --describe

Topic:test  PartitionCount:2    ReplicationFactor:2 Configs:

    Topic: test Partition: 0    Leader: 2   Replicas: 2,1   Isr: 2,1
    Topic: test Partition: 1    Leader: 1   Replicas: 1,2   Isr: 1

然后使用控制台生成器:

~/kafka/bin/kafka-console-producer.sh --broker-list 10.0.229.48:9094 --topic test

测试
[2018-04-19 17:00:55994]获取相关id为1的元数据时警告[producer clientid=console producer]错误:{test=leader\u not\u available}(org.apache.kafka.clients.networkclient)[2018-04-19 17:00:56,098]获取相关id为2的元数据时出现警告[producer clientid=console producer]错误:{test=leader\u not\u available}(org.apache.kafka.clients.networkclient)[
当我试图从机器1向机器2的代理生成消息时,出现了上述错误
我的机器通过局域网本地连接,我可以很容易地通过ssh连接机器2,反之亦然,没有网络问题

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题