Fabric 2.4.9 单机部署多节点网络(多通道---分片区块链网络)

发布于:2024-12-06 ⋅ 阅读:(131) ⋅ 点赞:(0)

要进行本教程的内容,请先完成 Fabric 网络基础环境的搭建,Fabric 网络基础环境要求:安装git、curl、vim、jq、docker、docker-compose、Node.js,克隆下载 fabric 源码,克隆下载 fabric-samples 源码、下载二进制文件和拉取镜像。搭建 Fabric 网络基础环境,参考我之前写的文章:Hyperledger Fabric 2.4.9 环境搭建和 Caliper 0.5.0 测试工具部署教程(Ubuntu)-CSDN博客

这里搭建的 Fabric 网络,是一个有着5个分片的分片区块链网络,有着1个排序组织(包含3个排序节点)和5个普通的组织(每个组织都包含2个对等节点,对应5个分片),网络拓扑如下所示(这里省略了排序节点):

1. 生成相关的证书文件

在 ~/go/src/github.com/hyperledger 目录下新建 myfabric 文件夹并进入该文件夹:

mkdir myfabric && cd myfabric

该文件夹就是我们要部署 Fabric 网络的根目录。

创建文件 crypto-config.yaml ,并用 gedit 软件打开:

touch crypto-config.yaml && gedit crypto-config.yaml

添加如下内容:


# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
  # ---------------------------------------------------------------------------
  # Orderer
  # ---------------------------------------------------------------------------
  - Name: Orderer
    Domain: idy.com
    EnableNodeOUs: true

    Specs:
      - Hostname: orderer0
      - Hostname: orderer1
      - Hostname: orderer2

# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
  # ---------------------------------------------------------------------------
  # Org1
  # ---------------------------------------------------------------------------
  - Name: Org1
    Domain: org1.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2

    Users:
      Count: 1

  # ---------------------------------------------------------------------------
  # Org2
  # ---------------------------------------------------------------------------
  - Name: Org2
    Domain: org2.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1
  
  # ---------------------------------------------------------------------------
  # Org3
  # ---------------------------------------------------------------------------
  - Name: Org3
    Domain: org3.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1
  
  # ---------------------------------------------------------------------------
  # Org4
  # ---------------------------------------------------------------------------
  - Name: Org4
    Domain: org4.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1
      
  # ---------------------------------------------------------------------------
  # Org5
  # ---------------------------------------------------------------------------
  - Name: Org5
    Domain: org5.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

根据 crypto-config.yaml 生成相关的证书文件,生成的证书文件会在 ./crypto-config/ 文件夹下:

cryptogen generate --config=crypto-config.yaml

2. 生成相关的通道配置文件

创建文件 configtx.yaml ,并用 gedit 软件打开:

touch configtx.yaml && gedit configtx.yaml

添加如下内容:

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

---
################################################################################
#
#   Section: Organizations
#
#   - This section defines the different organizational identities which will
#   be referenced later in the configuration.
#
################################################################################
Organizations:

    # SampleOrg defines an MSP using the sampleconfig.  It should never be used
    # in production but may be used as a template for other definitions
    - &OrdererOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: OrdererOrg

        # ID to load the MSP definition as
        ID: OrdererMSP

        # MSPDir is the filesystem path which contains the MSP configuration
        MSPDir: crypto-config/ordererOrganizations/idy.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"

        # OrdererEndpoints:
        #     - orderer.example.com:7050

    - &Org1
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org1MSP

        # ID to load the MSP definition as
        ID: Org1MSP

        MSPDir: crypto-config/peerOrganizations/org1.idy.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        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')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org1MSP.peer')"

    - &Org2
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org2MSP

        # ID to load the MSP definition as
        ID: Org2MSP

        MSPDir: crypto-config/peerOrganizations/org2.idy.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        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')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org2MSP.peer')"
    
    - &Org3
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org3MSP

        # ID to load the MSP definition as
        ID: Org3MSP

        MSPDir: crypto-config/peerOrganizations/org3.idy.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.peer', 'Org3MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org3MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org3MSP.peer')"
        
    - &Org4
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org4MSP

        # ID to load the MSP definition as
        ID: Org4MSP

        MSPDir: crypto-config/peerOrganizations/org4.idy.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.peer', 'Org4MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org4MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org4MSP.peer')"
                
    - &Org5
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org5MSP

        # ID to load the MSP definition as
        ID: Org5MSP

        MSPDir: crypto-config/peerOrganizations/org5.idy.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org5MSP.admin', 'Org5MSP.peer', 'Org5MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org5MSP.admin', 'Org5MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org5MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org5MSP.peer')"

