企业级区块链-HyperLeger Fabric v1.0.0 Fisrt Network详解

First Network详解


  • 使用cryptogen加密工具为网络链中相应节点的加密文件,以便各节点安全通讯生成证书和密钥(certs and keys)到/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network/crypto-config目录


[root@huangzhenhua first-network]# ../bin/cryptogen generate --config=./crypto-config.yaml

org1.example.com

org2.example.com


  • configtxgen工具需要使用configtx.yaml配置文件,设置configtx.yaml文件目录为PWD

  • 使用configtxgen工具为共识(orderer)节点生成原始块


[root@huangzhenhua first-network]# export FABRIC_CFG_PATH=$PWD

[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

2018-02-06 14:45:05.072 CST [common/configtx/tool] main -> INFO 001 Loading configuration

2018-02-06 14:45:05.101 CST [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block

2018-02-06 14:45:05.104 CST [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block


  • 创建通道配置事务--设置CHANNEL_NAME环境变量

  • 创建通道配置事务--创建通道交易配置文件


[root@huangzhenhua first-network]# export CHANNEL_NAME=mychannel

[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME

2018-02-06 14:45:46.644 CST [common/configtx/tool] main -> INFO 001 Loading configuration

2018-02-06 14:45:46.648 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx

2018-02-06 14:45:46.648 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx


  • 创建通道配置事务--创建机构1的通道交易配置文件


[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP

2018-02-06 14:46:03.190 CST [common/configtx/tool] main -> INFO 001 Loading configuration

2018-02-06 14:46:03.195 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update

2018-02-06 14:46:03.196 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update


  • 创建通道配置事务--创建机构2的通道交易配置文件


[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

2018-02-06 14:46:12.802 CST [common/configtx/tool] main -> INFO 001 Loading configuration

2018-02-06 14:46:12.808 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update

2018-02-06 14:46:12.808 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update


  • 开启Fabric网络链


[root@huangzhenhua first-network]# CHANNEL_NAME=$CHANNEL_NAME docker-compose -f docker-compose-cli.yaml up -d

Creating peer0.org1.example.com ... done

Creating cli ... done

Creating peer0.org2.example.com ... 

Creating peer0.org1.example.com ... 

Creating peer1.org2.example.com ... 

Creating peer1.org1.example.com ... 

Creating cli ... 


  • 进入peer节点,默认进入peer0.org1节点(具体配置请看docker-compose-cli.yaml中 environment)


[root@huangzhenhua first-network]# docker exec -it cli bash


  • 设置CHANNEL_NAME环境变量,并创建channel


root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# export CHANNEL_NAME=mychannel

root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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

2018-02-06 06:47:14.966 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP

2018-02-06 06:47:14.966 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity

2018-02-06 06:47:15.106 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized

2018-02-06 06:47:15.106 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP

2018-02-06 06:47:15.106 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity

2018-02-06 06:47:15.106 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP

2018-02-06 06:47:15.107 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity

2018-02-06 06:47:15.107 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267314D53501280062D...53616D706C65436F6E736F727469756D 

2018-02-06 06:47:15.107 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 9AD72083789E541ED07EEE0B5B42BD352E0562ECDFF344C15054B18DC556A522 

2018-02-06 06:47:15.108 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP

2018-02-06 06:47:15.108 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity

2018-02-06 06:47:15.108 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP

2018-02-06 06:47:15.108 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity

2018-02-06 06:47:15.108 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A0608F39EE5D30522

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值