无法创建频道 - 试图包含不在联盟中的成员

Unable to create channel - Attempted to include a member which is not in the consortium

我在创建频道时遇到问题:

频道 1 联盟 - Org 1、Org2、Org4、Org5 Channel 2 联盟 - Org2、Org3、Org4、Org5 Orderer Genesis 联盟 - Org1、Org2、Org3、Org4、Org5。

来自 Cli peer (Org2) - 当我尝试创建通道 1 或 2 时,出现以下问题:

> peer channel create -o orderer.clm.com:7050 -c $CHANNEL_ONE_NAME -f ./channel-artifacts/channelone.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/clm.com/orderers/orderer.clm.com/msp/tlscacerts/tlsca.clm.com-cert.pem


2018-07-15 01:13:08.240 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser 
and orderer connections initialized
Error: got unexpected status: BAD_REQUEST -- Attempted to include a member 
which is not in the consortium

configtx.yaml 文件

Organizations:
- &OrdererOrg
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: OrdererOrg

    # ID to load the MSP definition as
    ID: OrdererMSP

    # MSPDir is the filesystem path which contains the MSP configuration
    MSPDir: crypto-config/ordererOrganizations/clm.com/msp
    AdminPrincipal: Role.MEMBER

- &Org2
    Name: Bdc1MSP
    ID: Bdc1MSP
    MSPDir: crypto-config/peerOrganizations/bdc1.clm.com/msp
    AdminPrincipal: Role.MEMBER
    AnchorPeers:
        - Host: peer0.bdc1.clm.com
          Port: 7051


- &Org1
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: Cp1MSP

    # ID to load the MSP definition as
    ID: Cp1MSP

    MSPDir: crypto-config/peerOrganizations/cp1.clm.com/msp
    AdminPrincipal: Role.MEMBER
    AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.cp1.clm.com
          Port: 7051

- &Org3
    Name: Adp1MSP
    ID: Adp1MSP
    MSPDir: crypto-config/peerOrganizations/adp1.clm.com/msp
    AdminPrincipal: Role.MEMBER
    AnchorPeers:
        - Host: peer0.adp1.clm.com
          Port: 7051
- &Org4
    Name: Ottp1MSP
    ID: Ottp1MSP
    MSPDir: crypto-config/peerOrganizations/ottp1.clm.com/msp
    AdminPrincipal: Role.MEMBER
    AnchorPeers:
        - Host: peer0.ottp1.clm.com
          Port: 7051
- &Org5
        Name: RegMSP
        ID: RegMSP
        MSPDir: crypto-config/peerOrganizations/reg.clm.com/msp
        AdminPrincipal: Role.MEMBER
        AnchorPeers:
            - Host: peer0.reg.clm.com
              Port: 7051
Capabilities:
    Global: &ChannelCapabilities
        V1_1: true
    Orderer: &OrdererCapabilities
        V1_1: true
    Application: &ApplicationCapabilities
        V1_2: true


Application: &ApplicationDefaults


    Organizations:


Orderer: &OrdererDefaults


OrdererType: solo

Addresses:
    - orderer.clm.com:7050

# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s

# Batch Size: Controls the number of messages batched into a block
BatchSize:

    # Max Message Count: The maximum number of messages to permit in a batch
    MaxMessageCount: 10

    # Absolute Max Bytes: The absolute maximum number of bytes allowed for
    # the serialized messages in a batch.
    AbsoluteMaxBytes: 99 MB

    # Preferred Max Bytes: The preferred maximum number of bytes allowed for
    # the serialized messages in a batch. A message larger than the preferred
    # max bytes will result in a batch larger than preferred max bytes.
    PreferredMaxBytes: 512 KB

Kafka:
    # Brokers: A list of Kafka brokers to which the orderer connects
    # NOTE: Use IP:port notation
    Brokers:
        - 127.0.0.1:9092


Organizations:


Profiles:

    FiveOrgsOrdererGenesis:
        Capabilities:
            <<: *ChannelCapabilities
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org2
                    - *Org1
                    - *Org3
                    - *Org4
                    - *Org5
    ChannelOne:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org2
                - *Org1
                - *Org5
                - *Org4
            Capabilities:
                <<: *ApplicationCapabilities
    ChannelTwo:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org2
                - *Org3
                - *Org5
                - *Org4
            Capabilities:
                <<: *ApplicationCapabilities

docker 编写客户端

