- 基于前期所安装的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/peers/peer.eduorg.example.com/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/peers/peer.stuorg.example.com/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/peers/peer.teachorg.example.com/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/peers/peer.adminorg.example.com/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/Admin@eduorg.example.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/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/Admin@stuorg.example.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/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/Admin@teachorg.example.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/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/Admin@adminorg.example.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/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目录,具体修改位置如下
使用cryptogen生成各组织的密钥证书时,出现peers目录缺失的情况
- 核查发现,crypto-config.yaml文件中的Template的开头字母误写成了小写,造成了读取失败,经过更改即可解决。
每一个不曾起舞的日子,都是对生命的辜负。