无法在hyperledger结构中设置kaka订购者network:unexpected topic-level 元数据错误:kafka服务器:复制因子无效

vlju58qv  于 2021-06-08  发布在  Kafka
关注(0)|答案(1)|浏览(420)

配置如下:我有4台服务器,分别在server1,server2,server3中启动zookeeper0,zookeeper1,zookeeper2,如下(其中i=0,1,2)

`docker run -itd --network="networkName" --name zookeeperi \
-e ZOO_MY_ID=i+1 \
-e ZOO_SERVERS.1=zookeeper0IP:2888:3888 \
-e ZOO_SERVERS.2=zookeeper1IP:2888:3888 \
-e ZOO_SERVERS.3=zookeeper2IP:2888:3888 \
-p 2181:2181 \
-p 2888:2888 \
-p 3888:3888 \
-v /opt/share/hyperledger/zookeeper:/tmp/zookeeper \
hyperledger/fabric-zookeeper:latest`

接下来,我将在4个respective服务器中启动4个kafka代理(式中i=0,1,2,3)

`docker run -itd --network="networkName" --name kafkai --restart always \
-e KAFKA_BROKER_ID=i \
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper0IP:2181,zookeeper1IP,zookeeper2IP:2181 
\
-e KAFKA_LOG_RETENTION_MS=-1 \
-e KAFKA_MESSAGE_MAX_BYTES=103809024 \
-e KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 \
-e KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false \
-e KAFKA_DEFAULT_REPLICATION_FACTOR=3 \
-e KAFKA_MIN_INSYNC_REPLICAS=2 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka0:9092 \
-p 9092:9092 \
-p 9093:9093 \
hyperledger/fabric-kafka:latest`

最后,我将在3个不同的服务器上启动order0、order1和order2(式中i=0,1,2)

`docker run --rm  -it --network="networkName" --name ordereri -p 7055:7050 \
-e ORDERER_GENERAL_LOGLEVEL=debug \
-e ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 \
-e ORDERER_GENERAL_GENESISMETHOD=file \
-e ORDERER_GENERAL_GENESISFILE=/opt/hyperledger/fabric/msp/crypto- 
config/ordererOrganizations/genesis.block \
-e ORDERER_GENERAL_LOCALMSPID=OrdererMSP \
-e ORDERER_GENERAL_LOCALMSPDIR=/opt/hyperledger/fabric/msp/crypto- 
config/ordererOrganizations/test.com/orderers/ordereri/msp \
-e ORDERER_GENERAL_TLS_ENABLED=false \
-e ORDERER_GENERAL_LISTENPORT=7050 \
-e CONFIGTX_ORDERER_ORDERERTYPE=kafka \
-e CONFIGTX_ORDERER_KAFKA_BROKERS= 
[kafka0:9092,kafka1:9092,kafka2:9092,kafka3:9092] \
-e ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s \
-e ORDERER_KAFKA_RETRY_SHORTTOTAL=30s \
-e ORDERER_KAFKA_VERBOSE=true \
-e ORDERER_GENERAL_LEDGERTYPE=ram \
-e ORDERER_GENERAL_TLS_ENABLED=false \
--mount type=bind,source=/opt/share/hyperledger/crypto- 
config,destination=/opt/hyperledger/fabric/msp/crypto-config \
-w /opt/gopath/src/github.com/hyperledger/fabric \
hyperledger/fabric-orderer:x86_64-1.1.0 orderer`

但是,订购者日志会引发以下kafka错误:

