天天看點

(二)生産網絡部署

  • 基于前期所安裝的fabric 2.4,根據自身的需求進行生産網絡的部署;

目錄

一、組織配置

二、生成創世區塊

三、建立系統通道

四、建立應用通道

五、更新錨節點

六、啟動網絡

期間遇到的錯誤

一、組織配置

準備配置檔案 crypto-config.yaml

OrdererOrgs:
  - Name: Orderer
    Domain: example.com
    EnableNodeOUs: true
    Specs:
      - Hostname: orderer
PeerOrgs:
  - Name: EduOrg
    Domain: eduorg.example.com
    EnableNodeOUs: true
    template:
      Count: 1
    Users:
      Count: 1
  - Name: StuOrg
    Domain: stuorg.example.com
    EnableNodeOUs: true
    template:
      Count: 1
    Users:
      Count: 1
  - Name: TeachOrg
    Domain: teachorg.example.com
    EnableNodeOUs: true
    template:
      Count: 1
    Users:
      Count: 1
  - Name: AdminOrg
    Domain: adminorg.example.com
    EnableNodeOUs: true
    template:
      Count: 1
    Users:
      Count: 1
           

運作以下指令

cryptogen generate --config=crypto-config.yaml
           

運作之後回會在目前目錄下生成crypto-config目錄

(二)生産網絡部署

 内部的具體檔案分布可以使用如下指令進行檢視

# 如未安裝tree,可以直接使用apt進行安裝
tree crypto-config
           

二、生成創世區塊

準備需要的配置檔案 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/example.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
​
    - &EduOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: EduOrgMSP
​
        # ID to load the MSP definition as
        ID: EduOrgMSP
