标签: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="}
后面可以使用链码测试该通道,待续~~
标签:previous color tools eve sam 容器 min too -o
原文地址:https://www.cnblogs.com/mhly/p/13406216.html