问题描述
在为超级账本结构配置我的kafka经纪人docker容器时,我需要一些帮助。我的设置将是一个由4个经纪人组成的集群,介绍第二个经纪人时遇到问题。目前所有经纪人都坐在一台计算机上,我需要他们发布外部地址,以便我在不同计算机上的订购者可以发现它们。
I need some assistance with configuring my kafka brokers docker containers for hyperledger fabric. My setup will be a cluster of 4 brokers and I am having an issue when I introduce the second broker. All the brokers are currently sitting on a single machine and I need them to advertise their external address so that my orderers on different machines can discover them.
我的撰写文件中有1 Zookeeper和1个经纪人:
My compose file with 1 Zookeeper and 1 Broker:
version: '2'
services:
zookeeper0.hyperfabric.xyz:
image: hyperledger/fabric-zookeeper
restart: always
container_name: zookeeper0.hyperfabric.xyz
environment:
- ZOO_SERVERS=server.1=zookeeper0.hyperfabric.xyz:2888:3888
- ZOO_MY_ID=1
ports:
- 2181:2181
- 2888:2888
- 3888:3888
kafka0.hyperfabric.xyz:
image: hyperledger/fabric-kafka
restart: always
container_name: kafka0.hyperfabric.xyz
environment:
- KAFKA_MESSAGE_MAX_BYTES=103809024
- KAFKA_REPLICA_FETCH_MAX_BYTES=103809024
- KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
- KAFKA_MIN_INSYNC_REPLICAS=1
- KAFKA_DEFAULT_REPLICATION_FACTOR=1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper0.hyperfabric.xyz:2181
- KAFKA_BROKER_ID=0
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka0.hyperfabric.xyz:9092
ports:
- 9092:9092
- 9093:9093
运行此程序效果很好。
当我使用以下方法介绍其他经纪人时:
When I introduce another broker using:
kafka1.hyperfabric.xyz:
image: hyperledger/fabric-kafka
restart: always
container_name: kafka1.hyperfabric.xyz
environment:
- KAFKA_MESSAGE_MAX_BYTES=103809024
- KAFKA_REPLICA_FETCH_MAX_BYTES=103809024
- KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
- KAFKA_MIN_INSYNC_REPLICAS=1
- KAFKA_DEFAULT_REPLICATION_FACTOR=1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper0.hyperfabric.xyz:2181
- KAFKA_BROKER_ID=1
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka1.hyperfabric.xyz:10092
ports:
- 10092:9092
- 10093:9093
我收到以下无限循环错误:
I get the followin infinitely looping error:
[2018-05-11 02:04:08,310] WARN [Controller id=0, targetBrokerId=1] Connection to node 1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
该错误与我的KAFKA_ADVERTISED_LISTENERS(相同KAFKA_ADVERTISED_HOST_NAME和KAFKA_ADVERTISED_PORT环境变量会发生这种情况。如果删除它,它可以工作,但是我的订购者将不会收到经纪人的地址,而且订购者和经纪人之间的通信也会丢失。
The error is somewhat related to my KAFKA_ADVERTISED_LISTENERS (same thing happens with KAFKA_ADVERTISED_HOST_NAME and KAFKA_ADVERTISED_PORT) environmental variable. If I remove it, it works, but then my orderers will not receive the brokers address and I will lose communication between orderers and brokers.
如何维护内部连接
推荐答案
我可以通过更改kafka1容器的外观来使所有东西连接起来像这样:
I was able to get everything connected by changing my kafka1 container to look like this:
kafka1.hyperfabric.xyz:
image: hyperledger/fabric-kafka
restart: always
container_name: kafka1.hyperfabric.xyz
environment:
- KAFKA_PORT=10092
- KAFKA_MESSAGE_MAX_BYTES=103809024
- KAFKA_REPLICA_FETCH_MAX_BYTES=103809024
- KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
- KAFKA_MIN_INSYNC_REPLICAS=1
- KAFKA_DEFAULT_REPLICATION_FACTOR=1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper0.hyperfabric.xyz:2181
- KAFKA_BROKER_ID=1
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka1.hyperfabric.xyz:10092
ports:
- 10092:10092
- 10093:9093
差异为-KAFKA_PORT = 10092
和-10092:10092
这篇关于Kafka Broker for Hyperledger Fabric无法建立连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!