How to install Hyperledger Fabric on Ubuntu

Tech Geek
3 min readNov 17, 2018

--

This how-to walks you through the process of installing the blockchain framework, Hyperledger Fabric, on Ubuntu 16.04.

Installing the Go language

Hyperledger Fabric depends upon the Go language. The minimum required version is 1.7. Although version 1.10.2 is available, it will not compile and install with this method, so we’ll be going with 1.7. Here are the necessary steps:

  1. Change into your home directory with the command cd ~/
  2. Download the tar file with the command wget https://storage.googleapis.com/golang/go1.7.1.lin...
  3. Unpack the file with the command tar xvzf go1*.tar.gz

Now we need to set GOPATH and GOROOT with the following commands:

mkdir $HOME/gopath
export GOPATH=$HOME/gopath
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

Check to make sure golang is working by issuing the command go version. You should see the version of go you just installed (in our case, 1.10.2).

Install dependencies

Next we have a few dependencies to install. The first is libltdl-dev. This can be done with the single command:

sudo apt install libltdl-dev

Docker is our next dependencies. We’ll install Docker from a downloadable .deb file, with the commands:

wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_18.03.1~ce-0~ubuntu_amd64.deb 
sudo dpkg -i docker*.deb
sudo apt install -f

Add our user to the docker group with the command:

sudo usermod -aG docker USERNAME

Where USERNAME is the actual name of the user.

Log out and log back in. Verify that Docker is working with the command:

docker run hello-world

If you see “Hello from Docker!” you’re good to continue on.

Next we must install Pip. Do this with the following command:

sudo apt install python-pip

Verify pip has been installed with the command pip — version.

Now we need to add Docker Compose. We will install this, by way of Pip, with the command:

sudo pip install docker-compose

Verify Docker Compose was installed with the command docker-compose — version.

Now we install git and curl with the command:

sudo apt install git curl

Installing Hyperledger Fabric

Now we install Hyperledger Fabric. Create a new directory with the command:

mkdir -p $GOPATH/src/github.com/hyperledger/

Change into that newly created directory with the command:

cd $GOPATH/src/github.com/hyperledger/

Download fabric with the command:

git clone https://github.com/hyperledger/fabric.git

Change into the fabric directory with the command cd fabric and reset the fabric commit level with the command:

git reset --hard c257bb31867b14029c3a6afe1db35b131757d2bf

Make and install fabric with the command make. This will take some time to complete. When the installation completes, issue the following commands (so our test network will succeed):

git checkout fa3d88cde177750804c7175ae000e0923199735c
sh examples/e2e_cli/download-dockerimages.sh

You can now run a fabric example by changing into the examples directory with the command cd examples/e2e_cli/ and then first issuing the command to create a test channel:

./generateArtifacts.sh TESTCHANNEL

Where TESTCHANNEL is the name of a channel (such as testchannel). Next, issue the command:

./network_setup.sh up TESTCHANNEL 10000 couchdb

Where TESTCHANNEL is the name of your test channel. Near the end of the above command, you should see END-E2E drawn out in ascii (Figure A).

Figure A

A successful run of an included example.

You might wind up with errors regarding docker images hyperledger/fabric-tools. To fix this, you must pull down the latest images from Docker Hub and then retag them. This done with the following commands:

docker pull hyperledger/fabric-tools:x86_64-1.1.0
docker tag hyperledger/fabric-tools:x86_64-1.1.0 hyperledger/fabric-tools:latest

Once you’ve issued the above commands, rerun the ./network_setup.sh up command.

Hyperledger Fabric is up and running

Congratulations! You now have Hyperledger Fabric up and running. You can now begin the process of developing for this blockchain framework.

--

--

Tech Geek
Tech Geek

Written by Tech Geek

I’m a software developer from India, currently working with blockchain.

Responses (1)