################################################################################
#
#   SECTION: Capabilities
#
#   - This section defines the capabilities of fabric network. This is a new
#   concept as of v1.1.0 and should not be utilized in mixed networks with
#   v1.0.x peers and orderers.  Capabilities define features which must be
#   present in a fabric binary for that binary to safely participate in the
#   fabric network.  For instance, if a new MSP type is added, newer binaries
#   might recognize and validate the signatures from this type, while older
#   binaries without this support would be unable to validate those
#   transactions.  This could lead to different versions of the fabric binaries
#   having different world states.  Instead, defining a capability for a channel
#   informs those binaries without this capability that they must cease
#   processing transactions until they have been upgraded.  For v1.0.x if any
#   capabilities are defined (including a map with all capabilities turned off)
#   then the v1.0.x peer will deliberately crash.
#
################################################################################
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
        # V2_0 capability ensures that orderers and peers behave according
        # to v2.0 channel capabilities. Orderers and peers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 capability.
        # Prior to enabling V2.0 channel capabilities, ensure that all
        # orderers and peers on a channel are at v2.0.0 or later.
        V2_0: 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
        # V2_0 orderer capability ensures that orderers behave according
        # to v2.0 orderer capabilities. Orderers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 orderer capability.
        # Prior to enabling V2.0 orderer capabilities, ensure that all
        # orderers on channel are at v2.0.0 or later.
        V2_0: 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
        # V2_0 application capability ensures that peers behave according
        # to v2.0 application capabilities. Peers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 application capability.
        # Prior to enabling V2.0 application capabilities, ensure that all
        # peers on channel are at v2.0.0 or later.
        V2_0: true

################################################################################
#
#   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/<PolicyName>
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        LifecycleEndorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"
        Endorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"

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

    # Orderer Type: The orderer implementation to start
    OrdererType: etcdraft
    # Addresses used to be the list of orderer addresses that clients and peers
    # could connect to.  However, this does not allow clients to associate orderer
    # addresses and orderer organizations which can be useful for things such
    # as TLS validation.  The preferred way to specify orderer addresses is now
    # to include the OrdererEndpoints item in your org definition
    Addresses:
        - orderer0.idy.com:7050
        - orderer1.idy.com:8050
        - orderer2.idy.com:9050

    EtcdRaft:
        Consenters:
        - Host: orderer0.idy.com
          Port: 7050
          ClientTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer0.idy.com/tls/server.crt
          ServerTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer0.idy.com/tls/server.crt
          
        - Host: orderer1.idy.com
          Port: 8050
          ClientTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer1.idy.com/tls/server.crt
          ServerTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer1.idy.com/tls/server.crt
          
        - Host: orderer2.idy.com
          Port: 9050
          ClientTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer2.idy.com/tls/server.crt
          ServerTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer2.idy.com/tls/server.crt
          
    # Batch Timeout: The amount of time to wait before creating a batch
    BatchTimeout: 2s

    # Batch Size: Controls the number of messages batched into a block
    BatchSize:

        # Max Message Count: The maximum number of messages to permit in a batch
        MaxMessageCount: 10

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for
        # the serialized messages in a batch.
        AbsoluteMaxBytes: 99 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed for
        # the serialized messages in a batch. A message larger than the preferred
        # max bytes will result in a batch larger than preferred max bytes.
        PreferredMaxBytes: 512 KB

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

    # Policies defines the set of policies at this level of the config tree
    # For Orderer policies, their canonical path is
    #   /Channel/Orderer/<PolicyName>
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        # BlockValidation specifies what signatures must be included in the block
        # from the orderer for the peer to validate it.
        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/<PolicyName>
    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:

    FiveOrgsOrdererGenesis:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
                    - *Org3
                    - *Org4
                    - *Org5

    shard1Channel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
            Capabilities:
                <<: *ApplicationCapabilities
    
    shard2Channel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org2
            Capabilities:
                <<: *ApplicationCapabilities
                
    shard3Channel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org3
            Capabilities:
                <<: *ApplicationCapabilities    
                
    shard4Channel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org4
            Capabilities:
                <<: *ApplicationCapabilities
                
    shard5Channel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org5
            Capabilities:
                <<: *ApplicationCapabilities

