Create and join a peer to a channel
In this example, we will assume the new channel will be named MyChannel
Generate a channel genesis block
Gather public keys into an MSP for genesis block creation and create configtx.yaml
This adds the PeerAdmin to the new channel as an ADMIN by putting its public key into msp/admincerts
In these examples, we assume the PeerOrg admin has been enrolled and its MSP is in PeerAdmin/mspcp config.env-example config.env
Use a text editor to make changes to the new config.env file. You will need to add your <NetworkID> to the config, as well as all the peer(s) <NodeID> separated by spaces, you can get this information from your Fabric Network Connect Tab
Create configtx.yaml
make configtx.yaml
Gather public keys into an MSP for genesis block creation
This adds the PeerAdmin to the new channel as an ADMIN
by putting its public key into msp/admincerts
mkdir -p mychannel/msp/cacerts/ mychannel/msp/admincerts/
cp -f PeerAdmin/msp/cacerts/*.pem mychannel/msp/cacerts/
cp -f PeerAdmin/msp/signcerts/cert.pem mychannel/msp/admincerts/
Generate genesis block and anchor peer update
mkdir -p artifacts/
configtxgen -configPath $PWD -profile SingleMSPChannel -outputCreateChannelTx artifacts/mychannel.txn -channelID mychannel
configtxgen -configPath $PWD -profile SingleMSPChannel -outputAnchorPeersUpdate artifacts/mychannel-anchor-peers.txn -channelID mychannel -asOrg PeerOrg
Make the PeerAdmin an admin of the local peer instances we will be running
mkdir -p PeerAdmin/msp/admincerts
cp -f PeerAdmin/msp/signcerts/* PeerAdmin/msp/admincerts
Create/update/join channel
Note that fetch/join has to be done for every <NodeID>
peer you wish to join to a channel, as specified in the config.env
ANCHOR_PEERS
setting for the configtx.yaml
created above.
source config.env
export FABRIC_CFG_PATH=$PWD
export CORE_PEER_MSPCONFIGPATH="PeerAdmin/msp"
export CORE_PEER_LOCALMSPID="${NETWORK_ID}-peerOrg"
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}/tlsca-${NETWORK_ID}.pem"
export CORE_PEER_ADDRESS="peer-${ANCHOR_PEERS[0]}.${NETWORK_ID}.bdnodes.net:7051"
peer channel create -c mychannel -f ./artifacts/mychannel.txn --tls -o orderer.${NETWORK_ID}.bdnodes.net:7050 --cafile=${CORE_PEER_TLS_ROOTCERT_FILE}
peer channel update -c mychannel -f ./artifacts/mychannel-anchor-peers.txn --tls -o orderer.${NETWORK_ID}.bdnodes.net:7050 --cafile=${CORE_PEER_TLS_ROOTCERT_FILE}
for NODE_ID in "${ANCHOR_PEERS[@]}"; do
export CORE_PEER_ADDRESS="peer-${NODE_ID}.${NETWORK_ID}${ENV}.bdnodes.net:7051"
echo "Joining peer-${NODE_ID} to $CHANNEL"
peer channel join -b ./mychannel.block
done
Comments
Its future must better all sides
The technology of USA is the best among the words.So
Fabrics quality and productivity are too must high and must demanded.
The technology of USA is the best among the words.So
Fabrics quality and productivity are too must high and must demanded.
I face severe. Problem. So.I need job fire urgent.
I need job fire urgent.
Its future must better all sides
Please sign in to leave a comment.