In the process below we will walk you through the steps of adding a new orderer.
We will assume that you have already followed the tutorial of deploying two orgs on two machines.
We will be adding an orderer orderer7.bnc.com running on port 10052
In the config-deploy-org1.yaml we will be adding our new orderer to the list of orderers.
Also in the config-hosts.yaml, we will add orderer7.bnc.com in the corresponding host section.
Do the following to update the config files in your config folder on machine1 of org1:
curl -L https://raw.githubusercontent.com/bxforce/bnc-hlf/master/tests/multi_machine/add-orderer/config-deploy-org1.yaml > $PWD/config/config-deploy-org1.yaml
curl -L https://raw.githubusercontent.com/bxforce/bnc-hlf/master/tests/multi_machine/add-orderer/config-hosts.yaml > $PWD/config/config-hosts.yaml
curl -L https://raw.githubusercontent.com/bxforce/bnc-hlf/master/tests/multi_machine/add-orderer/config-deploy-orderer.yaml > $PWD/config/config-deploy-orderer.yaml
In machine1 of org1 do:
bnc enroll-orderers --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml
Here we will create a new channel definition that needs to be signed by both organizations and then submitted to the network.
In machine1 of org1 do:
bnc channel add-orderer --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -o orderer7.bnc.com -p 10052 --addTLS --systemChannel
In machine1 of org1 do:
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/config_update_as_envelope_pb.pb --addOrderer --systemChannel
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp -r /tmp/hyperledger-fabric-network/artifacts/system-channel $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts
In machine2 of org2 do:
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org2.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/config_update_as_envelope_pb.pb --addOrderer --systemChannel
We need to copy the signature of org2 to org1 because org1 will be the one submitting the channel update to the network.
On machine 1 of org1 do :
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/signatures/org2_sign.json /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/signatures
Org1 will be using the signatures of both orgs along with the channel update file config_update_as_envelope_pb.pb to send the submit transaction to the channel.
On machine 1 of org1 do:
bnc channel submit-definition --config-folder $PWD/config -c /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/config_update_as_envelope_pb.pb -s /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/signatures/ -f config-deploy-org1.yaml -h config-hosts.yaml --addOrderer --systemChannel
Now we will be starting the new orderer container, to do so we will be using the new file config-deploy-orderer.yaml
Under the hood we will be retrieving the latest system channel definition and bootstrapping our new orderer with it.
On machine1 of org1 do:
bnc start --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -o config-deploy-orderer.yaml --addOrderer
Now org1 will creating a new channel definition to be signed by both organizations by orgs and then submitted to the network following same logic with TLS.
On machine1 of org1:
bnc channel --config-folder $PWD/config add-orderer -f config-deploy-org1.yaml -h config-hosts.yaml -o orderer7.bnc.com -p 10052 --addEndpoint --systemChannel
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/config_update_as_envelope_pb.pb --addOrderer --systemChannel
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp -r /tmp/hyperledger-fabric-network/artifacts/system-channel $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts
On machine2 of org2 do :
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org2.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/config_update_as_envelope_pb.pb --addOrderer --systemChannel
On machine1 of org1:
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/signatures/org2_sign.json /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/signatures
On machine1 of org1:
bnc channel submit-definition --config-folder $PWD/config -c /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/config_update_as_envelope_pb.pb -s /tmp/hyperledger-fabric-network/artifacts/system-channel/addOrderer/signatures/ -f config-deploy-org1.yaml -h config-hosts.yaml --addOrderer --systemChannel
On machine1 of org1:
bnc channel add-orderer --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -o orderer7.bnc.com -p 10052 -n mychannel --addTLS
On machine1 of org1:
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/config_update_as_envelope_pb.pb -n mychannel --addOrderer
On machine1 of org1:
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp -r /tmp/hyperledger-fabric-network/artifacts/mychannel $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts
On machine2 of org2:
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org2.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/config_update_as_envelope_pb.pb -n mychannel --addOrderer
On machine1 of org1:
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/signatures/org2_sign.json /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/signatures
On machine1 of org1 do:
bnc channel submit-definition --config-folder $PWD/config -c /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/config_update_as_envelope_pb.pb -s /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/signatures/ -f config-deploy-org1.yaml -h config-hosts.yaml -n mychannel --addOrderer
On machine1 of org1 do:
bnc channel add-orderer --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -o orderer7.bnc.com -p 10052 -n mychannel --addEndpoint
On machine1 of org1 do:
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org1.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/config_update_as_envelope_pb.pb -n mychannel --addOrderer
On machine1 of org1:
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp -r /tmp/hyperledger-fabric-network/artifacts/mychannel $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts
On machine2 of org2:
bnc channel sign-definition --config-folder $PWD/config -f config-deploy-org2.yaml -h config-hosts.yaml -c /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/config_update_as_envelope_pb.pb -n mychannel --addOrderer
On machine1 of org1 do:
sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network; ssh $SSH_VM2 'sudo chown -R $USER:$USER /tmp/hyperledger-fabric-network'
scp $SSH_VM2:/tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/signatures/org2_sign.json /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/signatures
On machine1 of org1 do:
bnc channel submit-definition --config-folder $PWD/config -c /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/config_update_as_envelope_pb.pb -s /tmp/hyperledger-fabric-network/artifacts/mychannel/addOrderer/signatures/ -f config-deploy-org1.yaml -h config-hosts.yaml -n mychannel --addOrderer
Org1 will do the init transaction
bnc chaincode invoke --config-folder /home/ubuntu/config -f config-deploy-org1.yaml -h config-hosts.yaml -c config-chaincode.yaml -i "Init,a,100,b,100"
Query a value:
bnc chaincode invoke --config-folder /home/ubuntu/config -f config-deploy-org1.yaml -h config-hosts.yaml -c config-chaincode.yaml -i "query,a"
substract 10 from a:
bnc chaincode invoke --config-folder /home/ubuntu/config -f config-deploy-org1.yaml -h config-hosts.yaml -c config-chaincode.yaml -i "invoke,a,b,10"
On machine2 of org2 you can invoke:
bnc chaincode invoke --config-folder /home/ubuntu/config -f config-deploy-org2.yaml -h config-hosts.yaml -c config-chaincode.yaml -i "invoke,a,b,10"