本系列文章:
第一章:九析带你完爆 hyperledger fabric - 快速上手 basic-network 样例
第二章:九析带你完爆 hyperledger fabric - 快速搭建 GO 环境
第三章:九析带你完爆 hyperledger fabric - 快速上手 first-network 样例
第四章:九析带你完爆 hyperledger fabric - 系统逻辑架构篇
第五章:九析带你完爆 hyperledger fabirc - 网络节点介绍
第六章: 九析带你轻松完爆 hyperledger fabric - 区块和区块链介绍
第七章: 九析带你轻松完爆 hyperledger fabric - 区块链防篡改机制
第八章:九析带你轻松完爆 hyperledger fabric - Couchdb 安装
第九章:九析带你轻松完爆 hyperledger fabric - NVM 和 Nodejs 安装
第十章:九析带你轻松完爆 hyperledger fabric - chaincode 生命周期介绍
第十一章: 九析带你轻松完爆 hyperledger fabric - 创建联盟
第十二章: 九析带你轻松完爆 hyperledger fabric - configtxlator 尝鲜
第十三章: 九析带你轻松完爆 hyperledger fabric - 创建静态组织
目录
1 前言
2 创建配置文件和目录
2.1 创建工作目录
2.2 创建必要目录
2.3 创建创世区块、通道、联盟资源文件
2.4 创建节点配置文件
2.5 创建 docker-compose.yaml 文件
3 生成证书
4 生成创世区块
5 生成通道交易文件
6 创建 Anchor 节点的 MSP 回话文件
7 初始化容器
8 创建通道
9 其他组织加入通道
10 小节
11 深入
11.1 生成新的通道交易文件
11.2 生成 Anchor 节点 MSP 文件
11.3 创建通道
1 前言
在上面的章节中,我们已经创建了联盟,下面将介绍如何创建组织。创建组织的方式可以分为两种:静态和动态。所谓静态就是在建立区块链网络前就已经在联盟下确定好组织了,在以后的业务发展过程中,不会再新增组织了;所谓动态就是随着业务的开展,会有新的组织要求加入进来,这时就不能重新停止区块链网络,然后修改配置文件,再启动建立,而是通过动态增量的方式添加。由于动态添加组织稍微难一些,我们将放在后续讲解。这节先介绍静态创建组织的方式。
需注意,本文所使用的 fabric 源码版本为 1.4.4。此外,为了简单和更容易理解,我们将使用自建脚本。本节会用到工具 configtxgen 和 cryptogen,所以确保这 2 个工具你都正确的安装和配置。如果你不会配置,请参考哥的第三章,不用谢。
2 创建配置文件和目录
2.1 创建工作目录
mkdir jiuxi
cd jiuxi
2.2 创建必要目录
这里的必要目录就是存放证书的目录和存放创世区块、通道交易文件、peer 主节点(Anchor)交易文件的目录:
mkdir crypto-config config
2.3 创建创世区块、通道、联盟资源文件
touch configtx.yaml
configtx.yaml 用来存放创世区块、联盟、通道、组织等配置信息,内容如下,根据内容可知,已经在配置阶段就完成了组织的创建:
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/jiuxi.org/msp
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.jiuxi.org/msp
AnchorPeers:
- Host: peer0.org1.jiuxi.org
Port: 11151
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/org2.jiuxi.org/msp
AnchorPeers:
- Host: peer0.org2.jiuxi.org
Port: 12151
- &Org3
Name: Org3MSP
ID: Org3MSP
MSPDir: crypto-config/peerOrganizations/org3.jiuxi.org/msp
AnchorPeers:
- Host: peer0.org3.jiuxi.org
Port: 13151
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.jiuxi.org:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Kafka:
Brokers:
- 127.0.0.1:9092
Organizations:
Application: &ApplicationDefaults
Organizations:
Profiles:
JiuxiOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
JiuxiConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
JiuxiChannel:
Consortium: JiuxiConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
- *Org3
2.4 创建节点配置文件
touch crypto-config.yaml
crypto-config.yaml 用来配置排序节点和 peer 节点,内容如下:
OrdererOrgs:
- Name: Orderer
Domain: jiuxi.org
Specs:
- Hostname: orderer
PeerOrgs:
- Name: Org1
Domain: org1.jiuxi.org
Template:
Count: 2
Users:
Count: 1
- Name: Org2
Domain: org2.jiuxi.org
Template:
Count: 2
Users:
Count: 1
- Name: Org3
Domain: org3.jiuxi.org
Template:
Count: 2
Users:
Count: 1
2.5 创建 docker-compose.yaml 文件
docker-compose.yaml 文件用来声明容器编排或者容器依赖关系,内容如下:
version: '2'
networks:
jiuxi:
services:
couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb
environment:
- COUCHDB_USER=
- COUCHDB_PASSWORD=
ports:
- 5984:5984
networks:
- jiuxi
orderer.jiuxi.org:
container_name: orderer.jiuxi.org
image: hyperledger/fabric-orderer
environment:
- FABRIC_LOGGING_SPEC=info
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
- 7050:7050
volumes:
- ./config/:/etc/hyperledger/configtx
- ./crypto-config/ordererOrganizations/jiuxi.org/orderers/orderer.jiuxi.org/:/etc/hyperledger/msp/orderer
- ./crypto-config/peerOrganizations/org1.jiuxi.org/peers/peer0.org1.jiuxi.org/:/etc/hyperledger/msp/peerOrg1
networks:
- jiuxi
peer0.org1.jiuxi.org:
container_name: peer0.org1.jiuxi.org
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.jiuxi.org
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.org1.jiuxi.org:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
ports:
- 11151:7051
- 11153:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.jiuxi.org/peers/peer0.org1.jiuxi.org/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.jiuxi.org/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.jiuxi.org
- couchdb
networks:
- jiuxi
peer1.org1.jiuxi.org:
container_name: peer1.org1.jiuxi.org
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org1.jiuxi.org
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer1.org1.jiuxi.org:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
ports:
- 11251:7051
- 11253:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.jiuxi.org/peers/peer1.org1.jiuxi.org/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.jiuxi.org/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.jiuxi.org
- couchdb
networks:
- jiuxi
peer0.org2.jiuxi.org:
container_name: peer0.org2.jiuxi.org
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org2.jiuxi.org
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.org2.jiuxi.org:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
ports:
- 12151:7051
- 12153:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org2.jiuxi.org/peers/peer0.org2.jiuxi.org/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org2.jiuxi.org/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.jiuxi.org
- couchdb
networks:
- jiuxi
peer1.org2.jiuxi.org:
container_name: peer1.org2.jiuxi.org
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org2.jiuxi.org
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer1.org2.jiuxi.org:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
ports:
- 12251:7051
- 12253:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org2.jiuxi.org/peers/peer1.org2.jiuxi.org/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org2.jiuxi.org/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.jiuxi.org
- couchdb
networks:
- jiuxi
peer0.org3.jiuxi.org:
container_name: peer0.org3.jiuxi.org
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org3.jiuxi.org
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org3MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.org3.jiuxi.org:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
ports:
- 13151:7051
- 13153:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org3.jiuxi.org/peers/peer0.org3.jiuxi.org/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org3.jiuxi.org/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.jiuxi.org
- couchdb
networks:
- jiuxi
peer1.org3.jiuxi.org:
container_name: peer1.org3.jiuxi.org
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org3.jiuxi.org
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org3MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer1.org3.jiuxi.org:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
ports:
- 13251:7051
- 13253:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org3.jiuxi.org/peers/peer1.org3.jiuxi.org/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org3.jiuxi.org/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.jiuxi.org
- couchdb
networks:
- jiuxi
cli:
container_name: cli
image: hyperledger/fabric-tools
tty: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- FABRIC_LOGGING_SPEC=info
- CORE_PEER_ID=cli
- CORE_PEER_ADDRESS=peer0.org1.jiuxi.org:11251
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.jiuxi.org/users/[email protected]/msp
- CORE_CHAINCODE_KEEPALIVE=10
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- ./../chaincode/:/opt/gopath/src/github.com/
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
networks:
- jiuxi
3 生成证书
cryptogen generate --config=./crypto-config.yaml
命令执行成功会在 crypto-config 目录下生成证书
4 生成创世区块
configtxgen -profile JiuxiOrdererGenesis -outputBlock ./config/genesis.block
执行成功会在 config 目录下生成创世区块 genesis.block。
5 生成通道交易文件
configtxgen -profile JiuxiChannel -outputCreateChannelTx ./config/channel1.tx -channelID channel1
命令执行成功会将通道交易文件生成在 config 目录下。
6 创建 Anchor 节点的 MSP 回话文件
configtxgen -profile JiuxiChannel -outputAnchorPeersUpdate ./config/channel1Org1MSPanchors.tx -channelID channel1 -asOrg Org1MSP
configtxgen -profile JiuxiChannel -outputAnchorPeersUpdate ./config/channel1Org2MSPanchors.tx -channelID channel1 -asOrg Org2MSP
7 初始化容器
启动 docker-compose.yaml 配置文件,生成容器:
docker-compose -f docker-compose.yaml up &
docker ps -a
启动成功后截图如下:
执行到此步骤已经完成了区块链搭建,orderer、peer、cli、couchdb 节点的启动,但是目前组织的 peer 节点还并没有处于通道之中,下一步就需要开始创建通道和将节点加入到通道中了。
8 创建通道
在 peer0.org1.jiuxi.org 节点上创建通道 channel1,通道创建成功后,会生成通道区块文件 .block,并将自身组织加入到通道中:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org peer channel create -o orderer.jiuxi.org:7050 -c channel1 -f /etc/hyperledger/configtx/channel1.tx
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org ls
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org peer channel join -b channel1.block
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org peer channel list
9 其他组织加入通道
上面只是 org1 组的 peer0 节点加入了通道,还需要将org1 和 org2 组织剩余的 peer 节点依次加入通道:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org peer channel fetch 0 channel1.block -o orderer.jiuxi.org:7050 -c channel1
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org ls
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org peer channel join -b channel1.block
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org peer channel list
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org peer channel fetch 0 channel1.block -o orderer.jiuxi.org:7050 -c channel1
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org ls
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org peer channel join -b channel1.block
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org peer channel list
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org peer channel fetch 0 channel1.block -o orderer.jiuxi.org:7050 -c channel1
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org ls
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org peer channel join -b channel1.block
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org peer channel list
10 小节
上面的步骤已经实现了创建联盟、创建静态组织(org1, org2, org3),其中每个组织都有 2 个 peer 节点,而且又创建了 ID 为 channel1 的通道,并把 org1 和 org2 的 2 个 peer 依次加入到该通道中。作为特殊,并没有将组织 org3 加入到通道中(当然你也可以加入,这里留给读者独爽)。下面再看看配置文件,理解一下:
JiuxiConsortium 就是自声明的联盟(联盟下静态定义了三个组织、JiuxiChannel 就是自声明的渠道(该渠道跟自声明联盟 Consortium 关联)。
11 深入
当然,你可以使用 org3 再创建一个通道,然后将其自身 2 个节点加入这个新的通道。相信你在理解上面的知识后,下面的操作简直容易到爆。步骤如下:
11.1 生成新的通道交易文件
configtxgen -profile JiuxiChannel -outputCreateChannelTx ./config/channel2.tx -channelID channel2
11.2 生成 Anchor 节点 MSP 文件
configtxgen -profile JiuxiChannel -outputAnchorPeersUpdate ./config/channel2Org3MSPanchors.tx -channelID channel2 -asOrg Org3MSP
11.3 创建通道
在 peer0.org3.jiuxi.org 节点上创建通道 channel2,并自身加入到通道 channel2:
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org peer channel create -o orderer.jiuxi.org:7050 -c channel2 -f /etc/hyperledger/configtx/channel2.tx
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org ls
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org peer channel join -b channel2.block
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org peer channel list
在 peer1.org3.jiuxi.org 节点也需要加入到通道 channel2 中:
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org peer channel fetch 0 channel2.block -o orderer.jiuxi.org:7050 -c channel2
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org ls
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org peer channel join -b channel2.block
docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org peer channel list
自此,九析带你轻松完爆 hyperledger fabirc 创建静态组织。