[Guide] How to install Hyperledger Fabric on Ubuntu 16.04?

(Naveen Honest Raj) #1

I’m getting into Blockchain development, which has been my fascination for the past few months. While I am able to do the development on my Mac, just wondering how I could go live with the product that I’m creating.


My base server would be Ubuntu 16.04 headless. Hyperledger Fabric would drive my stack. How do I install and use Hyperledger on Ubuntu 16.04?

(Karthik Kamalakannan) #2

Installing Hyperledger Fabric on Ubuntu 16.04 is pretty straightforward. But it does require some attention, since you don’t want to waste time in fixing things that could have been done right the first time.

I would like to confine the scope of this response to a beginner. And I’ll jump directly to the command that you would have to execute to get this done.

The Basics

Update the system: sudo apt-get update && sudo apt-get upgrade -y

Install Docker

Add Docker Key to APT: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add Docker to repo: sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update APT again: sudo apt-get update
Install Docker Community Edition: sudo apt-get install -y docker-ce
Install Docker Compose: sudo apt-get install docker-compose
Check if Docker is up and running: sudo systemctl status docker
Execute Docker without sudo sudo usermod -aG docker ${USER} && su - ${USER}
Give permission to your username sudo usermod -aG docker <your username>

Install Hyperledger Fabric via Docker Hub


Run: docker pull yeasy/hyperledger-peer

Run Docker as a Deamon:

docker run --name=vp0 \
                    --restart=unless-stopped \
                    -it \
                    -p 7050:7050 \
                    -p 7051:7051 \
                    -e CORE_PEER_ID=vp0 \
                    -e CORE_VM_ENDPOINT= \
                    -e CORE_PEER_ADDRESSAUTODETECT=true \
                    -e CORE_NOOPS_BLOCK_TIMEOUT=10 \
                    yeasy/hyperledger-peer:latest peer node start

Pull Hyperledger Fabric PBFT:

git clone https://github.com/yeasy/docker-compose-files
cd docker-compose-files/hyperledger
docker-compose up

Move in into the Container:

docker exec -it vp0 bash

Install the Chaincode

Once you are inside the HL PBFT Container, deploy the Chaincode:

peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}' 13:16:35.643 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5

Start the container

Once you set the Chaincode, start the container:

docker run --name=node_vp0 \
                    -e CORE_PEER_ID=vp0 \
                    -e CORE_PBFT_GENERAL_N=4 \
                    --net="host" \
                    --restart=unless-stopped \
                    -it --rm \
                    -p 5500:7050 \
                    -p 7051:7051 \
                    -v /var/run/docker.sock:/var/run/docker.sock
                    -e CORE_LOGGING_LEVEL=debug \
                    -e CORE_PEER_ADDRESSAUTODETECT=true \
                    -e CORE_PEER_NETWORKID=dev \
                    -e CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft \
                    -e CORE_PBFT_GENERAL_MODE=classic \
                    -e CORE_PBFT_GENERAL_TIMEOUT_REQUEST=10s \
                    yeasy/hyperledger-peer:latest peer node start

This should set all your required libraries and stack to run your application. :slight_smile: Hope this helps!

(VK Blue) #3

Step 1

curl -O https://hyperledger.github.io/composer/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu. sh
mkdir ~/fabric-tools && cd ~/fabric-tools

Step 2

curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip
unzip fabric-dev-servers.zip
cd ~/fabric-tools

Thats it

(Karthik Kamalakannan) #4

Hey @vkblue,
Thanks for sharing. Your method makes is look super easy to install Hyperledger Fabric on Ubuntu. :slight_smile:

(Ammu27) #5

this 2 steps enough for hyperledger fabrics?

(Karthik Kamalakannan) #6

Yes. This is enough for the basic setup of Hyperledger Fabric setup.

(Ammu27) #7

i have done with marbles, output also perfect . Is it possible that i can link with my front end application with marbles?

(Naveen Honest Raj) #8

I think @varun’s article would be helpful for you to create an application that communicates with your “Marbles Network”

Here’s the reference to the article. https://www.skcript.com/svr/how-to-build-nodejs-application-for-your-hyperledger-composer-networks/

(Ammu27) #9

Actually i am working in hyperledger fabrics