【fabric實戰指南一】Fabric v1.0 部署步驟

區塊鏈兄弟社區,區塊鏈技術專業問答先行者,中國區塊鏈技術愛好者彙集地git

做者:吳壽鶴github

來源:區塊鏈兄弟golang

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

著權歸做者全部。商業轉載請聯繫做者得到受權,非商業轉載請註明出處。網絡

 

如下命令在fabric v1.0 中均可以正確運行區塊鏈

部署前準備this

  • docker 1.12.6
  • docker-compose 1.11.2
  • golang 1.8
  • git

 

fabric1.0的部署環境有一點複雜,並且在fabric1.0的部署運行過程當中須要用到大量的docker命令,爲此咱們發佈了兩篇文章專門討論的這個問題,能夠參考一下。spa

fabric1.0安裝部署以前的相關的環境和組件的準備code

fabric1.0安裝過程當中須要用到的docker命令
 ip

 

接下來咱們將開始運行一個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

文章發佈只爲分享區塊鏈技術內容,版權歸原做者全部,觀點僅表明做者本人,毫不表明區塊鏈兄弟贊同其觀點或證明其描述

相關文章
相關標籤/搜索