cli:
container_name: cli
image: hyperledger/fabric-tools:$IMAGE_TAG
tty: true
stdin_open: true
environment:
  - GOPATH=/opt/gopath
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  #- CORE_LOGGING_LEVEL=DEBUG
  - CORE_LOGGING_LEVEL=INFO
  - CORE_PEER_ID=cli
  - CORE_PEER_ADDRESS=peer0.bdc1.clm.com:7051
  - CORE_PEER_LOCALMSPID=Bdc1MSP
  - CORE_PEER_TLS_ENABLED=true
  - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/bdc1.clm.com/peers/peer0.bdc1.clm.com/tls/server.crt
  - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/bdc1.clm.com/peers/peer0.bdc1.clm.com/tls/server.key
  - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/bdc1.clm.com/peers/peer0.bdc1.clm.com/tls/ca.crt
  - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/bdc1.clm.com/users/Admin@bdc1.clm.com/msp
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/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
depends_on:
  - orderer.clm.com
  - peer0.bdc1.clm.com
networks:
  - byfn

来自 CLI 容器的环境变量:

root@6a67b1de8f57:/opt/gopath/src/github.com/hyperledger/fabric/peer# env
HOSTNAME=6a67b1de8f57
TERM=xterm





CORE_PEER_TLS_ROOTCERT_FILE=
/opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/bdc1.clm.com/peers/
peer0.bdc1.clm.com/tls/ca.crt    
CORE_PEER_TLS_KEY_FILE=
/opt/gopath/src/github.com/hyperledger/fabric/peer/
crypto/peerOrganizations/bdc1.clm.com/peers/
peer0.bdc1.clm.com/tls/server.key
LS_COLORS=REMOVED
CORE_PEER_LOCALMSPID=Bdc1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/
bdc1.clm.com/peers/peer0.bdc1.clm.com/tls/server.crt
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/opt/go/bin:/opt/gopath/bin
PWD=/opt/gopath/src/github.com/hyperledger/fabric/peer
CORE_PEER_TLS_ENABLED=true



CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/
bdc1.clm.com/users/Admin@bdc1.clm.com/msp    
CORE_PEER_ID=cli
SHLVL=1
HOME=/root
GOROOT=/opt/go
CORE_LOGGING_LEVEL=INFO
FABRIC_CFG_PATH=/etc/hyperledger/fabric
CORE_PEER_ADDRESS=peer0.bdc1.clm.com:7051
LESSOPEN=| /usr/bin/lesspipe %s
GOPATH=/opt/gopath
CHANNEL_ONE_NAME=channelone
LESSCLOSE=/usr/bin/lesspipe %s %s

_=/usr/bin/env

这通常发生在将不在联盟中的成员添加到频道时。 请 post 您的 configtx.yaml 了解更多详情。

详情可参考此回答

How can I add two orderers to the same channel?

编辑

检查您在 cli 容器中的环境:

$ env

然后检查这些变量是否正确导出,如果没有,请执行。

export CORE_PEER_LOCALMSPID="Org2MSP"
export 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
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=peer0.org2.example.com:7051

@arnabkaycee 看起来像通过删除卷和孤儿来关闭 docket 容器,已解决。 我重新创建了密码,再次通道工件,解决了它。不确定,如果我以前的任何工作与它有冲突。仍然一无所知但解决了:)

就我而言,我忘记了 export CHANNEL_NAME:

root@e8daa001f461:/opt/gopath/src/github.com/hyperledger/fabric/peer# echo $CHANNEL_NAME

root@e8daa001f461:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2018-12-07 18:07:18.375 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2018-12-07 18:07:18.636 UTC [common/tools/configtxgen/localconfig] Load -> INFO 002 Loaded configuration: /etc/hyperledger/fabric/configtx.yaml
Error: got unexpected status: BAD_REQUEST -- Attempted to include a member which is not in the consortium

导出后:

root@e8daa001f461:/opt/gopath/src/github.com/hyperledger/fabric/peer# export CHANNEL_NAME=mychannel

root@e8daa001f461:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2018-12-07 18:03:29.985 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2018-12-07 18:03:30.028 UTC [cli/common] readBlock -> INFO 002 Received block: 0

我在 Node-SDK 创建新频道时遇到了这个错误。
每当我们更新联盟时,我们都必须为通道生成新的交易文件。

在我的例子中,我忘记生成相应的,因此出现了错误。
我生成了一个新的交易文件 mychannel.tx

它解决了我的问题。

我今天遇到了同样的问题。过了一会儿,我发现了为什么会这样。事实证明,如果 channelXXXXXX.tx 和 anchorXXXX.tx 文件不在同一文件夹中,即使您所做的一切都是正确的,这也会出错,因为它无法 link 到锚点。

在我的例子中,我有多个频道定义了各自的文件夹。我犯了一个错误,将 channelXXXXXX.tx 放在了它的文件夹之外,结果出现了错误。