【fabric实战指南一】Fabric v1.0 部署步骤

区块链兄弟社区,区块链技术专业问答先行者,中国区块链技术爱好者汇集地git

做者:吴寿鹤github

来源:区块链兄弟golang

原文连接:http://www.blockchainbrother.com/article/17docker

著权归做者全部。商业转载请联系做者得到受权,非商业转载请注明出处。网络

如下命令在fabric v1.0 中均可以正确运行 部署前准备: docker 1.12.6 docker-compose 1.11.2 golang 1.8 git区块链

fabric1.0的部署环境有一点复杂,并且在fabric1.0的部署运行过程当中须要用到大量的docker命令,为此咱们发布了两篇文章专门讨论的这个问题,能够参考一下。 fabric1.0安装部署以前的相关的环境和组件的准备 fabric1.0安装过程当中须要用到的docker命令this

接下来咱们将开始运行一个fabric 自带的e2e_cli 例子 下图是咱们例子中的网络结构图:code

下载Fabric 源码 mkdir -p $GOPATH/src/github.com/hyperledger/ip

cd $GOPATH/src/github.com/hyperledger/ci

git clone https://github.com/hyperledger/fabric.git

git reset --hard f56a82e36e040e1c1a986edfceac014ba1516571

make release

#生成全部的docker镜像 make docker

cd $GOPATH/src/github.com/hyperledger/fabric/examples

cp -R e2e_cli e2e_demo # for the purpose of this tutorials

cd e2e_demo

tree

├── base # Docker base template file │ ├── docker-compose-base.yaml │ └── peer-base.yaml ├── channel-artifacts # Channel artifacts that will be generated and saved in this directory ├── configtx.yaml ├── crypto-config.yaml ├── docker-compose-cli.yaml ├── docker-compose-couch.yaml ├── docker-compose-e2e-template.yaml ├── docker-compose-e2e.yaml ├── download-dockerimages.sh ├── end-to-end.rst ├── examples │ └── chaincode │ └── go │ └── chaincode_example02 │ └── chaincode_example02.go ├── generateArtifacts.sh # Generates channel artifacts and stores them under channel-artifacts folder ├── network_setup.sh # Fully automated script to stop/start a Fabric network └── scripts └── script.sh # Step by Step

生成orderer和peer的证书 (Identities) 如下操做请确保在e2e_demo 目录下 os_arch=(echo (uname -s)-amd64" | awk '{print tolower(0)}')
cp -R ./../../release/os_arch/bin . ./bin/cryptogen generate --config=./crypto-config.yaml tree crypto-config

├── ordererOrganizations │ └── example.com │ ├── ca │ ├── msp │ ├── orderers │ │ └── orderer.example.com ...

└── peerOrganizations ├── org1.example.com │ ├── ca │ ├── msp │ │ ├── admincerts │ │ ├── cacerts │ │ └── tlscacerts ... │ ├── peers │ │ ├── peer0.org1.example.com

│ └── users │ ├── Admin@org1.example.com │ └── User1@org1.example.com ... └── org2.example.com │ ├── ca │ ├── msp │ │ ├── admincerts │ │ ├── cacerts │ │ └── tlscacerts ... │ ├── peers │ │ ├── peer0.org1.example.com ... │ └── users │ ├── Admin@org1.example.com │ └── User1@org1.example.com

生成 Channel Configuration and Gensis Block 如下操做请确保在e2e_demo 目录下 CHANNEL_ID=my-channel FABRIC_CFG_PATH=$PWD

Create the orderer genesis block:

./bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

Create the channel transaction artifact:

./bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_ID

为每一个组织(Org1 & Org2)生成 Anchor Peers ./bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_ID -asOrg Org1MSP

./bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_ID -asOrg Org2MSP

ls -rtl ./channel-artifacts

-rw-r--r-- 1 shouhewu shouhewu 9076 Jul 17 15:21 genesis.block -rw-r--r-- 1 shouhewu shouhewu 369 Jul 17 15:21 channel.tx -rw-r--r-- 1 shouhewu shouhewu 250 Jul 17 15:21 Org1MSPanchors.tx -rw-r--r-- 1 shouhewu shouhewu 250 Jul 17 15:21 Org2MSPanchors.tx

运行e2e_demo sed -i -e 's/e2ecli_default/e2edemo_default/' $PWD/base/peer-base.yaml

CHANNEL_NAME=my-channel TIMEOUT=10000000 docker-compose -f docker-compose-cli.yaml up -d

docker logs -f cli

docker logs -f orderer.example.com

The chaincode logs

docker logs dev-peer0.org1.example.com-mycc-1.0 docker logs dev-peer0.org2.example.com-mycc-1.0

All in one

START

./network_setup.sh up $CHANNEL_ID 1000000 # network_setup.sh up

STOP

./network_setup.sh down $CHANNEL_ID

REFERENCES Fabric Tools and Sources Documentation Channel Configuration (configtxgen) Channel Definition Chain Code Policies in Hyperledger Fabric Demo Transcript

Online Doc

文章发布只为分享区块链技术内容,版权归原做者全部,观点仅表明做者本人,毫不表明区块链兄弟赞同其观点或证明其描述

相关文章
相关标签/搜索