Hyperledger fabric 如何在2台机器上设置结构网络v2?

Hyperledger fabric 如何在2台机器上设置结构网络v2?,hyperledger-fabric,Hyperledger Fabric,我正在尝试在2个虚拟机上设置HLF first网络。因此,我为每台机器创建了2个yaml文件 机器1: -1订购方 -2个同龄人 -2 couchdb -1 ca 机器2: -2个同龄人 -2 couchdb -1 ca 获取块0没有问题,我能够创建通道并最终安装链码。然而,当我试图批准我的组织的链码定义时,我从两台机器收到相同的错误 错误:检索广播客户端失败:订购方客户端未能连接到127.0.0.1:7050:未能创建新连接:连接错误:desc=“拨号时传输:错误:拨号tcp 127.0.0.

我正在尝试在2个虚拟机上设置HLF first网络。因此,我为每台机器创建了2个yaml文件

机器1: -1订购方 -2个同龄人 -2 couchdb -1 ca

机器2: -2个同龄人 -2 couchdb -1 ca

获取块0没有问题,我能够创建通道并最终安装链码。然而,当我试图批准我的组织的链码定义时,我从两台机器收到相同的错误

错误:检索广播客户端失败:订购方客户端未能连接到127.0.0.1:7050:未能创建新连接:连接错误:desc=“拨号时传输:错误:拨号tcp 127.0.0.1:7050:连接:连接被拒绝”

顺便说一句,很抱歉,为了防止有人发现我的缺点,我试图指定一个大职位

我检查了我的容器:

docker logs orderer.example.com
输出:

2020-06-15 13:33:43.211 UTC [common.deliver] Handle -> WARN 05a Error reading from 160.40.55.128:41374: rpc error: code = Canceled desc = context canceled
2020-06-15 13:33:43.211 UTC [comm.grpc.server] 1 -> INFO 05b streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=160.40.55.128:41374 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=25.77361ms
2020-06-15 13:35:06.984 UTC [common.deliver] Handle -> WARN 05c Error reading from 160.40.55.128:41380: rpc error: code = Canceled desc = context canceled
2020-06-15 13:35:06.984 UTC [comm.grpc.server] 1 -> INFO 05d streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=160.40.55.128:41380 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=35.920976ms
020-06-15 14:17:25.473 UTC [core.comm] ServerHandshake -> ERRO 4728 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=<this is ip machine2>:51022
2020-06-15 14:17:25.473 UTC [core.comm] ServerHandshake -> ERRO 4729 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=<this is ip machine2>:40848
2020-06-15 14:42:42.257 UTC [gossip.channel] reportMembershipChanges -> INFO 19ab [[mychannel] Membership view has changed. peers went offline:  [[peer1.org1.example.com:7051 ]] , current view:  [[peer1.org2.example.com:7051] [peer0.org1.example.com:7051 ]]]
2020-06-15 14:42:42.823 UTC [gossip.comm] sendToEndpoint -> WARN 19ac Failed obtaining connection for peer1.org1.example.com:7051, PKIid:0a1afd4de6bc1b118a4a3d455045b67979b757e7f1936283ab27d106f0674aa1 reason: context deadline exceeded
用于peer0机器1

docker logs peer0.Org1.example.com
输出:

2020-06-15 13:33:43.211 UTC [common.deliver] Handle -> WARN 05a Error reading from 160.40.55.128:41374: rpc error: code = Canceled desc = context canceled
2020-06-15 13:33:43.211 UTC [comm.grpc.server] 1 -> INFO 05b streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=160.40.55.128:41374 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=25.77361ms
2020-06-15 13:35:06.984 UTC [common.deliver] Handle -> WARN 05c Error reading from 160.40.55.128:41380: rpc error: code = Canceled desc = context canceled
2020-06-15 13:35:06.984 UTC [comm.grpc.server] 1 -> INFO 05d streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=160.40.55.128:41380 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=35.920976ms
020-06-15 14:17:25.473 UTC [core.comm] ServerHandshake -> ERRO 4728 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=<this is ip machine2>:51022
2020-06-15 14:17:25.473 UTC [core.comm] ServerHandshake -> ERRO 4729 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=<this is ip machine2>:40848
2020-06-15 14:42:42.257 UTC [gossip.channel] reportMembershipChanges -> INFO 19ab [[mychannel] Membership view has changed. peers went offline:  [[peer1.org1.example.com:7051 ]] , current view:  [[peer1.org2.example.com:7051] [peer0.org1.example.com:7051 ]]]
2020-06-15 14:42:42.823 UTC [gossip.comm] sendToEndpoint -> WARN 19ac Failed obtaining connection for peer1.org1.example.com:7051, PKIid:0a1afd4de6bc1b118a4a3d455045b67979b757e7f1936283ab27d106f0674aa1 reason: context deadline exceeded
输出:

2020-06-15 13:33:43.211 UTC [common.deliver] Handle -> WARN 05a Error reading from 160.40.55.128:41374: rpc error: code = Canceled desc = context canceled
2020-06-15 13:33:43.211 UTC [comm.grpc.server] 1 -> INFO 05b streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=160.40.55.128:41374 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=25.77361ms
2020-06-15 13:35:06.984 UTC [common.deliver] Handle -> WARN 05c Error reading from 160.40.55.128:41380: rpc error: code = Canceled desc = context canceled
2020-06-15 13:35:06.984 UTC [comm.grpc.server] 1 -> INFO 05d streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=160.40.55.128:41380 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=35.920976ms
020-06-15 14:17:25.473 UTC [core.comm] ServerHandshake -> ERRO 4728 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=<this is ip machine2>:51022
2020-06-15 14:17:25.473 UTC [core.comm] ServerHandshake -> ERRO 4729 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=<this is ip machine2>:40848
2020-06-15 14:42:42.257 UTC [gossip.channel] reportMembershipChanges -> INFO 19ab [[mychannel] Membership view has changed. peers went offline:  [[peer1.org1.example.com:7051 ]] , current view:  [[peer1.org2.example.com:7051] [peer0.org1.example.com:7051 ]]]
2020-06-15 14:42:42.823 UTC [gossip.comm] sendToEndpoint -> WARN 19ac Failed obtaining connection for peer1.org1.example.com:7051, PKIid:0a1afd4de6bc1b118a4a3d455045b67979b757e7f1936283ab27d106f0674aa1 reason: context deadline exceeded
node1.yaml:

version: '2'

volumes:
  orderer.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:

networks:
  byfn:

services:

  ca0:
    image: hyperledger/fabric-ca:$IMAGE_TAG
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org1
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/priv_sk
      - FABRIC_CA_SERVER_PORT=7054
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/priv_sk -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2:IP_MACHINE2'
    container_name: ca_peerOrg1
    networks:
      - byfn

  orderer.example.com:
    container_name: orderer.example.com
    extends:
      file: base/peer-base.yaml
      service: orderer-base
    volumes:
        - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
        - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
        - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
        - orderer.example.com:/var/hyperledger/production/orderer
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2:IP_MACHINE2'
    ports:
      - 7050:7050
    networks:
      - byfn

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_PEER_ID=peer0.org1.example.com
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_certh
      - CORE_LOGGING_LEVEL=INFO
      - 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
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
      - peer0.org1.example.com:/var/hyperledger/production
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2:IP_MACHINE2'
    command: peer node start
    ports:
      - 7051:7051
      - 7053:7053
    depends_on:
      - couchdb0
    networks:
      - byfn

  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - '5984:5984'
    networks:
      - byfn

  peer1.org1.example.com:
    container_name: peer1.org1.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_PEER_ID=peer1.org1.example.com
      - CORE_PEER_ADDRESS=peer1.org1.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_certh
      - CORE_LOGGING_LEVEL=INFO
      - 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
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
      - peer1.org1.example.com:/var/hyperledger/production
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2: IP_MACHINE2'
    command: peer node start
    ports:
      - 8051:7051
      - 8053:7053
    depends_on:
      - couchdb1
    networks:
      - byfn

  couchdb1:
    container_name: couchdb1
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - '6984:5984'
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_LOGGING_LEVEL=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer    
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca1.example.com:IP_MACHINE2'    
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/:/opt/gopath/src/github.com/chaincode
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
      - ./ccp:/opt/gopath/src/github.com/hyperledger/fabric/peer/ccp
    depends_on:
      - orderer.example.com
      - peer0.org1.example.com
      - peer1.org1.example.com
    networks:
      - byfn
node2.yaml: 版本:“2”

volumes:
  peer0.org2.example.com:
  peer1.org2.example.com:

networks:
  byfn:

