Hyper Ledger Fabric-无法添加第二个Peer或Org

时间:2018-07-17 07:12:28

标签: hyperledger-fabric hyperledger

我正在尝试建立一个具有1个订购者和2个组织(每个组织1个对等体)的超级账本网络,创建一个通道并将对等体加入该通道,安装并实例化Chaincode。我成功建立了带有1个组织(1个对等方)和一个订购者的网络,并且能够查询链码。但是,当我尝试将第二个对等方添加到频道时,出现以下错误。

Error: proposal failed (err: rpc error: code = Unimplemented desc = unknown service protos.Endorser)

我尝试了多种选择,在另一个交易(例如,链码安装)之前创建了通道,我能够在Peer2中创建通道,但是无法在通道中加入Peer2,而Peer1能够加入通道由Peer 2创建。

所有加密证书都是在为第一个对等体本身生成时生成的。我正在使用Kafka(不是Solo)。我正在使用CLI创建和加入频道,并且在将CLI用于peer2时更改了环境变量。请在下面找到我使用的配置和命令。

  

注意:我正在使用基本网络(而不是第一个网络和byfn.sh文件)并手动运行所有命令。

crypto-config.yaml

OrdererOrgs:
  - Name: Orderer
    Domain: testing.com
    Specs:
      - Hostname: orderer
PeerOrgs:
  - Name: peer1
    Domain: peer1.testing.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

  - Name: peer2
    Domain: peer2.testing.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

configtx.yaml

Organizations:
    - &Orderer
        Name: Orderer
        ID: OrdererMSP
        MSPDir: crypto-config/ordererOrganizations/testing.com/orderers/orderer.testing.com/msp
    - &Peer1
        Name: Peer1MSP
        ID: Peer1MSP
        MSPDir: crypto-config/peerOrganizations/peer1.testing.com/msp
        AnchorPeers:
            - Host: peer1.testing.com
              Port: 7051
    - &Peer2
        Name: Peer2MSP
        ID: Peer2MSP
        MSPDir: crypto-config/peerOrganizations/peer2.testing.com/msp
        AnchorPeers:
            - Host: peer2.testing.com
              Port: 7052
Application: &ApplicationDefaults
  Organizations:
Orderer: &OrdererDefaults
    OrdererType: kafka
    Addresses:
        - orderer.testing.com:7050
    BatchTimeout: 2s
    BatchSize:
        MaxMessageCount: 10
        AbsoluteMaxBytes: 99 MB
        PreferredMaxBytes: 512 KB
    Kafka:
       Brokers:
            - ordererkafka:9092
            - ordererkafka1:9093
            - ordererkafka2:9094
            - ordererkafka3:9095
    Organizations:
Profiles:
    AllOrgs:
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *Orderer
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Peer1
                    - *Peer2    
    AllOrgChannel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                    - *Peer1
                    - *Peer2

docker-compose.yml

version: '2'

networks:
  basic:

