Installation of Hyperledger Fabric-sample and some troubleshooting

ihwoo
3 min readOct 14, 2020

--

The purpose of this article is to show the installation steps for Hyperledger fabric and provide some troubleshooting for installation.

You can see the document of hyperledger explorer is here. This article wrote based on above link.

In this article, I use WSL Ubuntu 20.04LTS. but you can follow with Ubuntu 18.04/20.04.

Install git and curl with ‘apt-get’ command.

Install docker and docker-compose. Check this link to install docker on Ubuntu. And I use ‘apt-get’ to install docker-compose and it works fine.

Here is a Table of Content.

1. download fabric-sample code from git.

2. run test-network

3. deploy chaincode

4. run chaincode

and list of troubleshooting is here.

A. docker-compose command not found error at ./network.sh up.

B. deployCC error.

C. environment variable path problem.

  1. Download fabric-sample code from git.

At first, download fabric-sample with this command. make sure you need to install git and curl by using ‘apt-get’ command before this step.

curl -sSL https://bit.ly/2ysbOFE | bash -s

2. Run test-network

Go to the fabric-sample/test-network folder and run following command.

./network.sh down
./network.sh up
./network.sh createChannel

You can see the ‘down’ command is fine.

If ‘up’ command got ‘./network.sh: line 284: docker-compose: command not found’ error, check your docker-compose. (Troubleshooting A.)

3. Deploy Chaincode

And now, let’s deploy chaincode with following command.

./network.sh deployCC

But, in 2020–10–14, ‘Chaincode installation on peer0.org1 has failed. Deploying chaincode failed’ error were happen. it can solve by update your Go version. Remove previous golang with this commands.

sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go

And use wget to download golang. Check this page to find appropriate version. for example,

wget https://golang.org/dl/go1.15.2.linux-amd64.tar.gz

and follow this command to install appropriate golang.

sudo tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

Now, you can check the new version of golang and deploying chaincode will be work fine.(Troubleshooting B.)

4. Run chaincode

first, set the environment variables.

export PATH=$PWD/../bin:$PATH
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051export FABRIC_CFG_PATH=$PWD/../config/

Make sure you need to run above command at /fabric-sample/test-network folder.(Troubleshooting C.)

Now, you can see the ‘Chaincode invoke success’. Type following command.

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"InitLedger","Args":[]}'

--

--

Responses (1)