《HyperLedger Fabric 实战》—— 十六、升级 Fabric 1.2 —— 5、Peer 集群部署

《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.yamldocker-peer0.org2.yaml 文件并启动。

后面我们会尝试部署、测试合约。

你可能感兴趣的:(《Hyperledger,Fabric,实战》)