services:
  ca.peer1.testing.com:
    image: hyperledger/fabric-ca:1.2.0
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.peer1.testing.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/4427442b7ed4795edbeb45739f5c2ca2bb9ce73b373e81eb63254dc0400871dc_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=false
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw'
    volumes:
      - ./crypto-config/peerOrganizations/peer1.testing.com/ca/:/etc/hyperledger/fabric-ca-server-config
      - ./crypto-config/peerOrganizations/peer1.testing.com/msp/:/etc/hyperledger/fabric-ca-server-config/msp
    container_name: ca_peer1
    networks:
      - basic


  ca.peer2.testing.com:
    image: hyperledger/fabric-ca:1.2.0
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.peer2.testing.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/22fee4a6a803dfcc32858543dc4192ff377bfc6fe24d6a454207f5bc83da1433_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=false
    ports:
      - "7055:7055"
    command: sh -c 'fabric-ca-server start -b admin:adminpw'
    volumes:
      - ./crypto-config/peerOrganizations/peer2.testing.com/ca/:/etc/hyperledger/fabric-ca-server-config
      - ./crypto-config/peerOrganizations/peer2.testing.com/msp/:/etc/hyperledger/fabric-ca-server-config/msp
    container_name: ca_peer2
    networks:
      - basic


  orderer.testing.com:
    container_name: orderer.testing.com
    image: hyperledger/fabric-orderer:1.2.0
    environment:
      - CONFIGTX_ORDERER_ORDERERTYPE=kafka
      - CONFIGTX_ORDERER_KAFKA_BROKERS=[ordererkafka:9092,ordererkafka1:9093,ordererkafka2:9094,ordererkafka3:9095]
      - ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s
      - ORDERER_KAFKA_RETRY_SHORTTOTAL=30s
      - ORDERER_KAFKA_VERBOSE=true
      - ORDERER_GENERAL_LOGLEVEL=debug
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      - ORDERER_GENERAL_TLS_ENABLED=false
      - 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]

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
    command: orderer
    ports:
      - 7080:7050
    volumes:
        - ./channel-artifacts/:/etc/hyperledger/configtx
        - ./channel-artifacts/genesis.block:/var/hyperledger/orderer/genesis.block
        - ./crypto-config/ordererOrganizations/testing.com/orderers/orderer.testing.com/msp:/var/hyperledger/orderer/msp
        - ./crypto-config/ordererOrganizations/testing.com/orderers/orderer.testing.com/tls/:/var/hyperledger/orderer/tls
        - ./crypto-config/ordererOrganizations/testing.com/orderers/orderer.testing.com/:/etc/hyperledger/msp/orderer
        - ./crypto-config/peerOrganizations/peer1.testing.com/peers/peer0.peer1.testing.com/:/etc/hyperledger/msp/peer1
        - ./crypto-config/peerOrganizations/peer2.testing.com/peers/peer0.peer2.testing.com/:/etc/hyperledger/msp/peer2
    networks:
      - basic

  peer0.peer1.testing.com:
    container_name: peer0.peer1.testing.com
    image: hyperledger/fabric-peer:1.2.0
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer0.peer1.testing.com
      - CORE_LOGGING_PEER=info
      - CORE_CHAINCODE_LOGGING_LEVEL=info
      - CORE_CHAINCODE_DEPLOYTIMEOUT=300s
      - CORE_CHAINCODE_STARTUPTIMEOUT=300s
      - CORE_PEER_LOCALMSPID=Peer1MSP
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
      - CORE_PEER_ADDRESS=peer0.peer1.testing.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.peer1.testing.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.peer1.testing.com:7051
      - CORE_PEER_TLS_ENABLED=false
      # # 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}_basic
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: peer node start
    # command: peer node start --peer-chaincodedev=true
    ports:
      - 7051:7051
      - 7053:7053
    volumes:
        - /var/run/:/host/var/run/
        - ./crypto-config/peerOrganizations/peer1.testing.com/peers/peer0.peer1.testing.com/msp:/etc/hyperledger/msp/peer
        - ./crypto-config/peerOrganizations/peer1.testing.com/users:/etc/hyperledger/msp/users
        - ./channel-artifacts:/etc/hyperledger/configtx
        - ./crypto-config/peerOrganizations/peer1.testing.com/peers/peer0.peer1.testing.com/tls:/etc/hyperledger/tls
        - ./../chaincode/:/opt/gopath/src/github.com/
    depends_on:
      - orderer.testing.com
      - couchdb
    networks:
      - basic


  peer0.peer2.testing.com:
    container_name: peer0.peer2.testing.com
    image: hyperledger/fabric-peer:1.2.0
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer0.peer2.testing.com
      - CORE_LOGGING_PEER=debug
      - CORE_LOGGING_GRPC=debug
      - CORE_CHAINCODE_LOGGING_LEVEL=debug
      - CORE_CHAINCODE_DEPLOYTIMEOUT=300s
      - CORE_CHAINCODE_STARTUPTIMEOUT=300s
      - CORE_PEER_LOCALMSPID=Peer2MSP
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
      - CORE_PEER_ADDRESS=peer0.peer2.testing.com:7052
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.peer2.testing.com:7052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.peer2.testing.com:7052
      - CORE_PEER_TLS_ENABLED=false
      # # 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}_basic
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: peer node start
    # command: peer node start --peer-chaincodedev=true
    ports:
      - 7052:7052
      - 7056:7056
    volumes:
        - /var/run/:/host/var/run/
        - ./crypto-config/peerOrganizations/peer2.testing.com/peers/peer0.peer2.testing.com/msp:/etc/hyperledger/msp/peer
        - ./crypto-config/peerOrganizations/peer2.testing.com/users:/etc/hyperledger/msp/users
        - ./channel-artifacts:/etc/hyperledger/configtx
        - ./crypto-config/peerOrganizations/peer2.testing.com/peers/peer0.peer2.testing.com/tls:/etc/hyperledger/tls
    depends_on:
      - orderer.testing.com
      - couchdb
    networks:
      - basic


  couchdb:
    container_name: couchdb
    image: hyperledger/fabric-couchdb:0.4.8
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - 5984:5984
    networks:
      - basic

  cli:
    container_name: cli
    image: hyperledger/fabric-tools
    tty: 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.peer1.testing.com:7051
      - CORE_PEER_LOCALMSPID=peer1MSP
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/peer1.testing.com/users/Admin@peer1.testing.com/msp
      - CORE_CHAINCODE_KEEPALIVE=10
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/peer1.testing.com/peers/peer0.peer1.testing.com/tls/ca.crt
      - CHANNEL_NAME=mychannel
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./channel-artifacts/channel.tx:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts/channel.tx
        - ./channel-artifacts/:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts/
    networks:
      - basic

    #depends_on:
    #  - orderer.testing.com
    #  - peer0.peer1.testing.com
    #  - couchdb

  zookeeper0:
    image: hyperledger/fabric-zookeeper:0.4.8
    restart: always
    container_name: zookeeper0
    ports:
      - '2181:2181'
      - '2888:2888'
      - '3888:3888'
    environment:
      - ZOO_MY_ID=1
      - ZOO_SERVERS=server.1=zookeeper0:2888:3888 server.2=zookeeper1:2887:3887 server.3=zookeeper2:2886:3886
    #volumes:
      #-
    networks:
      - basic

  zookeeper1:
    image: hyperledger/fabric-zookeeper:0.4.8
    restart: always
    container_name: zookeeper1
    ports:
      - '12181:2182'
      - '12888:2887'
      - '13888:3887'
    environment:
      - ZOO_MY_ID=2
      - ZOO_SERVERS=server.1=zookeeper0:2888:3888 server.2=zookeeper1:2887:3887 server.3=zookeeper2:2886:3886
    #volumes:
      #- 
    networks:
      - basic

  zookeeper2:
    image: hyperledger/fabric-zookeeper:0.4.8
    restart: always
    container_name: zookeeper2
    ports:
      - '22181:2183'
      - '22888:2886'
      - '23888:3886'
    environment:
      - ZOO_MY_ID=3
      - ZOO_SERVERS=server.1=zookeeper0:2888:3888 server.2=zookeeper1:2887:3887 server.3=zookeeper2:2886:3886
    #volumes:
      #- 
    networks:
      - basic


  ordererkafka:
    image: hyperledger/fabric-kafka:0.4.8
    restart: always
    container_name: kafka
    ports:
      - '9092:9092'
    environment:
      - KAFKA_MESSAGE_MAX_BYTES=103809024
      - KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 
      - KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=true
      - KAFKA_BROKER_ID=0
      - KAFKA_MIN_INSYNC_REPLICAS=1
      - KAFKA_DEFAULT_REPLICATION_FACTOR=2
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2182,zookeeper2:2183
    #volumes:
      #- 
    depends_on:
      - zookeeper0
      - zookeeper1
      - zookeeper2
    networks:
      - basic


  ordererkafka1:
    image: hyperledger/fabric-kafka:0.4.8
    restart: always
    container_name: kafka1
    ports:
      - '9093:9093'
    environment:
      - KAFKA_MESSAGE_MAX_BYTES=103809024
      - KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 
      - KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=true
      - KAFKA_BROKER_ID=1
      - KAFKA_MIN_INSYNC_REPLICAS=1
      - KAFKA_DEFAULT_REPLICATION_FACTOR=2
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2182,zookeeper2:2183
    #volumes:
      #- 
    depends_on:
      - zookeeper0
      - zookeeper1
      - zookeeper2
    networks:
      - basic

  ordererkafka2:
    image: hyperledger/fabric-kafka:0.4.8
    restart: always
    container_name: kafka2
    ports:
      - '9094:9094'
    environment:
      - KAFKA_MESSAGE_MAX_BYTES=103809024
      - KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 
      - KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=true
      - KAFKA_BROKER_ID=2
      - KAFKA_MIN_INSYNC_REPLICAS=1
      - KAFKA_DEFAULT_REPLICATION_FACTOR=2
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2182,zookeeper2:2183
    #volumes:
      #- 
    depends_on:
      - zookeeper0
      - zookeeper1
      - zookeeper2
    networks:
      - basic

  ordererkafka3:
    image: hyperledger/fabric-kafka:0.4.8
    restart: always
    container_name: kafka3
    ports:
      - '9095:9095'
    environment:
      - KAFKA_MESSAGE_MAX_BYTES=103809024
      - KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 
      - KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=true
      - KAFKA_BROKER_ID=3
      - KAFKA_MIN_INSYNC_REPLICAS=1
      - KAFKA_DEFAULT_REPLICATION_FACTOR=2
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2182,zookeeper2:2183
    #volumes:
      #- 
    depends_on:
      - zookeeper0
      - zookeeper1
      - zookeeper2
    networks:
      - basic

