Fabric部署多机版本

Posted sanqima

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Fabric部署多机版本相关的知识,希望对你有一定的参考价值。

    Fabric v1.4.3的First-network默认是单机版本,采用solo模式。下面介绍其多机版本的部署方法,即4 peer+1 order 它们都在不同的机器上运行。

1、节点描述

节点IP说明所在组织
order192.168.30.11排序节点独立
peer0.org1192.168.30.22普通节点org1
peer1.org1192.168.30.33普通节点org1
peer0.org2192.168.30.44普通节点org2
peer1.org2192.168.30.55普通节点org2

2、软件环境

    fabric-samples v1.4.3
    fabric v1.4.3
    fabric ca v1.4.3
    Ubuntu 16.04

3、将First-network复制一份,重命名为one,然后精简one文件夹

3.1 精简first-network

cd $GOPATH/src/github.com/hyperledger/fabric-samples
cp -r first-network one
cd one

    在order节点,对one/文件夹进行精简,得到2个文件夹+7个文件,如图(2)所示:

图(1) first-network复制之后,再精简得到one文件夹

    下面的创世区块、身份证书、通道配置文件,都是通过工具,在$GOPATH/src/github.com/hyperledger/fabric-samples/one里生成的。

3.2 制作身份证书

    使用 cryptogen 工具将文件 crypto-config.yaml 作为参数配置生成组织结构与身份证书

cd ./fabric-sample/one
../bin/cryptogen generate --config=./crypto-config.yaml

3.3 生成创世区块

## 使能FABRIC_CFG_PATH 变量
export FABRIC_CFG_PATH=$PWD

## 生成创世区块
cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

3.4 生成通道配置文件

    创建一个mychannel的通道,并生成通道配置文件channel.tx,其保存在one/channel-artifacts目录下。

export CHANNEL_NAME=mychannel && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME

3.5 生成2个组织的锚节点文件

../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP

../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

    把这个one文件夹,使用scp命令,或者ftp拷贝其他4个节点。

4、设置/etc/hosts

    order、peer0.org1、peer1.org1、peer0.org2、peer1.org2这5台主机都需要配置/etc/hosts,如下所示。
    a)打开/etc/hosts

sudo vim /etc/hosts

    b) 添加5个域名解析

192.168.30.11 orderer.example.com     
192.168.30.22 peer0.org1.example.com  
192.168.30.33 peer1.org1.example.com  
192.168.30.44 peer0.org2.example.com  
192.168.30.55 peer1.org2.example.com  

    c) 重启网络

sudo /etc/init.d/networking restart

5、设置配置文件

5.1 order节点配置

    a) 复制docker-compose-cli.yaml,并重命名为docker-compose-orderer.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-cli.yaml docker-compose-orderer.yaml

    b) 精简docker-compose-orderer.yaml文件,如下:
    //docker-compose-orderer.yaml

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

version: '2'

volumes:
  orderer.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

5.2 peer0.org1节点配置

    a) 复制docker-compose-cli.yaml,并重命名为docker-compose-peer0-Org1.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-cli.yaml docker-compose-peer0-Org1.yaml

    b) 精简docker-compose-peer0-Org1.yaml文件,如下:
//docker-compose-peer0-Org1.yaml

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

version: '2'

volumes:
  peer0.org1.example.com:


networks:
  byfn:

services:

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org1.example.com
    networks:
      - byfn
    extra_hosts:  ##填写与该结点相连的其他节点IP
      - "orderer.example.com:192.168.30.11"
      - "peer1.org1.example.com:192.168.30.33"
      - "peer0.org2.example.com:192.168.30.44"
      - "peer1.org2.example.com:192.168.30.55"     


  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:
      - peer0.org1.example.com
    networks:
      - byfn
    extra_hosts:  ##填写所有的节点IP
      - "orderer.example.com:192.168.30.11"
      - "peer0.org1.example.com:192.168.30.22" 
      - "peer1.org1.example.com:192.168.30.33"
      - "peer0.org2.example.com:192.168.30.44"
      - "peer1.org2.example.com:192.168.30.55"     

5.3 peer1.org1节点配置

    a) 复制docker-compose-cli.yaml,并重命名为docker-compose-peer1-Org1.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-cli.yaml docker-compose-peer1-Org1.yaml

    b) 精简docker-compose-peer11-Org1.yaml文件,如下:
    //docker-compose-peer1-Org1.yaml

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

version: '2'

volumes:
  peer1.org1.example.com:


networks:
  byfn:

services:

  peer1.org1.example.com:
    container_name: peer1.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org1.example.com
    networks:
      - byfn
    extra_hosts:  ##填写与该结点相连的其他节点IP
      - "orderer.example.com:192.168.30.11"
      - "peer0.org1.example.com:192.168.30.22" 
      - "peer0.org2.example.com:192.168.30.44"
      - "peer1.org2.example.com:192.168.30.55"   


  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=peer1.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/peer1.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/peer1.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/peer1.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:
      - peer1.org1.example.com
    networks:
      - byfn
    extra_hosts:  ##填写所有的节点IP
      - "orderer.example.com:192.168.30.11"
      - "peer0.org1.example.com:192.168.30.22" 
      - "peer1.org1.example.com:192.168.30.33"
      - "peer0.org2.example.com:192.168.30.44"
      - "peer1.org2.example.com:192.168.30.55"     

5.4 peer0.org2节点配置

    a) 复制docker-compose-cli.yaml,并重命名为docker-compose-peer0-Org2.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-cli.yaml docker-compose-peer0-Org2.yaml

    b) 精简docker-compose-peer0-Org2.yaml文件,如下:
    //docker-compose-peer0-Org2.yaml

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