生成创世区块文件:

configtxgen -profile FiveOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block -channelID system-channel

分别生成5个分片的通道文件:

configtxgen -profile shard1Channel -outputCreateChannelTx ./channel-artifacts/shard1.tx -channelID shard1
configtxgen -profile shard2Channel -outputCreateChannelTx ./channel-artifacts/shard2.tx -channelID shard2
configtxgen -profile shard3Channel -outputCreateChannelTx ./channel-artifacts/shard3.tx -channelID shard3
configtxgen -profile shard4Channel -outputCreateChannelTx ./channel-artifacts/shard4.tx -channelID shard4
configtxgen -profile shard5Channel -outputCreateChannelTx ./channel-artifacts/shard5.tx -channelID shard5

3. 生成docker-compose.yaml的启动文件

创建文件 docker-compose.yaml ,并用 gedit 软件打开:

touch docker-compose.yaml && gedit docker-compose.yaml
version: '2.4'

volumes:
  orderer0.idy.com:
  orderer1.idy.com:
  orderer2.idy.com:
  peer0.org1.idy.com:
  peer1.org1.idy.com:
  peer0.org2.idy.com:
  peer1.org2.idy.com:
  peer0.org3.idy.com:
  peer1.org3.idy.com:
  peer0.org4.idy.com:
  peer1.org4.idy.com:
  peer0.org5.idy.com:
  peer1.org5.idy.com:

networks:
  test:
    name: Fabric_Sharding

