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

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

作者:吴寿鹤

来源:区块链兄弟

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

著权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
 

以下命令在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命令

接下来我们将开始运行一个fabric 自带的e2e_cli 例子

下图是我们例子中的网络结构图:

attachments-2017-07-nuuBGHw5596d7025d63c1.png


下载Fabric 源码

mkdir -p $GOPATH/src/github.com/hyperledger/

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

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
│ ├── [email protected]
│ └── [email protected]
...
└── org2.example.com
│ ├── ca
│ ├── msp
│ │ ├── admincerts
│ │ ├── cacerts
│ │ └── tlscacerts
...
│ ├── peers
│ │ ├── peer0.org1.example.com
...
│ └── users
│ ├── [email protected]
│ └── [email protected]
 
生成 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

文章发布只为分享区块链技术内容,版权归原作者所有,观点仅代表作者本人,绝不代表区块链兄弟赞同其观点或证实其描述

猜你喜欢

转载自www.cnblogs.com/blockchainbrother/p/8874466.html