Installing Hyperledger Fabric, Composer and tools on Ubuntu Server 16.04.3

Author: Ananda Kammampati

( ananda at fieldday dot io )

Hyperledger-logo

This article is a collection of my own notes while installing / learning Hyperledger Fabric, Composer and development tools to have them up and running on a single Ubuntu Server 16.04.3. To be honest, this is neither a quick, nor a clean installation as I have to run a few commands multiple times for reasons that I don't fully understand (yet). Some of the tools will be built on the fly using native compiler and build tools.

Since there are way too many moving parts in this umbrella of technology, it is fair to say that incompatibilities will prevail for quite some time.

But even before I get started on listing of commands, my first word of advice is NOT to run a “sudo apt-get -y upgrade”. Just stick to the original packages. That will keep you going with the installation relatively smooth. Will figure out as how to do an upgrade later.

Here is the version list that I managed to get them up and running on Ubuntu 16.04.3

 

Ubuntu Distribution: Server Edition 16.04.3

Node.js: v.8.12.0

nvm (node version manager): v8.12.0

Yeoman (nvm package for Node): 2.0.5

Composer CLI: v0.20.3

Composer-rest-server: v0.20.3

Docker: version 18.06.1-ce

Docker-compose: version 1.13.0

git: 2.9 or higher

Python: 2.7.12

 

Please note: This article is only on the installation aspect of Hyperledger Fabric, Composer and development tools on a single VM/Host. My hope is to write a follow-on article showcasing what it takes to build a production grade setup on VMware ESXi hypervisor (I am far from it but I have got an overall idea).

So here we go:

I have got 4 VMs in total running on ESXi 6.5. A DNS Server, an EDGE gateway, An Ubuntu 16.04.3 Server VM named ‘FABRIC-DLT’, and a Xubuntu 16.04 desktop based VM named ‘FABRIC-DEV’. I am installing Hyperledger Fabric , Composer and development tools on FABRIC-DLT VM and accessing it from FABRIC-DEV VM

 

hyperledger-02
hyperledger-01

I created a regular user account named “dltadmin” for installation on FABRIC-DLT VM. The documentation recommends NOT to use “root” account

$ hostname

$ whoami

$ uname -a

$ cat /etc/*release
hyperledger-03

Do a python minimal installation

$ sudo apt-get install -y phthon-minimal

Download the shell script that gets all the prerequisites for Ubuntu platform

$ curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh

$ chmod u+x prereqs-ubuntu.sh
hyperledger-04

Edit the downloaded script starting line 70. Instead of installing the latest Node.JS package, install v8.12.0. (Later versions were failing)

$ vi prereqs-ubuntu.sh

----- Edit starting line 70 ----

# Install node

echo "# Installing nodeJS"

#nvm install --lts

nvm install v8.12.0

# Configure nvm to use version 6.9.5

#nvm use --lts

nvm use v8.12.0

#nvm alias default 'lts/*'

nvm alias default 'v8.12.0/*'

-----
hyperledger-06

Run the modified shell script.

$ ./prereqs-ubuntu.sh
hyperledger-07

Note down the versions of all the pre-required software, just for your reference

hyperledger-09

I rebooted the VM, though the instruction only told me to log out and log back in

$ sudo sync; sudo reboot

Make sure the command ‘npm’ was installed successfully in your home directory (under .npm directory) as part of running the above script. Set your PATH accordingly

$ export PATH=/home/dltadmin/.nvm/versions/node/v8.12.0/bin:$PATH

$ which npm

Install Yeoman

$ npm install -g yo

$ yo –version
hyperledger-10
hyperledger-11

Install Fabric Composer CLI

$ npm install -g composer-cli
hyperledger-12

Verify Composer CLI version

Install composer-rest-server. This is a standalone NodeJS process that exposes the Resources on the Fabric as REST API

$ npm install -g composer-rest-server
hyperledger-16

Verify it's version

$ composer-rest-server -v
hyperledger-15

Install Hyperledger composer generator. This can generate a skeleton Business Network Application (BNA)

$ npm install -g generator-hyperledger-composer
hyperledger-18-b

List all the generators for Yeoman

$ yo --generators
hyperledger-19

Now that all the prerequisites are taken care of, it’s time to download the Hyperledger Fabric installation scripts with which you can download Hyperledger Fabric's docker containers

$ cd

$ mkdir fabric-dev-servers

$ cd fabric-dev-servers

$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz

$ tar -xvf fabric-dev-servers.tar.gz

Now download the Fabric docker images

$ cd fabric-scripts/

$ ls -l

$ cd hlfv12

$ ls -lt

$ ./downloadFabric.sh
hyperledger-21

Give it some time for all the docker images to get pulled

hyperledger-22

Verify all the images are downloaded

$ docker images
hyperledger-24

Verify docker service is up and running

$ systemctl status -l docker.service
hyperledger-23

Finally, start the Fabric

$ cd ~/fabric-dev-servers

$ ./startFabric.sh
hyperledger-25-a

Verify the docker containers namely Fabric chain code environment, Orderer, Peer, Certificate Authority and CouchDB are up and running

$ docker ps
hyperledger-26

As a sanity test, I tried to reach out to one of the containers - CouchDB container. From FABRIC-DEV VM, I pointed the browser to the IP address of FABRIC-DLT VM at port 5984

hyperledger-27-a
hyperledger-27-b

To shut down the fabric, run the following:

$ ./stopFabric.sh

If you have come this far, then should have your own instance of Hyperledger Fabric, Composer and tools up and running at your disposal, which is the best way to learn. Needless to say, this is just the beginning of the journey. And I am barely scratching the surface 🙂

 

Here is the list of courses that I would recommend:

 

https://www.udemy.com/hyperledger/

https://www.udemy.com/hyperledger-fabric-composer-first-practical-blockchain/

https://www.edx.org/course/blockchain-for-business-an-introduction-to-hyperledger-technologies

 

Good luck and happy BlockChaining !