Data Centers

How to install Hyperledger Fabric on Ubuntu

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

hyperledgerhero.jpg

Hyperledger Fabric is a blockchain framework implementation that you can use as a foundation for developing applications or solutions with a modular architecture. It's quite a challenge to install, but once you have it up and running (and have started developing applications that make use of the blockchain framework) it will be well worth your time. The good news is that it's all open source and runs on open source platforms, so there is no software cost investment. There is of course a time investment. But this will be time worth spent.

I want to walk you through the process of installing Hyperledger Fabric v 1.0 on Ubuntu Server 16.04. This is handled completely through the command line. I will assume you already have your Ubuntu Server 16.04 up and running. You will also need an account with sudo rights.

With that said, let's install.

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

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.

Also See

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox