zoukankan      html  css  js  c++  java
  • 构建第二个通道--fabric--release-1.4

    首先参考之前的博文进入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="}

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

    作者:mhly

    博客:https://www.cnblogs.com/mhly

    本文采用BY-NC-SA许可协议,转载请注明出处

  • 相关阅读:
    JS如何获取并操作iframe中的元素?
    CSS(14)元素定位
    C#基础 [01] 从Hello World 开始
    CSS(15)浮动
    C#基础 [05] 类和对象
    关于Visual Studio 2010 编辑器的一些设置
    Ext JS(1)Ext JS简介
    C#基础 [03] 类型和成员
    Python中基本数据类型的学习
    Python:集合与字符串格式化
  • 原文地址:https://www.cnblogs.com/mhly/p/13406216.html
Copyright © 2011-2022 走看看