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许可协议,转载请注明出处

  • 相关阅读:
    Spring AOP (下)
    C#和C++性能差距巨大,在高耗能和低性能设备上强烈建议不要使用
    [MOSS]Microsoft Office SharePoint Server 2007 安装与配置
    [MOSS]使用Microsoft Office SharePoint Server 2007过程中遇到的问题与解决方法
    博客索引
    springweb里面的post和get请求
    Nginx 之在windows下的安装与启动
    某外企招聘程序员部分面试题,求作答!!!
    解决Asp.net Web网站发布到服务器上运行时,某界面传参数过多,造成的“此请求的查询字符串的长度超过配置的 maxQueryStringLength 值”错误。
    使用”Sql Server 代理“下的”作业“定时执行期望的任务
  • 原文地址:https://www.cnblogs.com/mhly/p/13406216.html
Copyright © 2011-2022 走看看