命令运行

../bin/configtxgen -profile AllOrgs -outputBlock ./channel-artifacts/genesis.block
export CHANNEL_NAME=mychannel  && ../bin/configtxgen -profile AllOrgChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
../bin/configtxgen -profile AllOrgChannel -outputAnchorPeersUpdate ./channel-artifacts/Peer1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Peer1MSP
../bin/configtxgen -profile AllOrgChannel -outputAnchorPeersUpdate ./channel-artifacts/Peer2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Peer2MSP

// Create Channel
docker exec -e "CORE_PEER_LOCALMSPID=Peer1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/peer1.testing.com/users/Admin@peer1.testing.com/msp" cli peer channel create -o orderer.testing.com:7050 -c mychannel -f channel-artifacts/channel.tx
docker exec -e "CORE_PEER_LOCALMSPID=Peer2MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/peer2.testing.com/users/Admin@peer2.testing.com/msp" -e "CORE_PEER_ADDRESS=peer0.peer2.testing.com:7052" cli peer channel create -o orderer.testing.com:7050 -c mychannel -f channel-artifacts/channel.tx

// Join Channel
docker exec -e "CORE_PEER_LOCALMSPID=Peer1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/peer1.testing.com/users/Admin@peer1.testing.com/msp" cli peer channel join -b mychannel.block
docker exec -e "CORE_PEER_LOCALMSPID=Peer2MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/peer2.testing.com/users/Admin@peer2.testing.com/msp" -e "CORE_PEER_ADDRESS=peer0.peer2.testing.com:7052" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/peer2.testing.com/peers/peer0.peer2.testing.com/tls/ca.crt" cli peer channel join -b mychannel.block

预先感谢

Gowtham R

0 个答案:

没有答案