First network in hyperledger

2019-02-07 10:49发布

问题:

I am trying to work on my first network in Hyperledger Fabric. Using the following documentation http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html

I have completed the setup till http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html#create-join-channel

but when I run the

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

I got error as

Error: Got unexpected status: BAD_REQUEST

Searching for the issue i came across http://hyperledgerdocs.readthedocs.io/en/latest/asset_trouble.html

Hence I've tried to use a new channel name as given(old channel name=mychannel), I've tried below cmds

CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer channel create -c myc1

CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer.example.com:7050 peer channel create -c myc1

CORE_PEER_COMMITTER_LEDGER_ORDERER=172.18.0.2:7050 peer channel create -c myc1

For all the three I am getting error

Error: Ordering service endpoint is not valid or missing Usage: peer channel create [flags]

Also I've tried to skip it assuming the channel is already created. hence ran

peer channel join -b ./mychannel.block

But got

Error: proposal failed (err: rpc error: code = Unknown desc = chaincode error (status: 500, message: Cannot create ledger from genesis block, due to LedgerID already exists))

My OS is Ubuntu 16.04

docker ps Kindly help

回答1:

Let's try to make sure you run thru all the steps as outlined in docs.

  1. First of all you need to edit your docker-compose-cli.yaml file the cli section to comment out line responsible to run automatic flow of channel creation and join:

    command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT'
    

E.g.

# command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT'
  1. Next export channel name you are working with:

    export CHANNEL_NAME=mychannel

  2. Start the network (use default timeout of 60s):

    CHANNEL_NAME=$CHANNEL_NAME docker-compose -f docker-compose-cli.yaml up -d

  3. Enter the cli container:

    docker exec -it cli bash

  4. Export environmental variables:

    export CHANNEL_NAME=mychannel

  5. Create the channel:

    peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
    
  6. Join the channel:

    peer channel join -b mychannel.block