码迷,mamicode.com
首页 > 其他好文 > 详细

构建第二个通道--fabric--release-1.4

时间:2020-07-30 21:56:05      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:previous   color   tools   eve   sam   容器   min   too   -o   

首先参考之前的博文进入first-network目录下启动网络

创建一个应用通道的配置交易

设置环境变量CHANNEL_NAME

export CHANNEL_NAME=mychannel2 

 

指定使用 configtx.yaml 配置文件中的 TwoOrgsChannel 模板,来生成新建通道的配置交易文件

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME

输出如下

2020-07-30 16:32:16.714 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-07-30 16:32:16.815 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-07-30 16:32:16.915 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2020-07-30 16:32:16.915 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-07-30 16:32:16.915 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2020-07-30 16:32:16.918 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 Writing new channel tx

 

生成锚节点配置更新文件

基于 configtx.yaml 配置文件生成新建通道文件,每个组织都需要分别生成(注意指定对应的组织名称)

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

 

创建通道

进入CLI容器

docker exec -it cli bash

 

设置环境变量

export CHANNEL_NAME=mychannel2

 

创建通道

peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

 

加入通道

peer channel join -b mychannel2.block -o orderer:7050

 

更新锚节点

# 使用Org1的管理员身份更新锚节点配置
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

# 使用Org2的管理员身份更新锚节点配置
# 切换身份
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
CORE_PEER_LOCALMSPID="Org2MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt # 更新锚节点 peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

 

查看当前通道

peer channel list
# 输出如下
2020-07-30 08:36:37.687 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Channels peers has joined: 
mychannel
mychannel2

# 获取指定通道的区块链信息
peer channel getinfo -c mychannel2
# 输出如下
2020-07-30 08:42:31.512 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Blockchain info: {"height":3,"currentBlockHash":"2RHrxGUkfbBIEwzTkVKaTNxyTJAbnPemzcTUJesMJc8=","previousBlockHash":"pWmuHk/uj5vl2qlO3dGc2da2zibZUZbOYnwqhXpLz1I="}

 

后面可以使用链码测试该通道,待续~~

构建第二个通道--fabric--release-1.4

标签:previous   color   tools   eve   sam   容器   min   too   -o   

原文地址:https://www.cnblogs.com/mhly/p/13406216.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!