我正在实施一个Kafka集群架构,在两台本地连接的机器中有2个经纪人和2个动物园管理员
Machine1(10.0.215.22):( Hidding trival属性) 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):( Hidding trival properties)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经纪人
然后我用它来从机器1创建主题
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:55,994] WARN [Producer clientId = console-producer]获取具有相关ID 1的元数据时出错:{test = LEADER_NOT_AVAILABLE}(org.apache.kafka.clients.NetworkClient) [2018-04-19 17:00:56,098] WARN [Producer clientId = console-producer]获取具有相关ID 2的元数据时出错:{test = LEADER_NOT_AVAILABLE}(org.apache.kafka.clients.NetworkClient) [
当我尝试从机器1到机器2的经纪人生成消息时,我得到以上错误
我的机器通过局域网本地连接,我可以通过ssh轻松连接机器2,反之亦然,没有网络问题