fabric-solo单机多节点系统配置一

步骤

  • 生成证书文件
  • 生成通道文件 创始块文件
  • 编写docker-compose
    • 各个节点
  • 启动容器
  • 登录客户端
    • 创建通道
    • 加入通道(各节点)
    • 安装链码(各节点)
    • 初始化链码(任意节点)
    • 测试链码

Order节点:Orderer
域名:orderer.bank.com
类型:solo

组织 域名 peer节点 用户
Org1 org1.bank.com 2个 3个
Org2 org2.bank.com 2个 1个

所有的配置文件可参考fabric-samples/first-network中的配置文件(cp到项目目录更改即可)

1 生成证书文件 cryptogen

新建项目目录,编写 crypto-config.yaml 文件,编写完成后使用cryptogen生成证书文件。

sui@server_root:~/hyperledger-fabric/demo2$ pwd
sui@server_root:~/hyperledger-fabric/demo2$ vi crypto-config.yaml

生成证书 cryptogen generate --config=crypto-config.yaml
使用 cryptogen showtemplate 命令可以查看配置文件模板
配置文件内容如下:

# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
  # ---------------------------------------------------------------------------
  # Orderer
  # ---------------------------------------------------------------------------
  - Name: Orderer
    Domain: bank.com
      Specs:
      - Hostname: orderer
     
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
  # ---------------------------------------------------------------------------
  # Org1
  # ---------------------------------------------------------------------------
  - Name: Org1
    Domain: org1.bank.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 3
  # ---------------------------------------------------------------------------
  # Org2: See "Org1" for full specification
  # ---------------------------------------------------------------------------
  - Name: Org2
    Domain: org2.bank.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

生成后会在本地创建crypto-config文件夹

sui@server_root:~/hyperledger-fabric/demo2$ ls
crypto-config  crypto-config.yaml
sui@server_root:~/hyperledger-fabric/demo2$ tree crypto-config -L 3
crypto-config
├── ordererOrganizations
│   └── bank.com
│       ├── ca
│       ├── msp
│       ├── orderers
│       ├── tlsca
│       └── users
└── peerOrganizations
    ├── org1.bank.com
    │   ├── ca
    │   ├── msp
    │   ├── peers
    │   ├── tlsca
    │   └── users
    └── org2.bank.com
        ├── ca
        ├── msp
        ├── peers
        ├── tlsca
        └── users

2 生成通道和创世块文件-configtxgen

拷贝文件到目录下,编辑 configtx.yaml

sui@server_root:~/hyperledger-fabric/demo2$ cp ../fabric-samples/first-network/configtx.yaml .
sui@server_root:~/hyperledger-fabric/demo2$ vi configtx.yaml 

生成通道文件 --profile 接配置文件中的定义变量名称Profiles:
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx channel.tx -channelID mychannel
生成创世块文件
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock genesis.block
之后,会生成两个文件,一个创世块genesis.block,一个通道文件channel.tx,记住创建的通道名称 mychannel

sui@server_root:~/hyperledger-fabric/demo2$ ls
channel.tx  configtx.yaml  crypto-config  crypto-config.yaml  genesis.block
sui@server_root:~/hyperledger-fabric/demo2$ 

配置文件如下


Organizations:
    - &OrdererOrg  
        Name: OrdererOrg      
        ID: OrdererMSP
        MSPDir: crypto-config/ordererOrganizations/bank.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"

    - &Org1  
        Name: Org1MSP
        ID: Org1MSP
        MSPDir: crypto-config/peerOrganizations/org1.bank.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org1MSP.admin')"

        AnchorPeers:           
            - Host: peer0.org1.bank.com
              Port: 7051

    - &Org2        
        Name: Org2MSP      
        ID: Org2MSP
        MSPDir: crypto-config/peerOrganizations/org2.bank.com/msp     
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org2MSP.admin')"

        AnchorPeers:
            - Host: peer0.org2.bank.com
              Port: 7051

