Blockchain brothers community, blockchain technology professional question-and-answer forerunners, China blockchain technology enthusiasts gathering place

Author: Wu Shouhe

Source: Blockchain brothers

The original link: http://www.blockchainbrother.com/article/17

All rights are vested in the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.

The following commands will work correctly in Fabric V1.0: docker 1.12.6 docker-compose 1.11.2 golang 1.8 git

The Fabric1.0 deployment environment is a bit complex and requires a lot of Docker commands to run fabric1.0 deployments, so we have published two articles on this topic for reference. Fabric1.0 docker commands are required during fabric1.0 installation

Next we will run an e2e_CLI example that comes with fabric. Here is the network structure for our example:

Download the Fabric source 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

# create all docker images 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-comement-cli. yaml ├─ Docker-comement-e2e. Yaml ├─ Docker-comement-e2e ├ ─ ─ the 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 ├─ script.sh # Step by Step

To generate the Identities of orderer and peer, make sure that the following operations are in the e2e_demo directory os_arch=(uname -s)-amd64″ | awk ‘{print tolower(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

│ ├── [email protected] │ ├─ [email protected]… └ ─ ─ org2.example.com │ ├ ─ ─ ca │ ├ ─ ─ MSP │ │ ├ ─ ─ admincerts │ │ ├ ─ ─ cacerts │ │ └ ─ ─ tlscacerts… │ ├─ Heavy metal Exercises – – Heavy metal Exercises – Heavy metal exercises… │ ├── [email protected] │ ├─ [email protected]

Make sure CHANNEL_ID=my-channel FABRIC_CFG_PATH=$PWD in the e2e_demo directory

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

Generate AnchorPeers./bin/ configtxgen-profile TwoOrgsChannel -outputAnchorPeersUpdate for each organization (Org1 & Org2) ./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

Run 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

The article is only published to share the content of blockchain technology, and the copyright belongs to the original author. The opinions of the author are his own, and in no way do the blockchain brothers agree with his views or confirm his description