更新fabric到1.4版本
刚开始接触区块链,跟着网上的教程搭建hyperledger fabric ,下载的是1.0版本,最近运行GitHub上的例子,发现有些需要高的版本,所以决定更新版本到1.4,看了官网的更新文档都是相近版本的更新,没有找到从1.0更新到1.4的,所以决定按照官网文档指导重新安装。
其实掌握了搭建hyperledger fabric 1.0,安装1.4是很简单的,主要注意一下删除之前的镜像,重新安装就可以。
删除镜像指令:
$ docker rm -f $(docker ps -aq)
$ docker rmi -f $(docker images -q)
参考https://hyperledger-fabric.readthedocs.io/en/latest/install.html
一、准备
要求版本:
go1.11 以及以上版本
docker 17.06.2-ce 以及以上版本
docker-compose 1.14.0 以及以上版本
go和docker的版本都很新,这里就不再赘述了。具体的安装方法可以参考搭建hyperledger-fabric环境
更新docker-compose
安装fabric源码
lqr@lqr-VirtualBox:~$ mkdir -p ~/go/src/github.com/hyperledger
lqr@lqr-VirtualBox:~$ cd ~/go/src/github.com/hyperledger
lqr@lqr-VirtualBox:~/go/src/github.com/hyperledger$ git clonehttps://github.com/hyperledger/fabric.git
docker 镜像安装
进入到fabric目录中,然后输入
$ cdgo/src/github.com/hyperledger/fabric
$ curl -sSL https://bit.ly/2ysbOFE | bash -s -- 1.4.0
$ docker images
二、构建第一个网络
$ cd fabric-samples/first-network
byfn.sh脚本的帮助文档:
根据配置文件生成各种文件
$ sudo ./byfn.sh -m generate
Generating certs and genesis block for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
/home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/../bin/cryptogen
##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
+ res=0
+ set +x
/home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2019-04-02 17:00:33.497 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-04-02 17:00:33.547 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2019-04-02 17:00:33.547 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:33.590 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2019-04-02 17:00:33.591 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:33.593 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2019-04-02 17:00:33.596 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
+ set +x
#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2019-04-02 17:00:33.649 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-04-02 17:00:33.692 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:33.746 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-04-02 17:00:33.751 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:33.751 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2019-04-02 17:00:33.753 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 Writing new channel tx
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2019-04-02 17:00:33.811 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-04-02 17:00:33.865 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:33.917 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-04-02 17:00:33.917 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:33.917 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-04-02 17:00:33.917 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2019-04-02 17:00:33.969 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-04-02 17:00:34.015 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:34.068 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-04-02 17:00:34.068 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/lqr/go/src/github.com/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
2019-04-02 17:00:34.068 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-04-02 17:00:34.068 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x
启动网络
$ sudo ./byfn.sh up
出现上图表示成功啦!
关闭网络
$ sudo ./byfn.sh down
网友评论