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





 

你可能感兴趣的:(fabric)