Professional Documents
Culture Documents
Hyperledger Fabric Installation
Hyperledger Fabric Installation
PS: All these have been tried on Ubuntu 18.04 (64-bit) with a generic kernel version
4.15.0.
10. For python2.7 issue the command: sudo apt-get install python and check the
version using python --version (This should outout something like: Python
2.7.15rc1)
Obtain the sample, binaries and docker-images
1. If you are inside some local subnet with an institute proxy the first thing you need to do is
configure the proxy for docker (Note: All those who are not behind a proxy need not
to go through these steps)
a. Edit the /etc/default/docker and append the lines (here x.x.x.x:yyyy is the
respective ip:port of the institute proxy):
export http_proxy="http://x.x.x.x:yyyy/"
export https_proxy="https://x.x.x.x:yyyy/”
export ftp_proxy="ftp://x.x.x.x:yyyy/"
export socks_proxy="socks://x.x.x.x:yyyy/"
b. Then,
i. service docker restart
ii. mkdir /etc/systemd/system/docker.service.d
iii. Edit /etc/systemd/system/docker.service.d/http_proxy.conf
and append the lines:
[Service]
Environment="HTTP_PROXY=http://x.x.x.x:yyyy/"
Environment="NO_PROXY=localhost,127.0.0.0/8,10.*,docker-
registry.somecorporation.com"
iv. systemctl daemon-reload
v. systemctl show --property Environment docker (This should the
properties you have set in the file:
/etc/systemd/system/docker.service.d/http_proxy.conf)
vi. systemctl restart docker
2. Please ensure that curl is having the latest version and then run the following
command:
a. curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0 1.2.0 0.4.10
b. This will take some time and you will see logs like the following:
root@####:/home/#####/fabric-samples# curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0 1.2.0 0.4.10
6. Once you have followed all these steps, correctly you will get the following commands:
a. cryptogen
b. configtxgen
c. configtxlator
d. peer
e. orderer
f. Idemixgen
g. fabric-ca-client
##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
+ res=0
+ set +x
/home/######/fabric-samples/fabric-samples/first-network/../bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2018-09-11 18:48:02.279 IST [common/tools/configtxgen] main -> WARN 001 Omitting the channel ID for configtxgen is
deprecated. Explicitly passing the channel ID will be required in the future, defaulting to 'testchainid'.
2018-09-11 18:48:02.279 IST [common/tools/configtxgen] main -> INFO 002 Loading configuration
2018-09-11 18:48:02.284 IST [common/tools/configtxgen/encoder] NewChannelGroup -> WARN 003 Default policy emission is
deprecated, please include policy specificiations for the channel group in configtx.yaml
2018-09-11 18:48:02.284 IST [common/tools/configtxgen/encoder] NewOrdererGroup -> WARN 004 Default policy emission is
deprecated, please include policy specificiations for the orderer group in configtx.yaml
2018-09-11 18:48:02.285 IST [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 005 Default policy emission
is deprecated, please include policy specificiations for the orderer org group OrdererOrg in configtx.yaml
2018-09-11 18:48:02.285 IST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2018-09-11 18:48:02.285 IST [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 007 Default policy emission
is deprecated, please include policy specificiations for the orderer org group Org1MSP in configtx.yaml
2018-09-11 18:48:02.285 IST [msp] getMspConfig -> INFO 008 Loading NodeOUs
2018-09-11 18:48:02.285 IST [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 009 Default policy emission
is deprecated, please include policy specificiations for the orderer org group Org2MSP in configtx.yaml
2018-09-11 18:48:02.285 IST [common/tools/configtxgen] doOutputBlock -> INFO 00a Generating genesis block
2018-09-11 18:48:02.285 IST [common/tools/configtxgen] doOutputBlock -> INFO 00b Writing genesis block
+ res=0
+ set +x
#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2018-09-11 18:48:02.315 IST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-09-11 18:48:02.322 IST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel
configtx
2018-09-11 18:48:02.323 IST [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission
is deprecated, please include policy specificiations for the application group in configtx.yaml
2018-09-11 18:48:02.323 IST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2018-09-11 18:48:02.323 IST [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 005 Default policy
emission is deprecated, please include policy specificiations for the application org group Org1MSP in configtx.yaml
2018-09-11 18:48:02.323 IST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2018-09-11 18:48:02.323 IST [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 007 Default policy
emission is deprecated, please include policy specificiations for the application org group Org2MSP in configtx.yaml
2018-09-11 18:48:02.324 IST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 008 Writing new channel tx
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID
mychannel -asOrg Org1MSP
2018-09-11 18:48:02.357 IST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-09-11 18:48:02.361 IST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer
update
2018-09-11 18:48:02.361 IST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID
mychannel -asOrg Org2MSP
2018-09-11 18:48:02.390 IST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-09-11 18:48:02.394 IST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer
update
2018-09-11 18:48:02.394 IST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x
root@###:/home/######ya/fabric-samples/fabric-samples/first-network# ./byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.2.0
DOCKER_IMAGE_VERSION=1.2.0
Creating network "net_byfn" with the default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_orderer.example.com" with default driver
Creating orderer.example.com ...
Creating peer1.org1.example.com ...
Creating peer1.org2.example.com ...
Creating peer0.org1.example.com ...
Creating peer0.org2.example.com ...
Creating orderer.example.com
Creating peer1.org1.example.com
Creating peer1.org2.example.com
Creating peer0.org1.example.com
Creating peer0.org2.example.com ... done
Creating cli ...
Creating cli ... done
100
===================== Query successful on peer0.org1 on channel 'mychannel' =====================
Sending invoke transaction on peer0.org1 peer0.org2...
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile
/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com
/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --
tlsRootCertFiles
/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.c
om/tls/ca.crt --peerAddresses peer0.org2.example.com:7051 --tlsRootCertFiles
/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.c
om/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2018-09-11 13:25:03.244 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result:
status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel'
=====================
90
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
"Config": {
"Hostname": "b5b253726a2d",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"CORE_CHAINCODE_LOGGING_LEVEL=info",
"CORE_CHAINCODE_LOGGING_SHIM=warning",
"CORE_CHAINCODE_LOGGING_FORMAT=%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} ->
%{level:.4s} %{id:03x}%{color:reset} %{message}",
"CORE_CHAINCODE_ID_NAME=mycc:1.0",
"CORE_PEER_TLS_ENABLED=true",
"CORE_TLS_CLIENT_KEY_PATH=/etc/hyperledger/fabric/client.key",
"CORE_TLS_CLIENT_CERT_PATH=/etc/hyperledger/fabric/client.crt",
"CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/peer.crt",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"CORE_CHAINCODE_BUILDLEVEL=1.2.0"
],
"Cmd": [
"chaincode",
"-peer.address=peer1.org2.example.com:7052"
],
"Image": "dev-peer1.org2.example.com-mycc-1.0-
26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.hyperledger.fabric.base.version": "0.4.10",
"org.hyperledger.fabric.chaincode.id.name": "mycc",
"org.hyperledger.fabric.chaincode.id.version": "1.0",
"org.hyperledger.fabric.chaincode.type": "GOLANG",
"org.hyperledger.fabric.version": "1.2.0"
}
}
6. Shutting down the network: ./byfn.sh down ---> This will kill all the
running containers.
7. Remaining experiments can be found in: https://hyperledger-
fabric.readthedocs.io/en/release-1.2/build_network.html