################################################################################
#
#   SECTION: Capabilities
#
################################################################################
Capabilities:
    # Channel capabilities apply to both the orderers and the peers and must be
    # supported by both.
    # Set the value of the capability to true to require it.
    Channel: &ChannelCapabilities
        # V1.3 for Channel is a catchall flag for behavior which has been
        # determined to be desired for all orderers and peers running at the v1.3.x
        # level, but which would be incompatible with orderers and peers from
        # prior releases.
        # Prior to enabling V1.3 channel capabilities, ensure that all
        # orderers and peers on a channel are at v1.3.0 or later.
        V1_3: true

    # Orderer capabilities apply only to the orderers, and may be safely
    # used with prior release peers.
    # Set the value of the capability to true to require it.
    Orderer: &OrdererCapabilities
        # V1.1 for Orderer is a catchall flag for behavior which has been
        # determined to be desired for all orderers running at the v1.1.x
        # level, but which would be incompatible with orderers from prior releases.
        # Prior to enabling V1.1 orderer capabilities, ensure that all
        # orderers on a channel are at v1.1.0 or later.
        V1_1: true

    # Application capabilities apply only to the peer network, and may be safely
    # used with prior release orderers.
    # Set the value of the capability to true to require it.
    Application: &ApplicationCapabilities
        # V1.3 for Application enables the new non-backwards compatible
        # features and fixes of fabric v1.3.
        V1_3: true
        # V1.2 for Application enables the new non-backwards compatible
        # features and fixes of fabric v1.2 (note, this need not be set if
        # later version capabilities are set)
        V1_2: false
        # V1.1 for Application enables the new non-backwards compatible
        # features and fixes of fabric v1.1 (note, this need not be set if
        # later version capabilities are set).
        V1_1: false

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

    # Policies defines the set of policies at this level of the config tree
    # For Application policies, their canonical path is
    #   /Channel/Application/
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"

    Capabilities:
        <<: *ApplicationCapabilities
################################################################################
#
#   SECTION: Orderer
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

    OrdererType: solo

    Addresses:
        - orderer.bank.com:7050

    BatchTimeout: 2s
    BatchSize:
        MaxMessageCount: 10  
        AbsoluteMaxBytes: 99 MB
        PreferredMaxBytes: 512 KB

    Kafka:
        # Brokers: A list of Kafka brokers to which the orderer connects
        # NOTE: Use IP:port notation
        Brokers:
            - 127.0.0.1:9092

    # Organizations is the list of orgs which are defined as participants on
    # the orderer side of the network
    Organizations:

    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        BlockValidation:
            Type: ImplicitMeta
            Rule: "ANY Writers"

################################################################################
#
#   CHANNEL
#
#   This section defines the values to encode into a config transaction or
#   genesis block for channel related parameters.
#
################################################################################
Channel: &ChannelDefaults
    # Policies defines the set of policies at this level of the config tree
    # For Channel policies, their canonical path is
    #   /Channel/
    Policies:
        # Who may invoke the 'Deliver' API
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        # Who may invoke the 'Broadcast' API
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        # By default, who may modify elements at this config level
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"

    # Capabilities describes the channel level capabilities, see the
    # dedicated Capabilities section elsewhere in this file for a full
    # description
    Capabilities:
        <<: *ChannelCapabilities

################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:

    TwoOrgsOrdererGenesis:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
    TwoOrgsChannel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
            Capabilities:
                <<: *ApplicationCapabilities

    SampleDevModeKafka:
        <<: *ChannelDefaults
        Capabilities:
            <<: *ChannelCapabilities
        Orderer:
            <<: *OrdererDefaults
            OrdererType: kafka
            Kafka:
                Brokers:
                - kafka.bank.com:9092

            Organizations:
            - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Application:
            <<: *ApplicationDefaults
            Organizations:
            - <<: *OrdererOrg
        Consortiums:
            SampleConsortium:
                Organizations:
                - *Org1
                - *Org2

2 编写docker-compose

先自行了解下docker数据卷挂载,compose文件用到了大量的数据挂载。编写compose文件可查看first-network中的demo

