创建通道使用的命令

[root@localhost test-network]# ./network.sh createChannel

创建通道使用的命令用到了以下一些工具,如下图所示:

下面是创建通道时,对输出信息的一些注释。看了一些参考文档,感觉上输出的信息中有一些命令没在里面,可见参考文档,更加详细,目前只能理解这些,以后了解更多再进行补充。

[root@localhost test-network]# ./network.sh createChannel
Creating channel 'mychannel'.
If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb'
Generating channel genesis block 'mychannel.block'
/home/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/bin/configtxgen
# 命令:生成创世区块mychannel.block文件
+ configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/mychannel.block -channelID mychannel
2021-11-01 01:05:10.404 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-11-01 01:05:10.409 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2021-11-01 01:05:10.409 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
2021-11-01 01:05:10.409 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml
2021-11-01 01:05:10.411 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2021-11-01 01:05:10.411 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Creating application channel genesis block
2021-11-01 01:05:10.411 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
Creating channel mychannel
Using organization 1
# 命令:创建通道mychannel
+ osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:7053 --ca-file /home/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --client-cert /home/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt --client-key /home/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
+ res=0
Status: 201
{"name": "mychannel","url": "/participation/v1/channels/mychannel","consensusRelation": "consenter","status": "active","height": 1
}Channel 'mychannel' created
Joining org1 peer to the channel...
Using organization 1
# 命令:将peer节点(组织1)加入到通道中
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2021-11-01 01:05:16.526 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-11-01 01:05:16.541 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Joining org2 peer to the channel...
Using organization 2
# 命令:将peer节点(组织2)加入到通道中
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2021-11-01 01:05:19.581 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-11-01 01:05:19.594 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Setting anchor peer for org1...
Using organization 1
Fetching channel config for channel mychannel
#设置org1管理员
Using organization 1
Fetching the most recent configuration block for the channel
# 命令:获取最新的通道配置区块
+ peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2021-10-31 17:05:19.756 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-10-31 17:05:19.757 UTC [cli.common] readBlock -> INFO 002 Received block: 0
2021-10-31 17:05:19.757 UTC [channelCmd] fetch -> INFO 003 Retrieving last config block: 0
2021-10-31 17:05:19.758 UTC [cli.common] readBlock -> INFO 004 Received block: 0
# 以上返回的是通道创世区块block 0# 将区块从protobuf格式转为json格式,并且生成一个隔离的json文件Org1MSPconfig.json
Decoding config block to JSON and isolating config to Org1MSPconfig.json
# 命令:将区块从protobuf格式转为json格式,方便读写
+ jq '.data.data[0].payload.data.config'
+ configtxlator proto_decode --input config_block.pb --type common.Block# 生成org1锚节点,并将org1锚节点加入到通道配置文件
Generating anchor peer update transaction for Org1 on channel mychannel
# 命令:将org1锚节点加入到通道配置文件
+ jq '.channel_group.groups.Application.groups.Org1MSP.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "peer0.org1.example.com","port": 7051}]},"version": "0"}}' Org1MSPconfig.json
# 命令:原来的和修改过的配置文件由json格式转换到protobuf格式
+ configtxlator proto_encode --input Org1MSPconfig.json --type common.Config
+ configtxlator proto_encode --input Org1MSPmodified_config.json --type common.Config
# 命令:核算原来的和修改过的配置文件有什么不同
+ configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb
+ configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate
+ jq .
++ cat config_update.json
+ echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":{' '"channel_id":' '"mychannel",' '"isolated_data":' '{},' '"read_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org1MSP":' '{' '"groups":' '{},' '"mod_policy":' '"",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '},' '"write_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org1MSP":' '{' '"groups":' '{},' '"mod_policy":' '"Admins",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"AnchorPeers":' '{' '"mod_policy":' '"Admins",' '"value":' '{' '"anchor_peers":' '[' '{' '"host":' '"peer0.org1.example.com",' '"port":' 7051 '}' ']' '},' '"version":' '"0"' '},' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"1"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '}}}}'
+ configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope
2021-10-31 17:05:19.934 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-10-31 17:05:19.943 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peer set for org 'Org1MSP' on channel 'mychannel'# 设置org2锚节点与设置org1锚节点步骤相同
Setting anchor peer for org2...
Using organization 2
Fetching channel config for channel mychannel
Using organization 2
Fetching the most recent configuration block for the channel
+ peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2021-10-31 17:05:20.193 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-10-31 17:05:20.195 UTC [cli.common] readBlock -> INFO 002 Received block: 1
2021-10-31 17:05:20.195 UTC [channelCmd] fetch -> INFO 003 Retrieving last config block: 1
2021-10-31 17:05:20.196 UTC [cli.common] readBlock -> INFO 004 Received block: 1
Decoding config block to JSON and isolating config to Org2MSPconfig.json
+ configtxlator proto_decode --input config_block.pb --type common.Block
+ jq '.data.data[0].payload.data.config'
Generating anchor peer update transaction for Org2 on channel mychannel
+ jq '.channel_group.groups.Application.groups.Org2MSP.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "peer0.org2.example.com","port": 9051}]},"version": "0"}}' Org2MSPconfig.json
+ configtxlator proto_encode --input Org2MSPconfig.json --type common.Config
+ configtxlator proto_encode --input Org2MSPmodified_config.json --type common.Config
+ configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb
+ configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate
+ jq .
++ cat config_update.json
+ echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":{' '"channel_id":' '"mychannel",' '"isolated_data":' '{},' '"read_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org2MSP":' '{' '"groups":' '{},' '"mod_policy":' '"",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '},' '"write_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org2MSP":' '{' '"groups":' '{},' '"mod_policy":' '"Admins",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"AnchorPeers":' '{' '"mod_policy":' '"Admins",' '"value":' '{' '"anchor_peers":' '[' '{' '"host":' '"peer0.org2.example.com",' '"port":' 9051 '}' ']' '},' '"version":' '"0"' '},' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"1"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '}}}}'
+ configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope
2021-10-31 17:05:20.399 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-10-31 17:05:20.411 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peer set for org 'Org2MSP' on channel 'mychannel'
Channel 'mychannel' joined

