将新节点添加到超级账本结构组织需要哪些步骤?

What steps are necessary to add a new peer to an organization of hyperledger fabric?

我正在学习使用 Hyperledger Fabric 构建网络,因为我已经使用 Hyperledger Composer 开发了一个网络,下一步是构建生产网络。我已经开始构建第一个网络示例并开始工作。我添加了带有 2 个对等点的 Org3 进行采样并且它有效。

现在我想添加更多点,例如 peer2。org1.example.com 所以我编辑了文件以创建 peer2 并且它已创建,但是当 script.sh 尝试加入时频道,它会启动一个错误:

Error: Error getting endorser client channel: PER:404 - Error trying to connect to local peer Caused by: x509: certificate is valid for peer1.org1.example.com, peer1, not peer2.org1.example.com

那么,我做错了什么?谢谢

当您向网络添加新对等点时,您需要确保为该新对等点正确设置所有带下划线的相关加密 material。首先确保将有关新节点的信息添加到 crypto-config.yaml 文件中,并使用 cryptogen 工具为新节点生成密钥和证书。接下来,您需要在启动对等点之前设置配置以指向相关的加密 material 例如 org2 的 peer0 的配置:

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org2.example.com
      - CORE_PEER_ADDRESS=peer0.org2.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051

它继承自 base/peer-base.yaml 文件:

services:
  peer-base:
    image: hyperledger/fabric-peer
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      # the following setting starts chaincode containers on the same
      # bridge network as the peers
      # https://docs.docker.com/compose/networking/
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
      #- CORE_LOGGING_LEVEL=ERROR
      - CORE_LOGGING_LEVEL=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls

    ports:
      - 9051:7051
      - 9053:7053

最后,您需要确保配置正确的 MSP ID 和 tls 证书的路径。在您的情况下,您的新对等方只是尝试重用另一个对等方的加密 material。

您可以通过为新节点生成加密 material(使用 cryptogen extends)来实现此目的,生成新节点并使该节点加入网络上的现有通道以 sync-up.

您可以在

找到完整的指南

Extending Hyperledger Fabric Network: Adding a new peer