2017-09-01

版权声明:本文为博主原创文章,转载注明“龙棠博客”字样和原文链接。

获取镜像

#Docker内地镜像源设置,Docker安装参见本博其它文章
#更新镜像到1.0.1版本
docker rmi hyperledger/fabric-tools:latest
docker rmi hyperledger/fabric-couchdb:latest
docker rmi hyperledger/fabric-kafka:latest
docker rmi hyperledger/fabric-zookeeper:latest
docker rmi hyperledger/fabric-orderer:latest
docker rmi hyperledger/fabric-peer:latest
docker rmi hyperledger/fabric-ca:latest
docker rmi hyperledger/fabric-ccenv:latest

docker pull hyperledger/fabric-tools:x86_64-1.0.1
docker pull hyperledger/fabric-couchdb:x86_64-1.0.1
docker pull hyperledger/fabric-kafka:x86_64-1.0.1
docker pull hyperledger/fabric-zookeeper:x86_64-1.0.1
docker pull hyperledger/fabric-orderer:x86_64-1.0.1
docker pull hyperledger/fabric-peer:x86_64-1.0.1
docker pull hyperledger/fabric-ca:x86_64-1.0.1
docker pull hyperledger/fabric-ccenv:x86_64-1.0.1
docker pull hyperledger/fabric-baseos:x86_64-0.3.2

docker tag hyperledger/fabric-tools:x86_64-1.0.1 hyperledger/fabric-tools:latest
docker tag hyperledger/fabric-couchdb:x86_64-1.0.1 hyperledger/fabric-couchdb:latest
docker tag hyperledger/fabric-kafka:x86_64-1.0.1 hyperledger/fabric-kafka:latest
docker tag hyperledger/fabric-zookeeper:x86_64-1.0.1 hyperledger/fabric-zookeeper:latest
docker tag hyperledger/fabric-orderer:x86_64-1.0.1 hyperledger/fabric-orderer:latest
docker tag hyperledger/fabric-peer:x86_64-1.0.1 hyperledger/fabric-peer:latest
docker tag hyperledger/fabric-ca:x86_64-1.0.1 hyperledger/fabric-ca:latest
docker tag hyperledger/fabric-ccenv:x86_64-1.0.1 hyperledger/fabric-ccenv:latest

#原来
docker tag hyperledger/fabric-tools:x86_64-1.0.0 hyperledger/fabric-tools:latest
docker tag hyperledger/fabric-couchdb:x86_64-1.0.0 hyperledger/fabric-couchdb:latest
docker tag hyperledger/fabric-kafka:x86_64-1.0.0 hyperledger/fabric-kafka:latest
docker tag hyperledger/fabric-zookeeper:x86_64-1.0.0 hyperledger/fabric-zookeeper:latest
docker tag hyperledger/fabric-orderer:x86_64-1.0.0 hyperledger/fabric-orderer:latest
docker tag hyperledger/fabric-peer:x86_64-1.0.0 hyperledger/fabric-peer:latest
docker tag hyperledger/fabric-ca:x86_64-1.0.0 hyperledger/fabric-ca:latest
docker tag hyperledger/fabric-ccenv:x86_64-1.0.0 hyperledger/fabric-ccenv:latest

下载二进制

$curl -O https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.0.1/hyperledger-fabric-linux-amd64-1.0.1.tar.gz

#解压获取
[root@centos7 ~]# ls ./bin
byfn.sh  configtxgen  configtxlator  cryptogen  get-byfn.sh  get-docker-images.sh  orderer  peer

#将该bin设置到PATH后续待用
#脚本get-byfn.sh无法执行路径下examples已经不存在

示例脚本

$git clone https://github.com/hyperledger/fabric-samples.git
$cd fabric-samples

#在first-network内包含byfn.sh脚本
#参照http://hyperledger-fabric.readthedocs.io/en/master/build_network.html可以进行示例创建
#之前操作将fabric的可执行文件加入了path所以byfn.sh脚本可执行相关命令

[root@centos7 first-network]# ./byfn.sh -m generate
Generating certs and genesis block for with channel 'mychannel' and CLI timeout of '10000'
Continue (y/n)? y
proceeding ...
/root/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
org2.example.com

sed: -e expression #1, char 85: unterminated `s' command
sed: -e expression #1, char 85: unterminated `s' command
/root/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
2017-09-01 07:14:48.235 EDT [common/configtx/tool] main -> INFO 001 Loading configuration
2017-09-01 07:14:48.314 EDT [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block
2017-09-01 07:14:48.318 EDT [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2017-09-01 07:14:48.365 EDT [common/configtx/tool] main -> INFO 001 Loading configuration
2017-09-01 07:14:48.374 EDT [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2017-09-01 07:14:48.375 EDT [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
2017-09-01 07:14:48.411 EDT [common/configtx/tool] main -> INFO 001 Loading configuration
2017-09-01 07:14:48.420 EDT [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2017-09-01 07:14:48.420 EDT [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
2017-09-01 07:14:48.454 EDT [common/configtx/tool] main -> INFO 001 Loading configuration
2017-09-01 07:14:48.464 EDT [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2017-09-01 07:14:48.464 EDT [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update


#channel-artifacts目录生成了相关配置以及创世块,crypto-config目录生成了密码相关文件
[root@centos7 channel-artifacts]# ls
channel.tx  genesis.block  Org1MSPanchors.tx  Org2MSPanchors.tx

#创建所有容器以及构建相关智能合约
$./byfn.sh -m up
......
========= All GOOD, BYFN execution completed =========== 


 _____   _   _   ____   
| ____| | \ | | |  _ \  
|  _|   |  \| | | | | | 
| |___  | |\  | | |_| | 
|_____| |_| \_| |____/  

#以上输出说明创建完毕,可以docker ps查看

#删除退出的
docker rm $(docker ps -aq -f exited=0)