创建自己的区块链网络 五

前言

上次我们修改了docker-compose-base.yaml,我还还需要修改最后一个文件便可以来编写启动网络的命令了。那么我们这里就来修改docker-compose-cli.yaml文件,这个配置文件是启动网络网络节点时候需要的,也就是使用docker启动了相应的容器作为网络节点。

修改文件

那么接下来我们就来修改下官方文件,首先看一下官方文件。

1、查看官方源文件

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

version: '2'

volumes:
  orderer.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:
  peer0.org2.example.com:
  peer1.org2.example.com:

networks:
  byfn:

services:

  orderer.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer.example.com
    container_name: orderer.example.com
    networks:
      - byfn

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org1.example.com
    networks:
      - byfn

  peer1.org1.example.com:
    container_name: peer1.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org1.example.com
    networks:
      - byfn

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org2.example.com
    networks:
      - byfn

  peer1.org2.example.com:
    container_name: peer1.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org2.example.com
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:$IMAGE_TAG
    tty: true
    stdin_open: true
    environment:
      - SYS_CHANNEL=$SYS_CHANNEL
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- FABRIC_LOGGING_SPEC=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=true
      - 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/Admin@org1.example.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/chaincode
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
        - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    depends_on:
      - orderer.example.com
      - peer0.org1.example.com
      - peer1.org1.example.com
      - peer0.org2.example.com
      - peer1.org2.example.com
    networks:
      - byfn

2、修改文件

大家可以看到我们修改的东西无非还是那几样,域名与我们之前配置的对应就可以了,如果少了,就自行添加上,就这么简单。那么接下来我们就来着手来进行修改。
下面是修改过后的内容:

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

#  1--将所有的example改为之前定义的slzce
#  2--将所有的org1改为之前定义的organization1
#  3--将所有的org2改为之前定义的organization2
#  4--将所有的peer0改为之前定义的node1
#  5--将所有的peer1改为之前定义的node2
#  6--将所有的channel-artifacts改为之前定义的config
#  6--添加节点
version: '2'

volumes:
  orderer.slzce.com:
  node1.organization1.slzce.com:
  node2.organization1.slzce.com:
  node1.organization2.slzce.com:
  node2.organization2.slzce.com:
#    以下内容为添加的
  node1.organization3.slzce.com:
  node2.organization3.slzce.com:
# -------------------
networks:
  byfn:

services:

  orderer.slzce.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer.slzce.com
    container_name: orderer.slzce.com
    networks:
      - byfn

  node1.organization1.slzce.com:
    container_name: node1.organization1.slzce.com
    extends:
      file:  base/docker-compose-base.yaml
      service: node1.organization1.slzce.com
    networks:
      - byfn

  node2.organization1.slzce.com:
    container_name: node2.organization1.slzce.com
    extends:
      file:  base/docker-compose-base.yaml
      service: node2.organization1.slzce.com
    networks:
      - byfn

  node1.organization2.slzce.com:
    container_name: node1.organization2.slzce.com
    extends:
      file:  base/docker-compose-base.yaml
      service: node1.organization2.slzce.com
    networks:
      - byfn

  node2.organization2.slzce.com:
    container_name: node2.organization2.slzce.com
    extends:
      file:  base/docker-compose-base.yaml
      service: node2.organization2.slzce.com
    networks:
      - byfn
  #    以下内容为添加的
  node1.organization3.slzce.com:
    container_name: node1.organization3.slzce.com
    extends:
      file:  base/docker-compose-base.yaml
      service: node1.organization3.slzce.com
    networks:
      - byfn

  node2.organization3.slzce.com:
    container_name: node2.organization3.slzce.com
    extends:
      file:  base/docker-compose-base.yaml
      service: node2.organization3.slzce.com
    networks:
      - byfn
# ---------------------------
  cli:
    container_name: cli
#    image: hyperledger/fabric-tools:$IMAGE_TAG 删除不必要的变量
    image: hyperledger/fabric-tools
    tty: true
    stdin_open: true
    environment:
      - SYS_CHANNEL=$SYS_CHANNEL
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- FABRIC_LOGGING_SPEC=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=node1.organization1.slzce.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP #这里注意点我们不需要修改他,如果你之前的id修改了才需要修改
      - CORE_PEER_TLS_ENABLED=flase
#        TLS 改为false并且删除下方
#      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/organization1.slzce.com/peers/node1.organization1.slzce.com/tls/server.crt
#      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/organization1.slzce.com/peers/node1.organization1.slzce.com/tls/server.key
#      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/organization1.slzce.com/peers/node1.organization1.slzce.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/organization1.slzce.com/users/Admin@organization1.slzce.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/chaincode
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
#        - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts 这里将channel-artifacts修改为config
        - ./config:/opt/gopath/src/github.com/hyperledger/fabric/peer/config
    depends_on:
      - orderer.slzce.com
      - node1.organization1.slzce.com
      - node2.organization1.slzce.com
      - node1.organization2.slzce.com
      - node2.organization2.slzce.com
      #    以下内容为添加的
      - node1.organization3.slzce.com
      - node2.organization3.slzce.com
#      ------------------
    networks:
      - byfn
#修改完毕

结语

那么到这里我们所有的配置文件全部都修改完成了,那么后面我们就可以编写命令来跑网络了,是不是很期待。

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

患孤

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值