services:

  orderer0.idy.com:
    container_name: orderer0.idy.com
    image: hyperledger/fabric-orderer:latest
    labels:
      service: hyperledger-fabric
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_LISTENPORT=7050
      - 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_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_CHANNELPARTICIPATION_ENABLED=true
      - ORDERER_ADMIN_TLS_ENABLED=true
      - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_ADMIN_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_ADMIN_TLS_CLIENTROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053
    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/idy.com/orderers/orderer0.idy.com/msp:/var/hyperledger/orderer/msp
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer0.idy.com/tls:/var/hyperledger/orderer/tls
    ports:
      - 7050:7050
      - 7053:7053
    networks:
      - test

  orderer1.idy.com:
    container_name: orderer1.idy.com
    image: hyperledger/fabric-orderer:latest
    labels:
      service: hyperledger-fabric
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_LISTENPORT=8050
      - 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_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_CHANNELPARTICIPATION_ENABLED=true
      - ORDERER_ADMIN_TLS_ENABLED=true
      - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_ADMIN_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_ADMIN_TLS_CLIENTROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053
    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/idy.com/orderers/orderer1.idy.com/msp:/var/hyperledger/orderer/msp
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer1.idy.com/tls:/var/hyperledger/orderer/tls
    ports:
      - 8050:8050
      - 7054:7053
    networks:
      - test

  orderer2.idy.com:
    container_name: orderer2.idy.com
    image: hyperledger/fabric-orderer:latest
    labels:
      service: hyperledger-fabric
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_LISTENPORT=9050
      - 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_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_CHANNELPARTICIPATION_ENABLED=true
      - ORDERER_ADMIN_TLS_ENABLED=true
      - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_ADMIN_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_ADMIN_TLS_CLIENTROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053
    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/idy.com/orderers/orderer2.idy.com/msp:/var/hyperledger/orderer/msp
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer2.idy.com/tls:/var/hyperledger/orderer/tls
    ports:
      - 9050:9050
      - 7055:7053
    networks:
      - test

  peer0.org1.idy.com:
    container_name: peer0.org1.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org1.idy.com
      - CORE_PEER_ADDRESS=peer0.org1.idy.com:7051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:7051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org1.idy.com:7052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.idy.com:8051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.idy.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 7051:7051
    networks:
      - test

  peer1.org1.idy.com:
    container_name: peer1.org1.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org1.idy.com
      - CORE_PEER_ADDRESS=peer1.org1.idy.com:8051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:8051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org1.idy.com:8052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:8052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.idy.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.idy.com:8051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer1.org1.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer1.org1.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 8051:8051
    networks:
      - test

  peer0.org2.idy.com:
    container_name: peer0.org2.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org2.idy.com
      - CORE_PEER_ADDRESS=peer0.org2.idy.com:9051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:9051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org2.idy.com:9052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:9052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.idy.com:10051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.idy.com:9051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 9051:9051
    networks:
      - test

  peer1.org2.idy.com:
    container_name: peer1.org2.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org2.idy.com
      - CORE_PEER_ADDRESS=peer1.org2.idy.com:10051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:10051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org2.idy.com:10052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:10052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.idy.com:9051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.idy.com:10051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer1.org2.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer1.org2.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 10051:10051
    networks:
      - test

  peer0.org3.idy.com:
    container_name: peer0.org3.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org3.idy.com
      - CORE_PEER_ADDRESS=peer0.org3.idy.com:11051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:11051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org3.idy.com:11052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:11052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org3.idy.com:12051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.idy.com:11051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 11051:11051
    networks:
      - test

  peer1.org3.idy.com:
    container_name: peer1.org3.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org3.idy.com
      - CORE_PEER_ADDRESS=peer1.org3.idy.com:12051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:12051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org3.idy.com:12052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:12052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.idy.com:11051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org3.idy.com:12051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer1.org3.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer1.org3.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 12051:12051
    networks:
      - test

  peer0.org4.idy.com:
    container_name: peer0.org4.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org4.idy.com
      - CORE_PEER_ADDRESS=peer0.org4.idy.com:13051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:13051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org4.idy.com:13052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:13052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org4.idy.com:14051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org4.idy.com:13051
      - CORE_PEER_LOCALMSPID=Org4MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 13051:13051
    networks:
      - test

  peer1.org4.idy.com:
    container_name: peer1.org4.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org4.idy.com
      - CORE_PEER_ADDRESS=peer1.org4.idy.com:14051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:14051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org4.idy.com:14052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:14052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org4.idy.com:13051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org4.idy.com:14051
      - CORE_PEER_LOCALMSPID=Org4MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer1.org4.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer1.org4.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 14051:14051
    networks:
      - test

  peer0.org5.idy.com:
    container_name: peer0.org5.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org5.idy.com
      - CORE_PEER_ADDRESS=peer0.org5.idy.com:15051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:15051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org5.idy.com:15052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:15052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org5.idy.com:16051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org5.idy.com:15051
      - CORE_PEER_LOCALMSPID=Org5MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 15051:15051
    networks:
      - test

  peer1.org5.idy.com:
    container_name: peer1.org5.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - 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
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org5.idy.com
      - CORE_PEER_ADDRESS=peer1.org5.idy.com:16051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:16051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org5.idy.com:16052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:16052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org5.idy.com:15051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org5.idy.com:16051
      - CORE_PEER_LOCALMSPID=Org5MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer1.org5.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer1.org5.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 16051:16051
    networks:
      - test

  cli1:
    container_name: cli1
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli1
      - CORE_PEER_ADDRESS=peer0.org1.idy.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.idy.com/peers/peer0.org1.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/users/Admin@org1.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

  cli2:
    container_name: cli2
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli2
      - CORE_PEER_ADDRESS=peer0.org2.idy.com:9051
      - 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.idy.com/peers/peer0.org2.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.idy.com/users/Admin@org2.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

  cli3:
    container_name: cli3
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli3
      - CORE_PEER_ADDRESS=peer0.org3.idy.com:11051
      - CORE_PEER_LOCALMSPID=Org3MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/users/Admin@org3.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

  cli4:
    container_name: cli4
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli4
      - CORE_PEER_ADDRESS=peer0.org4.idy.com:13051
      - CORE_PEER_LOCALMSPID=Org4MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/users/Admin@org4.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

  cli5:
    container_name: cli5
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli5
      - CORE_PEER_ADDRESS=peer0.org5.idy.com:15051
      - CORE_PEER_LOCALMSPID=Org5MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/users/Admin@org5.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

在当前的目录下执行如下命令启动网络:

docker-compose up -d

查看节点状态:

docker ps -a

如果想要关闭网络,执行如下命令:

docker-compose down
docker volume prune

4. 通道相关配置操作

进入容器 cli1 :

docker exec -it cli1 bash

创建通道,生成通道文件:

peer channel create -o orderer0.idy.com:7050 -c shard1 -f ./channel-artifacts/shard1.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem

 查看生成的 shard1.block 通道文件:

