Raft requires 2n+1 order nodes. This article deploys 5 order nodes,
5 virtual machines
raftone, 192.168.84.144, order (7050) node, two peer nodes (peer0 (7051) peer1 (8051)), cli node
rafttwo , 192.168.84.139, order (7050) node, two peer nodes (peer0 (9051) peer1 (10051)), cli node
raftthree, 192.168.84.140, order (7050) node, two peer nodes (peer0 (11051) peer1 (12051 (7051)), cli node
raftfour, 192.168.84.141, order (7050) node, two peer nodes (peer0 (13051) peer1 (14051)), cli node
raftfive, 192.168.84.142, order (7050) node
Four organizations raftone (fy), rafttwo (ga), raftthree (jc), raftfour (sf)
Regarding the ledger data, the realization of fy to view ledger data and write ledger data requires ga, jc, and sf to agree
Configuration:
fabric1.4.7
Enable couchdb database,
enable ca mirroring
, add extra_hosts under both order and peer ports in base/docker-compose-base.yaml
extra_hosts:
- fy.jdml.pro:192.168.84.144
- ga.jdml.pro:192.168.84.139
- jc.jdml.pro:192.168.84.140
- sf.jdml.pro:192.168.84.141
- orderer.jdml.pro:192.168.84.142
- peer0.fy.jdml.pro:192.168.84.144
- peer1.fy.jdml.pro:192.168.84.144
- peer0.ga.jdml.pro:192.168.84.139
- peer1.ga.jdml.pro:192.168.84.139
- peer0.jc.jdml.pro:192.168.84.140
- peer1.jc.jdml.pro:192.168.84.140
- peer0.sf.jdml.pro:192.168.84.141
- peer1.sf.jdml.pro:192.168.84.141
1. Modify the encrypted file (crypto-config.yaml) to generate 5 organizations. There are two nodes under the organizations 1-4, and each organization has 5 users except Admin.
2. Modify the configuration file (the genesis block, Channel configuration, organization of anchor nodes)
3. Enter the 192.168.84.144 (raftone) virtual machine,
enter the first-network directory, and
generate an encryption certificate
../bin/cryptogen generate --config=./crypto-config.yaml
4. Generate genesis block
../bin/configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
5. Generate channel configuration file
../bin/configtxgen -profile FourOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID jdml
6. Generate Anchor Node Configuration File
Organization 1
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID jdml -asOrg Org1MSP
Organization 2
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID jdml -asOrg Org2MSP
Organization 3
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID jdml -asOrg Org3MSP
Organization 4
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org4MSPanchors.tx -channelID jdml -asOrg Org4MSP
7. Enter the cli terminal to create a channel
peer channel create -o fy.jdml.pro:7050 -c jdml -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/jdml.pro/orderers/ fy.jdml.pro /msp/tlscacerts/tlsca.jdml.pro-cert.pem
Copy the generated channel block to the channel-artifacts folder
cp jdml.block ./channel-artifacts
8. First authorize (chmod 777 -R xxx) and then package the encrypted file (crypto-config) configuration file (channel-artifacts)
tar -cvf xxx.tar.gz xxx
9. Copy the compressed file to rafttwo, raftthree, raftfour, and raftfive to
decompress it to the first-network path. 5 virtual machines use the same encrypted file and network configuration file to configure the multi-machine service
10. Raftone virtual machine modify first-network/ scripts/utils.sh to facilitate node switching
11. Enter the raftone cli node to execute peer instructions
docker exec -it cli bash
12. Create a channel
peer channel create -o fy.jdml.pro:7050 -c jdml -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/jdml.pro/orderers/fy.jdml.pro/msp/tlscacerts/tlsca.jdml.pro-cert.pem
View peer environment
env | grep CORE
peer0 joins the channel
peer channel join -b channel-artifacts/jdml.block
Switch node
source scripts/utils.sh
setGlobals 1 1
env | grep CORE
peer1 joins the channel
peer channel join -b channel-artifacts/jdml.block
13. The rafttwo, raftthree, and raftfour virtual machines perform the above join channel operation.
Modify the utils.sh file, peer0 joins the channel, switch nodes, peer1 joins the channel
14, 4 organizations and 8 nodes all join the channel, execute the update anchor node operation
raftone
peer channel update -o fy.jdml.pro:7050 -c jdml -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/jdml.pro/orderers/fy.jdml.pro/msp/tlscacerts/tlsca.jdml.pro-cert.pem
rafttwo
peer channel update -o ga.jdml.pro:7050 -c jdml -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/jdml.pro/orderers/ga.jdml.pro/msp/tlscacerts/tlsca.jdml.pro-cert.pem
raftthree
peer channel update -o jc.jdml.pro:7050 -c jdml -f ./channel-artifacts/Org3MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/jdml.pro/orderers/jc.jdml.pro/msp/tlscacerts/tlsca.jdml.pro-cert.pem
raftfour
peer channel update -o sf.jdml.pro:7050 -c jdml -f ./channel-artifacts/Org4MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/jdml.pro/orderers/sf.jdml.pro/msp/tlscacerts/tlsca.jdml.pro-cert.pem
15. View the latest block starting from 0
View on raftone
peer channel fetch newest -c jdml -o fy.jdml.pro
View on rafttwo
peer channel fetch newest -c jdml -o ga.jdml.pro
View on raftthree
peer channel fetch newest -c jdml -o jc.jdml.pro
View on raftfour
peer channel fetch newest -c jdml -o sf.jdml.pro
Genesis block 0
update the anchor node of organization 1 1
update the anchor node of organization 2 2
update the anchor node of organization 3 3
update the anchor node of organization 4