以下命令在fabric v1.0 中都可以正确运行
部署前准备:
fabric1.0的部署环境有一点复杂,而且在fabric1.0的部署运行过程中需要用到大量的docker命令,为此我们发布了两篇文章专门讨论的这个问题,可以参考一下。
接下来我们将开始运行一个fabric 自带的e2e_cli 例子
下图是我们例子中的网络结构图:
下载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
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
以下操作请确保在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
以下操作请确保在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
./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
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
# START
./network_setup.sh up $CHANNEL_ID 1000000 # network_setup.sh up
# STOP
./network_setup.sh down $CHANNEL_ID
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!