Saya22K
Saya22K

Reputation: 31

Error while trying to join peer to channel in fabric

I am trying to build a fabric network with two channels. One peer is able to join the channel but while trying to join the second peer to channel getting following error:

Error: genesis block file not found open mychannel.block: no such file or directory

this is my code used for channel creation and joining peers:

Creating channel:

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx

Joining peers:

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.example.com peer channel join -b mychannel.block

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b mychannel.block

Please correct if something is wrong.

Upvotes: 3

Views: 4564

Answers (5)

Rohit Kumar
Rohit Kumar

Reputation: 446

This issue is due to mychannel.block was not found in peer0.org1.example.com You can copy mychannel.block from peer0.org2.example.com to peer0.org1.example.com

try these commands

docker cp peer0.org2.example.com:/opt/gopath/src/github.com/hyperledger/fabric/mychannel.block mychannel.block


docker cp mychannel.block peer0.org1.example.com:/opt/gopath/src/github.com/hyperledger/fabric/

sudo rm mychannel.block

Now try rejoining peer0.org1.example.com to mychannel.

Upvotes: 0

annaira
annaira

Reputation: 11

I had the same problem, but the scenario was slightly different: I had two peers (peer0 and peer1) in one org (org1). I used the following commands to join them to the same channel, and it works:

//Join peer0.org1.example.com to the channel

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e 
"CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" 
peer0.org1.example.com peer channel join -b mychannel.block

//Join peer1.org1.example.com to the channel.

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e 
"CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" -e "CORE_PEER_ADDRESS=peer1.org1.example.com:7051" peer0.org1.example.com peer 
channel join -b mychannel.block

Upvotes: 1

zaf187
zaf187

Reputation: 533

you need to check your docker-compose.yaml file to see how you're mapping volumes in there

in the definitions of the two peers, ensure there is a common mapped volume, for example in peer0 you may have something like this;

    volumes:
    - /var/run/:/host/var/run/
    - ./:/etc/hyperledger/configtx
    - ./crypto-config/peers/peer0/msp:/etc/hyperledger/peer/msp
    - ./crypto-config/users/user0/msp:/etc/hyperledger/msp/users

and in your peer1 you may have;

    volumes:
    - /var/run/:/host/var/run/
    - ./:/etc/hyperledger/configtx
    - ./crypto-config/peers/peer1/msp:/etc/hyperledger/peer/msp
    - ./crypto-config/users/user1/msp:/etc/hyperledger/msp/users

You can see here there are two shared volume mappings, the first two in each definition point to the sample place.

So to be clear, the volume mapping is defined as follows:

[path on local machine]:[path to map in docker image]

Upvotes: 0

MPucci
MPucci

Reputation: 31

i run in the same situation and find a solution. Since the mychannel.block is known only to peer0.org2.example.com container, all the joins have to be done from there. For the second peer you can issue:

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" -e "peer0.org1.example.com:7051" peer0.org2.example.com peer channel join -b mychannel.block

M

Upvotes: 3

Gari Singh
Gari Singh

Reputation: 12013

The issue is that mychannel.block is only available within the peer0.org2.example.com container (since that is the container where you ran the channel create command). The peer0.org1.example.com container does not have access to mychannel.block and that's why you get the error.

What you will need to do is to actually have to do is mount a shared volume for both containers and make sure that you when you run channel create that mychannel.block is output in the shared volume

Upvotes: 2

Related Questions