《HyperLedger Fabric 實戰》—— 十六、更新 Fabric 1.2 —— 5、Peer 叢集部署
1、編寫 docker-peer0.org1.yaml 配置檔案
提取
docker-compose-e2e.yaml
檔案中 ca01、couchdb01、peer0.org1.example.com、cli01 等資訊,全部寫入 211 機器的
~/fabric/aberic/docker-peer0.org1.yaml
檔案中,以 211 機器為例,它應該是如下樣子。
ca01:
container_name: ca_Org1
extends:
file: base/docker-compose-base.yaml
service: ca
environment:
- FABRIC_CA_SERVER_CA_NAME=ca-org1
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/2bcc992008ab104c2923f73cec561c6ec3257380ea726c040b276b3b331e7550_sk
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/2bcc992008ab104c2923f73cec561c6ec3257380ea726c040b276b3b331e7550_sk -b admin:adminpw -d'
volumes:
- ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
couchdb01:
container_name: couchdb01
extends:
file: base/docker-compose-base.yaml
service: couchdb
peer0.org1.example.com:
container_name: peer0.org1.example.com
extends:
file: base/docker-compose-base.yaml
service: peer.org.example.com
environment:
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb01:5984
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:7052
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
cli01:
container_name: cli
extends:
file: base/docker-compose-base.yaml
service: cli
environment:
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
2、防火牆設定
在 208 ~ 210 機器上全部執行一次以下指令,以開放防火牆限制。
firewall-cmd --add-port=5984/tcp --add-port=7051/tcp --add-port=7052/tcp --add-port=7053/tcp --add-port=7054/tcp
3、啟動 peer0.org1 節點
在 211 機器上執行:
docker-compose -f docker-peer0.org1.yaml up
4、驗證 peer0.org1 啟動情況
另起一個終端連接配接到 211 機器上,執行:
docker ps
若 ca_Org1、couchdb01、peer0.org1.example.com、cli 四個容器勻成功啟動,說明節點啟動成功。重點看 ca 容器,因為如果手工替換 “*_sk” 檔案的話,如果替錯,ca 容器會啟動失敗。
5、配置群集其他 peer 服務
複制第一步開始的步驟,分别在 212、213 機器上建立
docker-peer1.org1.yaml
、
docker-peer0.org2.yaml
檔案并啟動。
後面我們會嘗試部署、測試合約。