version: '2'

volumes:
  peer0.org2.example.com:


networks:
  byfn:

services:

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org2.example.com
    networks:
      - byfn
    extra_hosts:  
      - "orderer.example.com:192.168.30.11"
      - "peer0.org1.example.com:192.168.30.22" 
      - "peer1.org1.example.com:192.168.30.33"
      - "peer1.org2.example.com:192.168.30.55"   


  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.org2.example.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.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:
      - peer0.org2.example.com
    networks:
      - byfn
    extra_hosts:  
      - "orderer.example.com:192.168.30.11"
      - "peer0.org1.example.com:192.168.30.22" 
      - "peer1.org1.example.com:192.168.30.33"
      - "peer0.org2.example.com:192.168.30.44"
      - "peer1.org2.example.com:192.168.30.55"     

5.5 peer1.org2节点配置

    a) 复制docker-compose-cli.yaml,并重命名为docker-compose-peer1-Org2.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-cli.yaml docker-compose-peer1-Org2.yaml

    b) 精简docker-compose-peer1-Org2.yaml文件,如下:
    //docker-compose-peer1-Org2.yaml

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

version: '2'

volumes:
  peer1.org2.example.com:


networks:
  byfn:

services:

  peer1.org2.example.com:
    container_name: peer1.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org2.example.com
    networks:
      - byfn
    extra_hosts:  
      - "orderer.example.com:192.168.30.11"
      - "peer0.org1.example.com:192.168.30.22" 
      - "peer1.org1.example.com:192.168.30.33"
      - "peer0.org2.example.com:192.168.30.44" 
   


  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=peer1.org2.example.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.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:
      - peer1.org2.example.com
    networks:
      - byfn
    extra_hosts:  
      - "orderer.example.com:192.168.30.11"
      - "peer0.org1.example.com:192.168.30.22" 
      - "peer1.org1.example.com:192.168.30.33"
      - "peer0.org2.example.com:192.168.30.44"
      - "peer1.org2.example.com:192.168.30.55"     

5.6 peer0.org1的couch配置

    a) 复制docker-compose-couch.yaml,并重命名为docker-compose-peer0-Org1-couch.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-couch.yaml docker-compose-peer0-Org1-couch.yaml

    b) 精简docker-compose-peer0-Org1-couch.yaml文件,如下:
    //docker-compose-peer0-Org1-couch.yaml

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

version: '2'

networks:
  byfn:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "5984:5984"
    networks:
      - byfn

  peer0.org1.example.com: ##指定节点域名
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb0

5.7 peer1.org1的couch配置

    a) 复制docker-compose-couch.yaml,并重命名为docker-compose-peer1-Org1-couch.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-couch.yaml docker-compose-peer1-Org1-couch.yaml

    b) 精简docker-compose-peer1-Org1-couch.yaml文件,如下:
    //docker-compose-peer1-Org1-couch.yaml

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

version: '2'

networks:
  byfn:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "5984:5984"
    networks:
      - byfn

  peer1.org1.example.com: ##指定节点域名
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb0

5.8 peer0.org2的couch配置

    a) 复制docker-compose-couch.yaml,并重命名为docker-compose-peer0-Org2-couch.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-couch.yaml docker-compose-peer0-Org2-couch.yaml

    b) 精简docker-compose-peer0-Org2-couch.yaml文件,如下:
    //docker-compose-peer0-Org2-couch.yaml

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

version: '2'

networks:
  byfn:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "5984:5984"
    networks:
      - byfn

  peer0.org2.example.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb0

5.9 peer1.org2的couch配置

    a) 复制docker-compose-couch.yaml,并重命名为docker-compose-peer1-Org2-couch.yaml

cd $GOPATH/src/github.com/hyperledger/fabric-samples/one
cp docker-compose-couch.yaml docker-compose-peer1-Org2-couch.yaml

    b) 精简docker-compose-peer1-Org2-couch.yaml文件,如下:
    //docker-compose-peer1-Org2-couch.yaml

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

version: '2'

networks:
  byfn:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "5984:5984"
    networks:
      - byfn

  peer1.org2.example.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb0

5.10 节点的目录结构

    a) order节点的目录结构

图(1) order节点的目录结构

    b) peer0.org1节点的目录结构

图(2) peer0.org1节点的目录结构

    c) peer1.org1节点的目录结构

图(3) peer1.org1节点的目录结构

    d) peer0.org2节点的目录结构

图(4) peer0.org2节点的目录结构

    f) peer1.org2节点的目录结构

图(f) peer1.org2节点的目录结构

6、启动order和peer节点

6.1 启动order

cd /usr/local/gocode/src/github.com/hyperledger/fabric-samples/one
sudo docker-compose -f docker-compose-orderer.yaml up

6.2 启动peer0.org1

sudo docker-compose -f docker-compose-peer0-Org1.yaml -f docker-compose-peer0-Org1-couch.yaml up

6.3 启动peer1.org1

sudo docker-compose -f docker-compose-peer1-Org1.yaml -f docker-compose-peer1-Org1-couch.yaml up

6.4 启动peer0.org2

sudo docker-compose -f docker-compose-peer0-Org2.yaml -f docker-compose-peer0-Org2-以上是关于Fabric部署多机版本的主要内容,如果未能解决你的问题,请参考以下文章

菜鸟系列Fabric——Fabric 1.2 多机部署

HyperLedger Fabric 1.2 多机多节点部署(10.3)

fabric-1.1多机多节点部署

(Fabric 学习七)Fabric2.4.x 区块链多机部署(重新整一遍)

Hyperledger Fabric多机及explorer搭建

Fabric多机环境搭建,测试通过