services:
  ca1:
    image: hyperledger/fabric-ca
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org2
      - 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/priv_sk
    ports:
      - '7054:7054'
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/priv_sk -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg2
    extra_hosts:
      - 'peer0.org1.example.com:IP_MACHINE1'
      - 'peer1.org1.example.com:IP_MACHINE1'
      - 'ca_peerOrg1:IP_MACHINE1'
      - 'orderer.example.com:IP_MACHINE1'
    networks:
      - byfn

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_PEER_ID=peer0.org2.example.com
      - CORE_PEER_ADDRESS=peer0.org2.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_certh
      - CORE_LOGGING_LEVEL=INFO
      - 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
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    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
      - peer0.org2.example.com:/var/hyperledger/production   
    extra_hosts:
      - 'peer0.org1.example.com:IP_MACHINE1'
      - 'peer1.org1.example.com:IP_MACHINE1'
      - 'ca_peerOrg1:IP_MACHINE1'
      - 'orderer.example.com:IP_MACHINE1'

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 9051:7051
      - 9053:7053
    depends_on:
      - couchdb2
    networks:
      - byfn

  couchdb2:
    container_name: couchdb2
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - '7984:5984'
    networks:
      - byfn

  peer1.org2.example.com:
    container_name: peer1.org2.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_PEER_ID=peer1.org2.example.com
      - CORE_PEER_ADDRESS=peer1.org2.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_certh
      - CORE_LOGGING_LEVEL=INFO
      - 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
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
      - peer1.org2.example.com:/var/hyperledger/production

    extra_hosts:
      - 'peer0.org1.example.com:IP_MACHINE1'
      - 'peer1.org1.example.com:IP_MACHINE1'
      - 'ca_peerOrg1:IP_MACHINE1'
      - 'orderer.example.com:IP_MACHINE1'

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 10051:7051
      - 10053:7053
    depends_on:
      - couchdb3
    networks:
      - byfn

  couchdb3:
    container_name: couchdb3
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - '8984:5984'
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_LOGGING_LEVEL=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org2.example.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer   
    extra_hosts:
      - 'peer0.org1.example.com:IP_MACHINE1'
      - 'peer1.org1.example.com:IP_MACHINE1'
      - 'ca_peerOrg1:IP_MACHINE1'
      - 'orderer.example.com:IP_MACHINE1'   
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/:/opt/gopath/src/github.com/chaincode
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
      - ./ccp:/opt/gopath/src/github.com/hyperledger/fabric/peer/ccp
    depends_on:
      - peer0.org2.example.com
      - peer1.org2.example.com
    networks:
      - byfn
Configtx.yaml:


组织:
-&orderorg
姓名:OrderOrg
ID:ordermsp
MSPDir:../first network/crypto config/orderorganizations/example.com/msp
政策:
读者:
类型:签名
规则:“或('ordermsp.member')”
作者:
类型:签名
规则:“或('ordermsp.member')”
管理员:
类型:签名
规则:“或('ordermsp.admin')”
订购点:
-order.example.com:7050
-&Org1
名称:Org1MSP
ID:Org1MSP
MSPDir:../first network/crypto config/peerOrganizations/org1.example.com/msp
政策:
读者:
类型:签名
规则:“或('Org1MSP.admin','Org1MSP.peer','Org1MSP.client')”
作者:
类型:签名
规则:“或('Org1MSP.admin','Org1MSP.client')”
管理员:
类型:签名
规则:“或('Org1MSP.admin')”
背书:
类型:签名
规则:“或('Org1MSP.peer')”
主持人:
-主持人:peer0.org1.example.com
港口:7051
-&Org2
名称:Org2MSP
ID:Org2MSP
MSPDir:../first network/crypto config/peerOrganizations/org2.example.com/msp
政策:
读者:
类型:签名
规则:“或('Org2MSP.admin','Org2MSP.peer','Org2MSP.client')”
作者:
类型:签名
规则:“或('Org2MSP.admin','Org2MSP.client')”
管理员:
类型:签名
规则:“或('Org2MSP.admin')”
背书:
类型:签名
规则:“或('Org2MSP.peer')”
主持人:
-主持人:peer0.org2.example.com
港口:7051
能力:
通道:&通道功能
V2_0:正确
订购者:&订购者能力
V2_0:正确
应用程序:&应用程序容量
V2_0:正确
应用程序:&ApplicationDefaults
组织:
政策:
读者:
类型:ImplicitMeta
规则:“任何读者”
作者:
类型:ImplicitMeta
规则:“任何作家”
管理员:
类型:ImplicitMeta
规则:“多数管理员”
生命周期声明:
类型:ImplicitMeta
规则:“多数赞成”
背书:
类型:ImplicitMeta
规则:“多数赞成”
能力:

