基于kafka的网络中的多订购者冗余

h5qlskok  于 2021-06-06  发布在  Kafka
关注(0)|答案(2)|浏览(343)

我们在配置一个基于3个组织的结构网络时遇到了麻烦,每个组织有1个对等方,2个基于kafka的订购方。对于Kafka排序,我们使用4个Kafka节点和3个缩放器。它部署在一些aws ec2示例上,如下所示:
1:组织1
2:组织2
3:组织3
4:order0,order1,kafka0,kafka1,kafka2,kafka3,zookeeper0,zookeeper1,zookeeper2
由于连接性的原因,整个ordering nodes plus kafka集群都位于同一台机器上(读取它们必须在同一台机器上的某个位置以避免这些问题)
在测试过程中,我们尝试使用docker stop关闭第一个order(order0)进行冗余测试。我们期望网络通过order1继续工作,但是它却死掉了,停止了工作。
查看对等机的控制台,我可以看到一些错误。
无法连接到任何终结点:[order0.example]。com:7050,order1.example。com:8050]
找到附件中与系统配置相关的文件内容。
订购方+Kafka+zk


# 

# Copyright IBM Corp. All Rights Reserved.

# 

# SPDX-License-Identifier: Apache-2.0

# 

version: '2'

services:

  zookeeper0.example.com:
    container_name: zookeeper0.example.com
    extends:
      file: docker-compose-base.yaml
      service: zookeeper0.example.com
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"

  zookeeper1.example.com:
    container_name: zookeeper1.example.com
    extends:
      file: docker-compose-base.yaml
      service: zookeeper1.example.com
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"

  zookeeper2.example.com:
    container_name: zookeeper2.example.com
    extends:
      file: docker-compose-base.yaml
      service: zookeeper2.example.com
    logging:
     driver: "json-file" 
     options:
      max-size: "1m"
      max-file: "3"

  kafka0.example.com:
    container_name: kafka0.example.com
    extends:
      file: docker-compose-base.yaml
      service: kafka0.example.com
    depends_on:
      - zookeeper0.example.com
      - zookeeper1.example.com
      - zookeeper2.example.com
      - orderer0.example.com
      - orderer1.example.com
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"

  kafka1.example.com:
    container_name: kafka1.example.com
    extends:
      file: docker-compose-base.yaml
      service: kafka1.example.com
    depends_on:
      - zookeeper0.example.com
      - zookeeper1.example.com
      - zookeeper2.example.com
      - orderer0.example.com
      - orderer1.example.com
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"

  kafka2.example.com:
    container_name: kafka2.example.com
    extends:
      file: docker-compose-base.yaml
      service: kafka2.example.com
    depends_on:
      - zookeeper0.example.com
      - zookeeper1.example.com
      - zookeeper2.example.com
      - orderer0.example.com
      - orderer1.example.com
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"

  kafka3.example.com:
    container_name: kafka3.example.com
    extends:
      file: docker-compose-base.yaml
      service: kafka3.example.com        
    depends_on:
      - zookeeper0.example.com
      - zookeeper1.example.com
      - zookeeper2.example.com
      - orderer0.example.com
      - orderer1.example.com
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"

  orderer0.example.com:
    container_name: orderer0.example.com
    image: hyperledger/fabric-orderer:x86_64-1.1.0
    environment:
      - ORDERER_GENERAL_LOGLEVEL=debug
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_LISTEN_PORT=7050
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/crypto/orderer/msp
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/crypto/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/crypto/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/crypto/orderer/tls/ca.crt, /etc/hyperledger/crypto/peerOrg1/tls/ca.crt, /etc/hyperledger/crypto/peerOrg2/tls/ca.crt, /etc/hyperledger/crypto/peerOrg3/tls/ca.crt]
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderers
    command: orderer
    ports:
      - 7050:7050
    volumes:
        - ./channel:/etc/hyperledger/configtx
        - ./channel/crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/:/etc/hyperledger/crypto/orderer
        - ./channel/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/crypto/peerOrg1
        - ./channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/crypto/peerOrg2
        - ./channel/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/:/etc/hyperledger/crypto/peerOrg3
    depends_on:
        - kafka0.example.com
        - kafka1.example.com
        - kafka2.example.com
        - kafka3.example.com

  orderer1.example.com:
    container_name: orderer1.example.com
    image: hyperledger/fabric-orderer:x86_64-1.1.0
    environment:
      - ORDERER_GEN ERAL_LOGLEVEL=debug
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_LISTEN_PORT=8050
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/crypto/orderer/msp
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/crypto/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/crypto/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/crypto/orderer/tls/ca.crt, /etc/hyperledger/crypto/peerOrg1/tls/ca.crt, /etc/hyperledger/crypto/peerOrg2/tls/ca.crt, /etc/hyperledger/crypto/peerOrg3/tls/ca.crt]
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderers
    command: orderer
    ports:
      - 8050:7050
    volumes:
        - ./channel:/etc/hyperledger/configtx
        - ./channel/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/:/etc/hyperledger/crypto/orderer
        - ./channel/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/crypto/peerOrg1
        - ./channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/crypto/peerOrg2
        - ./channel/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/:/etc/hyperledger/crypto/peerOrg3
    depends_on:
        - kafka0.example.com
        - kafka1.example.com
        - kafka2.example.com
        - kafka3.example.com

来自org2的对等机和ca


# 

# Copyright IBM Corp. All Rights Reserved.

# 

# SPDX-License-Identifier: Apache-2.0

# 

version: '2'