ls

加入通道:

peer channel join -b shard1.block

退出容器 cli1 :

exit

然后分别进入 cli2/3/4/5 容器中,重复上面 cli1 中的操作(创建通道,加入通道)。

5. 链码调用

因为还未编写链码,所以先复制测试网络的链码文件,将 fabric-samples/chaincode/sacc/ 文件夹下的 sacc.go 文件复制到当前目录的 ./chaincode/go/ 目录下:

sudo cp ../fabric/scripts/fabric-samples/chaincode/sacc/sacc.go ./chaincode/go/

将 fabric-samples/chaincode/sacc/ 目录下的 go.mod 文件和 go.sum 文件复制到 ~ 用户主目录下,然后使用 gedit 命令打开 go.mod 文件:

cp ../fabric/scripts/fabric-samples/chaincode/sacc/go.mod ~/
cp ../fabric/scripts/fabric-samples/chaincode/sacc/go.sum ~/
gedit ~/go.mod

只修改 go.mod 文件,将 module 修改为: github.com/hyperledger/fabric-cluster/chaincode/go ,然后将 go 的版本修改为: go 1.18 , go.mod 文件的内容如下:

module github.com/hyperledger/fabric-cluster/chaincode/go
 
go 1.18
 
require (
	github.com/hyperledger/fabric-chaincode-go v0.0.0-20190823162523-04390e015b85
	github.com/hyperledger/fabric-protos-go v0.0.0-20190821214336-621b908d5022
)

将修改后的文件复制到容器 cli1 中:

docker cp ~/go.mod cli1:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
docker cp ~/go.sum cli1:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go

进入容器 cli1 ,进入链码文件:

docker exec -it cli1 bash
cd /opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go/

配置代理并下载相关依赖:

go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=on
go mod tidy
go mod vendor

回到工作目录,链码打包并安装:

cd /opt/gopath/src/github.com/hyperledger/fabric/peer
peer lifecycle chaincode package sacc.tar.gz --path /opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go/ --label sacc_1
peer lifecycle chaincode install sacc.tar.gz

上图中最后一行是 package-id ,在组织批准中需要用到,如果忘了,也有查询命令:

peer lifecycle chaincode queryinstalled

授权批准链码:

peer lifecycle chaincode approveformyorg --channelID shard1 --name sacc --version 1.0 --init-required --package-id sacc_1:2975ee7870d40463a45052f874b4d13f11884d405b087d1296e217db3657132c --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem

注意,记得将 pakage-id ,替换成自己电脑上生成的。

批准成功:

查看批准状态:

peer lifecycle chaincode checkcommitreadiness --channelID shard1 --name sacc --version 1.0 --init-required --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem --output json

链码提交:

peer lifecycle chaincode commit -o orderer1.idy.com:8050 --channelID shard1 --name sacc --version 1.0 --init-required --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer1.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem --peerAddresses peer0.org1.idy.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt

链码调用,初始化:

peer chaincode invoke -o orderer2.idy.com:9050 --isInit --ordererTLSHostnameOverride orderer2.idy.com --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer2.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem -C shard1 -n sacc --peerAddresses peer0.org1.idy.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt -c '{"Args":["IDY","100"]}'

查询操作:

peer chaincode query -C shard1 -n sacc -c '{"Args":["query","IDY"]}'

修改操作:

peer chaincode invoke -o orderer0.idy.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem -C shard1 -n sacc --peerAddresses peer0.org1.idy.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt -c '{"Args":["set","IDY","99"]}'

查询修改后的结果:

peer chaincode query -C shard1 -n sacc -c '{"Args":["query","IDY"]}'

在容器 cli1 中的测试到此结束。

退出容器 cli1 ,将容器 cli1 中的链码包分别复制到其他容器 cli2/3/4/5 中,以 cli2 为例:

exit
docker cp cli1:/opt/gopath/src/github.com/hyperledger/fabric/peer/sacc.tar.gz ./
docker cp sacc.tar.gz cli2:/opt/gopath/src/github.com/hyperledger/fabric/peer

分别进入容器 cli2/3/4/5 ,重复上面容器 cli1 中的操作进行测试(链码安装、批准、提交、调用、查询和修改)。

结束!!!


网站公告

今日签到

点亮在社区的每一天
去签到