`2018-07-02 06:29:00.216 UTC [orderer/common/server] Start -> INFO 095 Starting orderer:
Version: 1.1.0
Go version: go1.9.2
OS/Arch: linux/amd64
Experimental features: false
2018-07-02 06:29:00.217 UTC [orderer/common/server] Start -> INFO 096 Beginning to serve requests
2018-07-02 06:29:00.217 UTC [orderer/consensus/kafka] setupProducerForChannel -> INFO 097 [channel: testchainid] Setting up the producer for this channel...
2018-07-02 06:29:00.217 UTC [orderer/consensus/kafka] try -> DEBU 098 [channel: testchainid] Connecting to the Kafka cluster
2018-07-02 06:29:00.217 UTC [orderer/consensus/kafka/sarama] NewClient -> DEBU 099 Initializing new client
2018-07-02 06:29:00.217 UTC [orderer/consensus/kafka/sarama] Validate -> DEBU 09a ClientID is the default of 'sarama', you should consider setting it to something application-specific.
2018-07-02 06:29:00.217 UTC [orderer/consensus/kafka/sarama] Validate -> DEBU 09b ClientID is the default of 'sarama', you should consider setting it to something application-specific.
2018-07-02 06:29:00.218 UTC [orderer/consensus/kafka/sarama] tryRefreshMetadata -> DEBU 09c client/metadata fetching metadata for all topics from broker kafka1:9092
2018-07-02 06:29:00.219 UTC [orderer/consensus/kafka/sarama] func1 -> DEBU 09d Connected to broker at kafka1:9092 (unregistered)
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka/sarama] registerBroker -> DEBU 09e client/brokers registered new broker #2 at kafka2:9092
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka/sarama] registerBroker -> DEBU 09f client/brokers registered new broker #1 at kafka1:9092
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka/sarama] NewClient -> DEBU 0a0 Successfully initialized new client
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka] try -> DEBU 0a1 [channel: testchainid] Error is nil, breaking the retry loop
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka] startThread -> INFO 0a2 [channel: testchainid] Producer set up successfully
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka] sendConnectMessage -> INFO 0a3 [channel: testchainid] About to post the CONNECT message...
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka] try -> DEBU 0a4 [channel: testchainid] Attempting to post the CONNECT message...
2018-07-02 06:29:00.223 UTC [orderer/consensus/kafka/sarama] tryRefreshMetadata -> DEBU 0a5 client/metadata fetching metadata for [testchainid] from broker kafka1:9092
2018-07-02 06:29:00.230 UTC [orderer/consensus/kafka/sarama] updateMetadata -> DEBU 0a6 Unexpected topic-level metadata error: kafka server: Replication-factor is invalid.
2018-07-02 06:29:00.230 UTC [orderer/consensus/kafka] try -> DEBU 0a7 [channel: testchainid] Initial attempt failed = kafka server: Replication-factor is invalid.
2018-07-02 06:29:00.230 UTC [orderer/consensus/kafka] try -> DEBU 0a8 [channel: testchainid] Retrying every 1s for a total of 30s
2018-07-02 06:29:01.230 UTC [orderer/consensus/kafka] try -> DEBU 0a9 [channel: testchainid] Attempting to post the CONNECT message...
2018-07-02 06:29:01.230 UTC [orderer/consensus/kafka/sarama] tryRefreshMetadata -> DEBU 0aa client/metadata fetching metadata for [testchainid] from broker kafka1:9092
2018-07-02 06:29:01.236 UTC [orderer/consensus/kafka/sarama] updateMetadata -> DEBU 0ab Unexpected topic-level metadata error: kafka server: Replication-factor is invalid`

感谢您的帮助。

xpcnnkqh

xpcnnkqh1#

似乎您的orderer节点只接收kafka2和kafka1:

2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka/sarama] registerBroker -> DEBU 09e client/brokers registered new broker #2 at kafka2:9092
2018-07-02 06:29:00.222 UTC [orderer/consensus/kafka/sarama] registerBroker -> DEBU 09f client/brokers registered new broker #1 at kafka1:9092

检查configtx.yaml中的orderer和genesis块的配置。

Orderer: &OrdererDefaults

    OrdererType: kafka

    Addresses:
        - orderer.example.com:7050
...

    Kafka:
        # Brokers: A list of Kafka brokers to which the orderer connects. Edit
        # this list to identify the brokers of the ordering service.
        # NOTE: Use IP:port notation.
        Brokers:
            - kafka0:9092
            - kafka1:9092
            - kafka2:9092
            - kafka3:9092

您提供了以下环境变量:configtx\u order\u ordertype&configtx\u order\u kafka\u brokers。我不确定他们是否得到支持。

相关问题