services:

  ca.org2.example.com:
    image: hyperledger/fabric-ca:x86_64-1.1.0
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/efa7d0819b7083f6c06eb34da414acbcde79f607b9ce26fb04dee60cf79a389a_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/efa7d0819b7083f6c06eb34da414acbcde79f607b9ce26fb04dee60cf79a389a_sk
    ports:
      - "8054:7054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
    volumes:
      - ./channel/crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg2

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org2.example.com
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_ADDRESS=peer0.org2.example.com:7051
    ports:
      - 8051:7051
      - 8053:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/crypto/peer
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"
    extra_hosts:
      - "orderer0.example.com:xxx.xxx.xxx.xxx"
      - "orderer1.example.com:xxx.xxx.xxx.xxx"
      - "kafka0.example.com:xxx.xxx.xxx.xxx"
      - "kafka1.example.com:xxx.xxx.xxx.xxx"
      - "kafka2.example.com:xxx.xxx.xxx.xxx"
      - "kafka3.example.com:xxx.xxx.xxx.xxx"

订购者基数


# Copyright IBM Corp. All Rights Reserved.

# 

# SPDX-License-Identifier: Apache-2.0

# 

version: '2'

services:

  orderer-base:
    image: hyperledger/fabric-orderer:$IMAGE_TAG
    environment:
      - ORDERER_GENERAL_LOGLEVEL=error
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      # enabled TLS
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      # kafka
      - CONFIGTX_ORDERER_ORDERERTYPE=kafka
      - CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0.example.com,kafka1.example.com,kafka2.example.com,kafka3.example.com]
      - ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s
      - ORDERER_KAFKA_RETRY_SHORTTOTAL=30s
      - ORDERER_KAFKA_VERBOSE=true
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: orderer

Kafka基地


# Copyright IBM Corp. All Rights Reserved.

# 

# SPDX-License-Identifier: Apache-2.0

# 

version: '2'

services:

  zookeeper:
    image: hyperledger/fabric-zookeeper
    environment:
      - ZOO_SERVERS=server.1=zookeeper0.example.com:2888:3888 server.2=zookeeper1.example.com:2888:3888 server.3=zookeeper2.example.com:2888:3888
    restart: always

  kafka:
    image: hyperledger/fabric-kafka
    restart: always
    environment:
      - KAFKA_MESSAGE_MAX_BYTES=103809024 # 99 * 1024 * 1024 B
      - KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 # 99 * 1024 * 1024 B
      - KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
      - KAFKA_MIN_INSYNC_REPLICAS=2
      - KAFKA_DEFAULT_REPLICATION_FACTOR=3
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper0.example.com:2181,zookeeper1.example.com:2181,zookeeper2.example.com:2181
    logging:
     driver: "json-file"
     options:
      max-size: "1m"
      max-file: "3"

配置tx.yaml

Organizations:

    - &OrdererOrg

        Name: OrdererMSP

        ID: OrdererMSP

        MSPDir: crypto-config/ordererOrganizations/example.com/msp

    - &Org1

        Name: Org1MSP

        ID: Org1MSP

        MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

        AnchorPeers:

            - Host: peer0.org1.example.com
              Port: 7051

    - &Org2

        Name: Org2MSP

        ID: Org2MSP

        MSPDir: crypto-config/peerOrganizations/org2.example.com/msp

        AnchorPeers:

            - Host: peer0.org2.example.com
              Port: 7051

    - &Org3

        Name: Org3MSP

        ID: Org3MSP

        MSPDir: crypto-config/peerOrganizations/org3.example.com/msp

        AnchorPeers:

            - Host: peer0.org3.example.com
              Port: 7051

################################################################################ 

Orderer: &OrdererDefaults

    OrdererType: kafka

    Addresses:
        - orderer0.example.com:7050
        - orderer1.example.com:7050

    BatchTimeout: 2s

    BatchSize:

        MaxMessageCount: 10

        AbsoluteMaxBytes: 98 MB

        PreferredMaxBytes: 512 KB

    Kafka:
        Brokers:
            - kafka0.example.com:9092
            - kafka1.example.com:9092
            - kafka2.example.com:9092
            - kafka3.example.com:9092

    Organizations:

################################################################################ 

Application: &ApplicationDefaults

    Organizations:

################################################################################ 

Profiles:

    ThreeOrgsOrdererGenesis:
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
                    - *Org3
    ThreeOrgsChannel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
                - *Org3

可能是配置错误吗?连接问题几乎被丢弃,因为在本地机器上运行相同的网络会得到相同的结果。
提前谢谢,谢谢

w80xi6nr

w80xi6nr1#

我不确定,但可能是因为不同的网络层。因为它是一个不同的compose文件,docker为每个composer创建不同的网络层。
另外,我没有看到yaml文件中提到的网络。
请使用“docker网络列表”检查网络层列表。

qvsjd97n

qvsjd97n2#

终于顺利了。原来问题不在docker compose文件中,而是在web服务的fabric sdk版本中。我在1.1版上使用了fabric客户端和fabric ca客户端,直到1.2版才出现(更多信息https://jira.hyperledger.org/browse/fabn-90)
澄清一下,由于两个订购者之间的互连,我能够看到两个订购者上都发生了事务,但我只攻击了第一个订购者。当那个订购者倒下时,网络就会变黑。
我了解fabric处理订购者的方式,它指向列表中的第一个订购者,如果它已关闭或无法访问,则将其移动到列表的底部,并指向下一个订购者。这是自1.2以来发生的事情,在旧版本中,您必须编写自己的错误控制器,以便它更改为下一个订购者。

相关问题