353-fabric创建通道














网络启动之后
1.客户端cli节点
2.peer节点
3.orderer节点

要做的事情:
1.创建通道
2.将所有组织的所有节点加入到创建的通道中
3.给所有的节点(peer)安装链码
4.链码初始化
5.链码调用






peer操作
我们先进入客户端容器
docker exec -it cli bash

如果我们把cli的名字改成了cli_fabric
那么就是
docker exec -it cli_fabric bash

abc@abc:~/workspace/fabric$ docker exec -it cli_fabric bash
root@6ef5786be7da:/opt/gopath/src/github.com/hyperledger/fabric/peer# 








我们看一下这个目录下面有什么
root@6ef5786be7da:/opt/gopath/src/github.com/hyperledger/fabric/peer# ls
channel-artifacts  crypto  scripts









然后创建通道
peer channel create

常用参数有:
1.-o --orderer		orderer节点的地址,orderer.abc.com
2.-c --channelID    通道名, abcchannel
3.-f --file			指定通过configtxgen生成的文件,channel.tx
4.--tls				是否对数据加密
5.--cafile			orderer证书

然后我们来执行一下
peer channel create -o orderer.abc.com:7050 --tls true --cafile $tlsfile -c abcchannel -f ./channel-artifacts/channel.tx

peer channel create 
-o 			orderer.abc.com:7050
--tls		true
--cafile	$tlsfile
-c 			abcchannel
-f 			./channel-artifacts/channel.tx 







docker exec -it cli bash
我们先保存一个tlsfile
tlsfile=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/abc.com/orderers/orderer.abc.com/msp/tlscacerts/tlsca.abc.com-cert.pem




peer channel create -o orderer.abc.com:7050 --tls true --cafile $tlsfile -c abcchannel -f ./channel-artifacts/channel.tx





然后我们看下输出结果
root@d71c17036f79:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel create -o orderer.abc.com:7050 --tls true --cafile $tlsfile -c abcchannel -f ./channel-artifacts/channel.tx
2019-04-14 15:04:23.264 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-04-14 15:04:23.292 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
2019-04-14 15:04:23.326 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2019-04-14 15:04:23.531 UTC [cli/common] readBlock -> INFO 004 Received block: 0





然后我们看下目录
root@d71c17036f79:/opt/gopath/src/github.com/hyperledger/fabric/peer# ls
channel-artifacts  crypto  abcchannel.block












然后我们加入通道
peer channel join
常用参数:
-b --blockpath


我们执行一下,并且看一下输出结果

root@d71c17036f79:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel join -b ./abcchannel.block 
2019-04-14 15:12:24.252 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-04-14 15:12:24.433 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
root@d71c17036f79:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel list
2019-04-14 15:12:29.569 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Channels peers has joined: 
abcchannel





 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值