参考文档:

https://blog.csdn.net/zhanglingge/article/details/106808435

Fabric创建通道流程解析_@毛宏斌-CSDN博客_fabric创建通道

Fabric v2.3测试网络 - 创建通道 返回结果分析相关推荐

  1. Fabric v2.3 测试网络 - 脚本分析(二)- 创建通道createChannel.sh解析

    本文针对创建通道脚本createChannel.sh进行分析,此脚本被创建测试网络network.sh脚本在执行命令./network.sh createChannel时调用 调用脚本及参数默认值命令 ...

  2. 3.Hyperledger Fabric v2.0 CA组件

    Hyperledger Fabric v2.0 CA组件 目的: 通过CA服务生成msp证书和tls证书,并启动fabric网络 由于使用CA生成证书时,需要注册为各个组织生成证书,为了便于理解,所以 ...

  3. fabric2.3.2 test-network测试网络搭建 超详细步骤

    搭建好fabric网络后的第一步一定是练习一下测试网络.如果需要ubuntu下安装fabric环境的可以看下面两篇文章: Ubuntu16.04+fabric1.4.3 (15条消息) fabric1 ...

  4. Fabric v2.3 手动模拟(一) - 测试网络./network.sh up命令创建自己的网络

    目录 0. 引言 1. 创建自己的网络目录 (1)进入fabric-samples目录 (2)创建文件夹test-network-myself(自己的网络目录) (3)进入test-network-m ...

  5. Hyperledger Fabric 环境搭建及Fabric 测试网络使用(区块链、联盟链)

    一篇博文体验Hyperledger Fabric区块链 系统环境(CentOS): [root@localhost ~]# cat /proc/version Linux version 3.10.0 ...

  6. Hyperledger Fabric2.3 环境搭建及Fabric 测试网络使用

    一.安装ubuntu20 Download Ubuntu Desktop | Download | Ubuntu 二.安装环境 参考: Prerequisites - hyperledger-fabr ...

  7. hyperledger fabric 2.3.3 测试网络

    教程 一.注意事项 确保通道名称应用以下限制: 仅包含小写 ASCII 字母数字.点"."和破折号"-" 少于 250 个字符 以字母开头 二.hyperled ...

  8. Fabric创建通道流程解析

    文章目录 一.命令行步骤 二.peer channel create 2.1 入口 2.2 发送创建通道的交易 2.3 获得该通道的创世块 2.4 Orderer侧处理逻辑 2.5 小结 三.peer ...

  9. Fabric 搭建测试网络并部署智能合约

    1.搭建网络: 详见博客 2.对Test Network的创建和关闭 cd ${HOME}/fabric-samples/test-network 创建网络: ./network.sh up关闭网络: ...

最新文章

  1. AUC是什么?AUC的的意义是什么?AUC的判断分类器优劣标准是什么?AUC如何计算?
  2. 五个指标看BCH,它距离“币圈金本位”还有多远?
  3. SpringBoot中Tomcat配置(学习SpringBoot实战)
  4. 数学--数论--HDU 12151七夕节 Plus (因子和线性筛)
  5. [转载]httpClient.execute抛Connection to refused异常问题
  6. UIKit框架各个类的简介
  7. python输出jpg_利用python实现.dcm格式图像转为.jpg格式
  8. NTV Media Server G3流媒体服务器搭建经验
  9. set UVA 11136 Hoax or what
  10. 如何使用kafka增加topic的备份数量,让业务更上一层楼
  11. 【收藏】Windows 8 Consumer Preview的108个运行命令及简要说明
  12. Linux误删C基本运行库libc.so.6处理方法
  13. windows xp输入法设置空白解决的方法
  14. qlistview 自定义控件_qlistview使用自定义模型的复选框
  15. “我被苹果人脸识别系统「坑」进了监狱”
  16. Js实现继承的6种方式
  17. 单机魔兽世界服务器显示不兼容,大芒果单机魔兽世界不能登陆怎么办?
  18. 计算机英语考虑是,计算机英语中单词privilege和permission的区别
  19. 边境的悍匪—机器学习实战:第十四章 使用卷积神经网络的深度计算机视觉
  20. C语言:字母金字塔(输入一个大写字母,输出从A到这个字母的金字塔

热门文章

  1. 通俗易懂的Kafka零拷贝机制
  2. 计算机内存五个区域,总结:计算机内存的五大区域
  3. scratch教程——弹球游戏
  4. php vip卡,vip.php
  5. Unity 相机被遮挡的判断与处理
  6. 【软件测试】软件测试随手记
  7. 【操作系统】第3章 内存管理
  8. xm-select的简单使用
  9. 有感于男人们的友谊和女人们的友谊
  10. 聊聊CVE漏洞编号和正式公开那些事