sui@server_root:~/hyperledger-fabric/fabric-samples/first-network$ tree
.
├── base #docker-compose继承base文件的yaml
│   ├──docker-compose-base.yaml 引用peer-base.yaml
│   └── peer-base.yaml
├── channel-artifacts #通道文件,创世块文件目录,也可以自定义
├── configtx.yaml
├── crypto-config.yaml
├── docker-compose-cli.yaml #compose模板文件,更改此内容即可

在docker-compose-base.yaml 中genesis.block数据挂载 默认在
channel-artifacts文件夹中,更改此目录或者将上一步生成的创世块文件和通道文件都cp到子目录中(自行创建channel-artifacts),或者以后生成创世块时直接生成到channel-artifacts目录中

   volumes:
    - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block

本例 为了少修改配置文件,把之前生成的创世块和通道文件,拷贝到此目录中,拷贝base/*和docker-compose-cli.yaml 到项目目录中

sui@server_root:~/hyperledger-fabric/demo2$ tree -L 2
.
├── base
│   ├── docker-compose-base.yaml
│   └── peer-base.yaml
├── channel-artifacts
│   ├── channel.tx
│   └── genesis.block
├── configtx.yaml
├── crypto-config
│   ├── ordererOrganizations
│   └── peerOrganizations
├── crypto-config.yaml
└── docker-compose-cli.yaml

docker-compose-cli.yaml

version: '2'
volumes:
  orderer.bank.com:
  peer0.org1.bank.com:
  peer1.org1.bank.com:
  peer0.org2.bank.com:
  peer1.org2.bank.com:

networks:
  byfn:

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

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

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

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

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

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:$IMAGE_TAG
    tty: true
    stdin_open: true
    environment:
      - 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.bank.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.bank.com/peers/peer0.org1.bank.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.bank.com/peers/peer0.org1.bank.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.bank.com/peers/peer0.org1.bank.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.bank.com/users/[email protected]/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.bank.com
      - peer0.org1.bank.com
      - peer1.org1.bank.com
      - peer0.org2.bank.com
      - peer1.org2.bank.com
    networks:
      - byfn

base/docker-compose-base

version: '2'
services:
  orderer.bank.com:
    container_name: orderer.bank.com
    image: hyperledger/fabric-orderer:$IMAGE_TAG
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      # enabled TLS
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1
      - ORDERER_KAFKA_VERBOSE=true
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: orderer
    volumes:
    - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
    - ../crypto-config/ordererOrganizations/bank.com/orderers/orderer.bank.com/msp:/var/hyperledger/orderer/msp
    - ../crypto-config/ordererOrganizations/bank.com/orderers/orderer.bank.com/tls/:/var/hyperledger/orderer/tls
    - orderer.bank.com:/var/hyperledger/production/orderer
    ports:
      - 7050:7050

  peer0.org1.bank.com:
    container_name: peer0.org1.bank.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org1.bank.com
      - CORE_PEER_ADDRESS=peer0.org1.bank.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.bank.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.bank.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org1.bank.com/peers/peer0.org1.bank.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org1.bank.com/peers/peer0.org1.bank.com/tls:/etc/hyperledger/fabric/tls
        - peer0.org1.bank.com:/var/hyperledger/production
    ports:
      - 7051:7051
      - 7053:7053

  peer1.org1.bank.com:
    container_name: peer1.org1.bank.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org1.bank.com
      - CORE_PEER_ADDRESS=peer1.org1.bank.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.bank.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.bank.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org1.bank.com/peers/peer1.org1.bank.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org1.bank.com/peers/peer1.org1.bank.com/tls:/etc/hyperledger/fabric/tls
        - peer1.org1.bank.com:/var/hyperledger/production

    ports:
      - 8051:7051
      - 8053:7053

  peer0.org2.bank.com:
    container_name: peer0.org2.bank.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org2.bank.com
      - CORE_PEER_ADDRESS=peer0.org2.bank.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.bank.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.bank.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org2.bank.com/peers/peer0.org2.bank.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org2.bank.com/peers/peer0.org2.bank.com/tls:/etc/hyperledger/fabric/tls
        - peer0.org2.bank.com:/var/hyperledger/production
    ports:
      - 9051:7051
      - 9053:7053

  peer1.org2.bank.com:
    container_name: peer1.org2.bank.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org2.bank.com
      - CORE_PEER_ADDRESS=peer1.org2.bank.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.bank.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.bank.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org2.bank.com/peers/peer1.org2.bank.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org2.bank.com/peers/peer1.org2.bank.com/tls:/etc/hyperledger/fabric/tls
        - peer1.org2.bank.com:/var/hyperledger/production
    ports:
      - 10051:7051
      - 10053:7053

base-peer-base无更改,注意启动时设置IMAGE_TAG环境变量,或者删除IMAGE_TAG

version: '2'
services:
  peer-base:
    image: hyperledger/fabric-peer:$IMAGE_TAG
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      # the following setting starts chaincode containers on the same
      # bridge network as the peers
      # https://docs.docker.com/compose/networking/
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start

3 启动dockers-compose

peer-base文件中引用IMAGE_TAG环境变量,这里使用latest,如果不设置,导致出现没有此dockers image错误,或者删除peer-base中的环境变量,默认使用latest

sui@server_root:~/hyperledger-fabric/demo2$ export IMAGE_TAG=latest
sui@server_root:~/hyperledger-fabric/demo2$ docker-compose -f docker-compose-cli.yaml up -d
WARNING: The COMPOSE_PROJECT_NAME variable is not set. Defaulting to a blank string.
Creating peer1.org2.bank.com ... done
Creating orderer.bank.com    ... done
Creating peer0.org2.bank.com ... done
Creating peer0.org1.bank.com ... done
Creating peer1.org1.bank.com ... done
Creating cli                 ... done
sui@server_root:~/hyperledger-fabric/demo2$ docker-compose -f docker-compose-cli.yaml ps 
WARNING: The COMPOSE_PROJECT_NAME variable is not set. Defaulting to a blank string.
       Name               Command       State                        Ports                      
------------------------------------------------------------------------------------------------
cli                   /bin/bash         Up                                                      
orderer.bank.com      orderer           Up      0.0.0.0:7050->7050/tcp                          
peer0.org1.bank.com   peer node start   Up      0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp  
peer0.org2.bank.com   peer node start   Up      0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp  
peer1.org1.bank.com   peer node start   Up      0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp  
peer1.org2.bank.com   peer node start   Up      0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp

一共启动了6个dockers容器,一个客户端cli,一个order排序节点,4个peer节点。
为了每次启动容器,不加-f 参数,可以把ocker-compose-cli.yaml 命名为ocker-compose.yaml,docker-compose默认查找子文件

关闭容器 down

sui@server_root:~/hyperledger-fabric/demo2$ docker-compose -f docker-compose-cli.yaml down
WARNING: The COMPOSE_PROJECT_NAME variable is not set. Defaulting to a blank string.
Stopping cli                 ... done
Stopping peer1.org1.bank.com ... done
Stopping peer0.org1.bank.com ... done
Stopping peer0.org2.bank.com ... done
Stopping orderer.bank.com    ... done
Stopping peer1.org2.bank.com ... done
Removing cli                 ... done
Removing peer1.org1.bank.com ... done
Removing peer0.org1.bank.com ... done
Removing peer0.org2.bank.com ... done
Removing orderer.bank.com    ... done
Removing peer1.org2.bank.com ... done
Removing network demo2_byfn

重命名文件,再次启动容器

sui@server_root:~/hyperledger-fabric/demo2$ mv docker-compose-cli.yaml docker-compose.yaml     
sui@server_root:~/hyperledger-fabric/demo2$ docker-compose up -d
WARNING: The COMPOSE_PROJECT_NAME variable is not set. Defaulting to a blank string.
Creating network "demo2_byfn" with the default driver
Creating peer1.org1.bank.com ... done
Creating orderer.bank.com    ... done
Creating peer1.org2.bank.com ... done
Creating peer0.org2.bank.com ... done
Creating peer0.org1.bank.com ... done
Creating cli                 ... done
sui@server_root:~/hyperledger-fabric/demo2$ 

下一节讲解peer节点操作

你可能感兴趣的:(区块链)