栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

fabric createChannel创建通道

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

fabric createChannel创建通道

[root@iZ8vbjcbks7pzj9po96hleZ test-network]# ./network.sh createChannel
Using docker and docker-compose
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
Network Running Already
Using docker and docker-compose
Generating channel genesis block ‘mychannel.block’
/opt/fabric/scripts/fabric-samples/bin/configtxgen

  • configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/mychannel.block -channelID mychannel
    2022-06-08 14:48:23.792 CST 0001 INFO [common.tools.configtxgen] main -> Loading configuration
    2022-06-08 14:48:23.799 CST 0002 INFO [common.tools.configtxgen.localconfig] completeInitialization -> orderer type: etcdraft
    2022-06-08 14:48:23.799 CST 0003 INFO [common.tools.configtxgen.localconfig] completeInitialization -> Orderer.EtcdRaft.Options unset, setting to tick_interval:“500ms” election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
    2022-06-08 14:48:23.799 CST 0004 INFO [common.tools.configtxgen.localconfig] Load -> Loaded configuration: /opt/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml
    2022-06-08 14:48:23.800 CST 0005 INFO [common.tools.configtxgen] doOutputBlock -> Generating genesis block
    2022-06-08 14:48:23.800 CST 0006 INFO [common.tools.configtxgen] doOutputBlock -> Creating application channel genesis block
    2022-06-08 14:48:23.800 CST 0007 INFO [common.tools.configtxgen] doOutputBlock -> Writing genesis block

  • res=0
    Creating channel mychannel
    Using organization 1

  • osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:7053 --ca-file /opt/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem --client-cert /opt/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt --client-key /opt/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 channel join -b ./channel-artifacts/mychannel.block
  • res=0
    2022-06-08 14:48:29.863 CST 0001 INFO [channelCmd] InitCmdFactory -> Endorser and orderer connections initialized
    2022-06-08 14:48:29.881 CST 0002 INFO [channelCmd] executeJoin -> Successfully submitted proposal to join channel
    Joining org2 peer to the channel…
    Using organization 2
  • peer channel join -b ./channel-artifacts/mychannel.block
  • res=0
    2022-06-08 14:48:32.920 CST 0001 INFO [channelCmd] InitCmdFactory -> Endorser and orderer connections initialized
    2022-06-08 14:48:32.937 CST 0002 INFO [channelCmd] executeJoin -> Successfully submitted proposal to join channel
    Setting anchor peer for org1…
    Using organization 1
    Fetching channel config for channel mychannel
    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/tlsca/tlsca.example.com-cert.pem
    2022-06-08 06:48:33.046 UTC 0001 INFO [channelCmd] InitCmdFactory -> Endorser and orderer connections initialized
    2022-06-08 06:48:33.048 UTC 0002 INFO [cli.common] readBlock -> Received block: 0
    2022-06-08 06:48:33.048 UTC 0003 INFO [channelCmd] fetch -> Retrieving last config block: 0
    2022-06-08 06:48:33.049 UTC 0004 INFO [cli.common] readBlock -> Received block: 0
    Decoding config block to JSON and isolating config to Org1MSPconfig.json
  • configtxlator proto_decode --input config_block.pb --type common.Block --output config_block.json
  • jq ‘.data.data[0].payload.data.config’ config_block.json
    Generating anchor peer update transaction for Org1 on channel mychannel
  • 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
  • configtxlator proto_encode --input Org1MSPconfig.json --type common.Config --output original_config.pb
  • configtxlator proto_encode --input Org1MSPmodified_config.json --type common.Config --output modified_config.pb
  • configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb --output config_update.pb
  • configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate --output config_update.json
  • 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 --output Org1MSPanchors.tx
    2022-06-08 06:48:33.210 UTC 0001 INFO [channelCmd] InitCmdFactory -> Endorser and orderer connections initialized
    2022-06-08 06:48:33.218 UTC 0002 INFO [channelCmd] update -> Successfully submitted channel update
    Anchor peer set for org ‘Org1MSP’ on channel ‘mychannel’
    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/tlsca/tlsca.example.com-cert.pem
    2022-06-08 06:48:33.328 UTC 0001 INFO [channelCmd] InitCmdFactory -> Endorser and orderer connections initialized
    2022-06-08 06:48:33.330 UTC 0002 INFO [cli.common] readBlock -> Received block: 1
    2022-06-08 06:48:33.330 UTC 0003 INFO [channelCmd] fetch -> Retrieving last config block: 1
    2022-06-08 06:48:33.331 UTC 0004 INFO [cli.common] readBlock -> Received block: 1
  • configtxlator proto_decode --input config_block.pb --type common.Block --output config_block.json
    Decoding config block to JSON and isolating config to Org2MSPconfig.json
  • jq ‘.data.data[0].payload.data.config’ config_block.json
    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 --output original_config.pb
  • configtxlator proto_encode --input Org2MSPmodified_config.json --type common.Config --output modified_config.pb
  • configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb --output config_update.pb
  • configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate --output config_update.json
  • 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 --output Org2MSPanchors.tx
    2022-06-08 06:48:33.505 UTC 0001 INFO [channelCmd] InitCmdFactory -> Endorser and orderer connections initialized
    2022-06-08 06:48:33.513 UTC 0002 INFO [channelCmd] update -> Successfully submitted channel update
    Anchor peer set for org ‘Org2MSP’ on channel ‘mychannel’
    Channel ‘mychannel’ joined
    [root@iZ8vbjcbks7pzj9po96hleZ test-network]#
    [root@iZ8vbjcbks7pzj9po96hleZ test-network]#
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/963416.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号