raft搭建需要2n+1的order節點,本文部署5個order節點
5臺虛擬機
raftone、192.168.84.144、order(7050)節點、兩個peer節點(peer0(7051)peer1(8051))、cli節點
rafttwo、192.168.84.139、order(7050)節點、兩個peer節點(peer0(9051)peer1(10051))、cli節點
raftthree、192.168.84.140、order(7050)節點、兩個peer節點(peer0(11051)peer1(12051(7051))、cli節點
raftfour、192.168.84.141、order(7050)節點、兩個peer節點(peer0(13051)peer1(14051))、cli節點
raftfive、192.168.84.142、order(7050)節點
四個組織 raftone(fy)、rafttwo(ga)、raftthree(jc)、raftfour(sf)
關于賬本資料實作 fy查看賬本資料 、寫入賬本資料需要ga、jc、sf都同意
配置:
fabric1.4.7
啟用couchdb資料庫
啟用ca鏡像
在base/docker-compose-base.yaml中 order和peer的埠下都加入extra_hosts
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、修改加密檔案(crypto-config.yaml),生成5個組織,組織1-4下各有兩個節點,每個組織除Admin外有5個用戶
2、修改組態檔(創世區塊、通道配置、組織錨節點)
3、進入192.168.84.144(raftone)虛擬機
進入first-network目錄
生成加密證書
../bin/cryptogen generate --config=./crypto-config.yaml
4、生成創世區塊
../bin/configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
5、生成通道組態檔
../bin/configtxgen -profile FourOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID jdml
6、生成錨節點組態檔
組織1
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID jdml -asOrg Org1MSP
組織2
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID jdml -asOrg Org2MSP
組織3
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID jdml -asOrg Org3MSP
組織4
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org4MSPanchors.tx -channelID jdml -asOrg Org4MSP
7、進入cli終端創建通道
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
將生成的通道塊拷貝到channel-artifacts檔案夾下
cp jdml.block ./channel-artifacts
8 、先授權(chmod 777 -R xxx)再打包 加密檔案(crypto-config)組態檔(channel-artifacts)
tar -cvf xxx.tar.gz xxx
9、將壓縮檔案復制到rafttwo、raftthree、raftfour、raftfive
解壓到first-network路徑下,5臺虛擬機使用同一個加密檔案以及網路組態檔,配置多機服務
10、raftone虛擬機 修改first-network/scripts/utils.sh 方便節點切換
11、進入raftone cli 節點執行peer指令
docker exec -it cli bash
12、創建通道
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
查看peer環境
env | grep CORE
peer0加入通道
peer channel join -b channel-artifacts/jdml.block
切換節點
source scripts/utils.sh
setGlobals 1 1
env | grep CORE
peer1加入通道
peer channel join -b channel-artifacts/jdml.block
13、rafttwo、raftthree、raftfour虛擬機執行上述加入通道操作
修改utils.sh檔案、peer0加入通道、切換節點、peer1加入通道
14、4個組織8個節點全部加入通道后,執行更新錨節點操作
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、查看最新區塊 從0開始
在raftone上查看
peer channel fetch newest -c jdml -o fy.jdml.pro
在rafttwo上查看
peer channel fetch newest -c jdml -o ga.jdml.pro
在raftthree上查看
peer channel fetch newest -c jdml -o jc.jdml.pro
在raftfour上查看
peer channel fetch newest -c jdml -o sf.jdml.pro
創世區塊 0
更新組織1的錨節點 1
更新組織2的錨節點 2
更新組織3的錨節點 3
更新組織4的錨節點 4
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/267097.html
標籤:區塊鏈
上一篇:一次node.js爬蟲實踐