​
        MSPDir: ./crypto-config/peerOrganizations/eduorg.example.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('EduOrgMSP.admin', 'EduOrgMSP.peer', 'EduOrgMSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('EduOrgMSP.admin', 'EduOrgMSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('EduOrgMSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('EduOrgMSP.peer')"
        AnchorPeers:
            - Host: peer.eduorg.example.com
              Port: 7051
​
    - &StuOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: StuOrgMSP
​
        # ID to load the MSP definition as
        ID: StuOrgMSP
​
        MSPDir: ./crypto-config/peerOrganizations/stuorg.example.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('StuOrgMSP.admin', 'StuOrgMSP.peer', 'StuOrgMSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('StuOrgMSP.admin', 'StuOrgMSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('StuOrgMSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('StuOrgMSP.peer')"
        AnchorPeers:
            - Host: peer.stuorg.example.com
              Port: 8051
​
    - &TeachOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: TeachOrgMSP
​
        # ID to load the MSP definition as
        ID: TeachOrgMSP
​
        MSPDir: ./crypto-config/peerOrganizations/teachorg.example.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('TeachOrgMSP.admin', 'TeachOrgMSP.peer', 'TeachOrgMSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('TeachOrgMSP.admin', 'TeachOrgMSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('TeachOrgMSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('TeachOrgMSP.peer')"
        AnchorPeers:
            - Host: peer.teachorg.example.com
              Port: 9051
    
    - &AdminOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: AdminOrgMSP
​
        # ID to load the MSP definition as
        ID: AdminOrgMSP
​
        MSPDir: ./crypto-config/peerOrganizations/adminorg.example.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('AdminOrgMSP.admin', 'AdminOrgMSP.peer', 'AdminOrgMSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('AdminOrgMSP.admin', 'AdminOrgMSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('AdminOrgMSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('AdminOrgMSP.peer')"
        AnchorPeers:
            - Host: peer.adminorg.example.com
              Port: 10051
​
################################################################################
#
#   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
    OrdererType: solo
    # 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:
        - orderer.example.com:7050
​
    # EtcdRaft:
    #     Consenters:
    #     - Host: orderer.example.com
    #       Port: 7050
    #       ClientTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
    #       ServerTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.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:
​
    FourOrgsChannel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *EduOrg
                - *StuOrg
                - *TeachOrg
                - *AdminOrg
            Capabilities:
                <<: *ApplicationCapabilities
​
    FourOrgsApplicationGenesis:
        <<: *ChannelDefaults
        Capabilities:
            <<: *ChannelCapabilities
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities: *OrdererCapabilities
        #Application:
        #   <<: *ApplicationDefaults
        #   Organizations:
        #       - *EduOrg
        #       - *StuOrg
        #       - *TeachOrg
        #       - *AdminOrg
        #   Capabilities: *ApplicationCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *EduOrg
                    - *StuOrg
                    - *TeachOrg
                    - *AdminOrg
           

三、建立系統通道

運作以下指令生成創世區塊 genesis.block

# 建立系統通道
configtxgen -profile [GenesisName] -outputBlock ./channel-artifacts/genesis.block -channelID [channel name]
           
(二)生産網絡部署

四、建立應用通道

運作如下指令,生成 channel.tx

# 建立應用通道
configtxgen -profile [your channel name in 'Profiles'] -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
           
(二)生産網絡部署

五、更新錨節點

使用如下指令,生成各組織(Org)的tx檔案

# 更新錨節點
configtxgen -outputAnchorPeersUpdate ./channel-artifacts/EduOrgMSPanchors.tx -profile [channel name] -channelID mychannel -asOrg [MSP Name]
           
  • (二)生産網絡部署
  • (二)生産網絡部署
  • (二)生産網絡部署
  • (二)生産網絡部署
至此在 channel-artifacts目錄下已生成如下檔案
(二)生産網絡部署

六、啟動網絡

編寫docker-compose.yaml

version: '2'
​
volumes:
  orderer.example.com:
  peer.eduorg.example.com:
  peer.stuorg.example.com:
  peer.teachorg.example.com:
  peer.adminorg.example.com:
  
networks:
  net_base:
  
services:
  orderer.example.com:
    container_name: orderer.example.com
    image: hyperledger/fabric-orderer:latest
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_LISTENPORT=7050
      - ORDERER_GENERAL_BOOTSTRAPMETHOD=file
      - ORDERER_GENERAL_BOOTSTRAPFILE=/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_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]
    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/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
      - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
      - orderer.example.com:/var/hyperledger/production/orderer
    ports:
      - 7050:7050
    networks:
      - net_base
  
  peer.eduorg.example.com:
    container_name: peer.eduorg.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer.eduorg.example.com
      - CORE_PEER_ADDRESS=peer.eduorg.example.com:7051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:7051
      - CORE_PEER_CHAINCODEADDRESS=peer.eduorg.example.com:7052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer.eduorg.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer.eduorg.example.com:7051
      - CORE_PEER_LOCALMSPID=EduOrgMSP
      - FABRIC_LOGGING_SPEC=INFO
      - 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
      - CORE_CHAINCODE_EXECUTETIMEOUT=300s
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/eduorg.example.com/users/[email protected]/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls:/etc/hyperledger/fabric/tls
      - peer.eduorg.example.com:/var/hyperledger/production
    ports:
      - 7051:7051
      - 7052:7052
      - 7053:7053
    networks:
      - net_base
      
  peer.stuorg.example.com:
    container_name: peer.stuorg.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer.stuorg.example.com
      - CORE_PEER_ADDRESS=peer.stuorg.example.com:8051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:8051
      - CORE_PEER_CHAINCODEADDRESS=peer.stuorg.example.com:8052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:8052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer.stuorg.example.com:8051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer.stuorg.example.com:8051
      - CORE_PEER_LOCALMSPID=StuOrgMSP
      - FABRIC_LOGGING_SPEC=INFO
      - 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
      - CORE_CHAINCODE_EXECUTETIMEOUT=300s
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/stuorg.example.com/users/[email protected]/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls:/etc/hyperledger/fabric/tls
      - peer.stuorg.example.com:/var/hyperledger/production
    ports:
      - 8051:8051
      - 8052:8052
      - 8053:8053
    networks:
      - net_base
      
  peer.teachorg.example.com:
    container_name: peer.teachorg.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer.teachorg.example.com
      - CORE_PEER_ADDRESS=peer.teachorg.example.com:9051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:9051
      - CORE_PEER_CHAINCODEADDRESS=peer.teachorg.example.com:9052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:9052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer.teachorg.example.com:9051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer.teachorg.example.com:9051
      - CORE_PEER_LOCALMSPID=TeachOrgMSP
      - FABRIC_LOGGING_SPEC=INFO
      - 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
      - CORE_CHAINCODE_EXECUTETIMEOUT=300s
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/teachorg.example.com/users/[email protected]/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls:/etc/hyperledger/fabric/tls
      - peer.teachorg.example.com:/var/hyperledger/production
    ports:
      - 9051:9051
      - 9052:9052
      - 9053:9053
    networks:
      - net_base
      
  peer.adminorg.example.com:
    container_name: peer.adminorg.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer.adminorg.example.com
      - CORE_PEER_ADDRESS=peer.adminorg.example.com:10051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:10051
      - CORE_PEER_CHAINCODEADDRESS=peer.adminorg.example.com:10052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:10052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.adminorg.example.com:10051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer.adminorg.example.com:10051
      - CORE_PEER_LOCALMSPID=AdminOrgMSP
      - FABRIC_LOGGING_SPEC=INFO
      - 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
      - CORE_CHAINCODE_EXECUTETIMEOUT=300s
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/adminorg.example.com/users/[email protected]/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls:/etc/hyperledger/fabric/tls
      - peer.adminorg.example.com:/var/hyperledger/production
    ports:
      - 10051:10051
      - 10052:10052
      - 10053:10053
    networks:
      - net_base
  
  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=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli1
      - CORE_PEER_ADDRESS=peer.eduorg.example.com:7051
      - CORE_PEER_LOCALMSPID=EduOrgMSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/eduorg.example.com/peers/peer.eduorg.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/eduorg.example.com/peers/peer.eduorg.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/eduorg.example.com/peers/peer.eduorg.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/eduorg.example.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/go/:/opt/gopath/src/github.com/hyperledger/multiple-deployment/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
    depends_on:
      - peer.eduorg.example.com
      - peer.stuorg.example.com
      - peer.teachorg.example.com
      - peer.adminorg.example.com
      - orderer.example.com
    networks:
      - net_base
  
  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=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli2
      - CORE_PEER_ADDRESS=peer.stuorg.example.com:8051
      - CORE_PEER_LOCALMSPID=StuOrgMSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/stuorg.example.com/peers/peer.stuorg.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/stuorg.example.com/peers/peer.stuorg.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/stuorg.example.com/peers/peer.stuorg.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/stuorg.example.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/go/:/opt/gopath/src/github.com/hyperledger/multiple-deployment/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
    depends_on:
      - peer.eduorg.example.com
      - peer.stuorg.example.com
      - peer.teachorg.example.com
      - peer.adminorg.example.com
      - orderer.example.com
    networks:
      - net_base
  
  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=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli3
      - CORE_PEER_ADDRESS=peer.teachorg.example.com:9051
      - CORE_PEER_LOCALMSPID=TeachOrgMSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/teachorg.example.com/peers/peer.teachorg.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/teachorg.example.com/peers/peer.teachorg.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/teachorg.example.com/peers/peer.teachorg.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/teachorg.example.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/go/:/opt/gopath/src/github.com/hyperledger/multiple-deployment/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
    depends_on:
      - peer.eduorg.example.com
      - peer.stuorg.example.com
      - peer.teachorg.example.com
      - peer.adminorg.example.com
      - orderer.example.com
    networks:
      - net_base
      
  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=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli4
      - CORE_PEER_ADDRESS=peer.adminorg.example.com:10051
      - CORE_PEER_LOCALMSPID=AdminOrgMSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/adminorg.example.com/peers/peer.adminorg.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/adminorg.example.com/peers/peer.adminorg.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/adminorg.example.com/peers/peer.adminorg.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/adminorg.example.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/go/:/opt/gopath/src/github.com/hyperledger/multiple-deployment/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
    depends_on:
      - peer.eduorg.example.com
      - peer.stuorg.example.com
      - peer.teachorg.example.com
      - peer.adminorg.example.com
      - orderer.example.com
    networks:
      - net_base
           

使用docker-compose啟動網絡

docker-compose up -d
           
(二)生産網絡部署

 通過docker檢視運作情況 

  • 異常
(二)生産網絡部署
  • 成功
(二)生産網絡部署

 通過docker-compose檢視運作情況

  • 成功
(二)生産網絡部署

期間遇到的錯誤

(二)生産網絡部署
  • 自己手寫下來之後,無論怎麼修正都沒辦法解決,最後根據官方測試網絡的configtx.yaml模闆修改後,執行成功。
啟動網絡時出現下面的錯誤
  • Failed validating bootstrap block: the block isn't a system channel block because it lacks ConsortiumsConfig
  • 該錯誤表示在啟動網絡時,驗證引導塊失敗,因為它缺少 ConsortiumsConfig。這通常是由于系統通道塊中缺少配置資訊造成的。請檢查系統通道塊的配置資訊是否完整,如果有缺失的話請補充完整。
0001 ERRO [main] InitCmd -> Cannot run peer because could not load a valid signer certificate from directory /etc/hyperledger/fabric/msp/signcerts: stat /etc/hyperledger/fabric/msp/signcerts: no such file or directory
  • 參考了官方文檔發現所需簽名檔案的真正位置需要改索引到每個組織内Admin使用者之下的msp目錄,具體修改位置如下
    • (二)生産網絡部署
每一個不曾起舞的日子,都是對生命的辜負。

繼續閱讀