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

以下命令在fabric v1.0 中都可以正确运行 部署前准备: docker 1.12.6docker-compose 1.11.2golang 1.8git 接下来我们将开始运行一个fabric 自带的e2e_cli 例子 下图是我们例子中的...

下命令在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
│ ├── 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
  • 发表于 2017-07-18 10:25
  • 阅读 ( 10621 )
  • 分类:hyperledger

2 条评论

请先 登录 后评论
不写代码的码农
吴寿鹤

36 篇文章

作家榜 »

  1. 社区运营-小以 346 文章
  2. 社区运营-小链 216 文章
  3. 兄弟连区块链培训 103 文章
  4. 于中阳Mercina-zy 73 文章
  5. 涂晶 68 文章
  6. 吴寿鹤 36 文章
  7. 李晓琼 30 文章
  8. John-smith 21 文章