问题出现在通道配置文件(configtx.yaml)中。您已为两个组织上的锚节点定义了相同的端口

Org2(目前):

(Org2)将其更改为:

 AnchorPeers:
            - Host: peer0.org2.example.com
              Port: 9051

@HectorCode,我对
node1.yml
文件做了一些更改,因为我假设您在同一个VM主机上运行两个Org1对等机,您不能同时对
peer0
peer1
使用端口
7051
。同样,根据这些更改对
node2.yml
进行更改

version: '2'

volumes:
  orderer.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:

networks:
  byfn:

services:

  ca0:
    image: hyperledger/fabric-ca:$IMAGE_TAG
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org1
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/priv_sk
      - FABRIC_CA_SERVER_PORT=7054
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/priv_sk -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2:IP_MACHINE2'
    container_name: ca_peerOrg1
    networks:
      - byfn

  orderer.example.com:
    container_name: orderer.example.com
    extends:
      file: base/peer-base.yaml
      service: orderer-base
    volumes:
        - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
        - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
        - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
        - orderer.example.com:/var/hyperledger/production/orderer
    extra_hosts:
      - 'peer0.org1.example.com:IP_MACHINE1'
      - 'peer1.org1.example.com:IP_MACHINE1'
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2:IP_MACHINE2'
    ports:
      - 7050:7050
    networks:
      - byfn

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_PEER_ID=peer0.org1.example.com
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:8051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_certh
      - CORE_LOGGING_LEVEL=INFO
      - 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
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
      - peer0.org1.example.com:/var/hyperledger/production
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2:IP_MACHINE2'
      - 'peer1.org1.example.com:IP_MACHINE1'
    command: peer node start
    ports:
      - 7051:7051
      - 7053:7053
    depends_on:
      - couchdb0
    networks:
      - byfn

  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - '5984:5984'
    networks:
      - byfn

  peer1.org1.example.com:
    container_name: peer1.org1.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_PEER_ID=peer1.org1.example.com
      - CORE_PEER_ADDRESS=peer1.org1.example.com:8051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:8051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_certh
      - CORE_LOGGING_LEVEL=INFO
      - 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
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
      - peer1.org1.example.com:/var/hyperledger/production
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'ca_peerOrg2: IP_MACHINE2'
      - 'peero.org1.example.com:INSTANCE_IP1'
    command: peer node start
    ports:
      - 8051:7051
      - 8053:7053
    depends_on:
      - couchdb1
    networks:
      - byfn

  couchdb1:
    container_name: couchdb1
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - '6984:5984'
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_LOGGING_LEVEL=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer    
    extra_hosts:
      - 'peer0.org2.example.com:IP_MACHINE2'
      - 'peer1.org2.example.com:IP_MACHINE2'
      - 'peer0.org1.example.com:IP1'
      - 'peer1.org1.example.com:IP1'
      - 'orderer.example.com:IP1'
      - 'ca1.example.com:IP_MACHINE2'    
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/:/opt/gopath/src/github.com/chaincode
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
      - ./ccp:/opt/gopath/src/github.com/hyperledger/fabric/peer/ccp
    depends_on:
      - orderer.example.com
      - peer0.org1.example.com
      - peer1.org1.example.com
    networks:
      - byfn

我假设我应该将node2.yaml peer0.org2.example.com和peer1.org2.example.com上的端口都更改为8051吗?不是两个。每个对等都有不同的端口。对于Org2,如果peer0是8051,那么peer1将是9051。Org1也是如此,例如,如果peer0位于6051,那么peer1将位于7051。@ShubhamJaiswal如果对等机运行在不同的VM上,那么不强制每个对等机使用不同的端口。只要对等机位于不同的机器上,您就可以对每个对等机使用
7051
。@HectorCode。您的命令中缺少订购者标志(-o)。但您提供了tls证书路径。下面是该命令的一个示例:
peer lifecycle chaincode approverformyorg-o order.example.com:7050--tls--cafile$order_CA--channelID mychannel--name mycc--version 1.0--init required--package id myccv1:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9--sequence 1--signature policy”和('Org1MSP.peer'、'Org2MSP.peer')”
好的,这意味着您没有在网络中使用任何特定的认可策略。您可以删除命令中的签名策略标志,然后重试,您是否更改了configtx.yaml中的锚节点端口?