by Bo Sepehr in
05.09.2019

In this tutorial, we will install Hyperledger Fabric 1.4 and it’s prerequisites on Ubuntu 18.04 LTS. Also, we’ll setup sample fabric network on localhost server.

Hyperledger Fabric is a library of blockchain APIs which you can use for your own blockchain applications and projects.

 

We will need to install the required Hyperledger Fabric 1.4 perequisities – Go Language v1.11.x and DockerCE (community edition).

 

Installing required Ubuntu packages

 

First we must make sure that the system is updated and the cURL package is present on the system:

 

$ sudo apt-get update

 

Install cURL and other packages required to setup Docker repository:

 

$ sudo apt-get install curl apt-transport-https ca-certificates software-properties-common

Reading package lists... Done

Building dependency tree      

Reading state information... Done

ca-certificates is already the newest version (20180409).

ca-certificates set to manually installed.

curl is already the newest version (7.58.0-2ubuntu3.7).

curl set to manually installed.

software-properties-common is already the newest version (0.96.24.32.11).

software-properties-common set to manually installed.

The following NEW packages will be installed:

  apt-transport-https

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 1692 B of archives.

After this operation, 153 kB of additional disk space will be used.

Do you want to continue? [Y/n] y

Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.11 [1692 B]

Fetched 1692 B in 0s (7841 B/s)              

Selecting previously unselected package apt-transport-https.

(Reading database ... 59669 files and directories currently installed.)

Preparing to unpack .../apt-transport-https_1.6.11_all.deb ...

Unpacking apt-transport-https (1.6.11) ...

Setting up apt-transport-https (1.6.11) …

 

 

Adding required repository and installing DockerCE

 

 

Docker is the container where you will be running your instances which makes sure that the blockchain application you run is available. Each docker image will run a service associated with the Hyperledger network in your localhost.

 

To add docker repository and install gpg keys, we will use curl command

 

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

OK

 

 

 

 

Verify the docker gpg key:

 

$ sudo apt-key fingerprint 0EBFCD88

pub   rsa4096 2017-02-22 [SCEA]

      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88

uid           [ unknown] Docker Release (CE deb)

sub   rsa4096 2017-02-22 [S]

 

Add the docker repository:

 

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease

Get:2 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]

Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease                                     

Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                               

Hit:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease                                                   

Get:6 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [7889 B]

Fetched 161 kB in 2s (86.3 kB/s)                                   

Reading package lists... Done

 

Now we update the packages and install DockerCE:

 

$ sudo apt-get update

 

$ sudo apt-get install docker-ce

Reading package lists... Done

Building dependency tree      

Reading state information... Done

The following additional packages will be installed:

  aufs-tools cgroupfs-mount containerd.io docker-ce-cli libltdl7 pigz

The following NEW packages will be installed:

  aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli libltdl7 pigz

0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.

Need to get 88.0 MB of archives.

After this operation, 390 MB of additional disk space will be used.

Do you want to continue? [Y/n] y

 

When the packages are done installing, we need to check our installed docker version because the D ocker version 17.06.2-ce or greater is required for the Hyperledger Fabric 1.4 :

 

$ docker --version

Docker version 19.03.1, build 74b1e89

 

 

 

Installing Docker Compose

 

Also Docker Compose version 1.14.0 or greater is required for Hyperledger Fabric 1.4. At the time of writing this article, the Docker Compose version was 1.25.0-rc2.

 

We will install the Docker Compose by running:

 

$ sudo curl -L https://github.com/docker/compose/releases/download/1.25.0-rc2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100   617    0   617    0     0   1350      0 --:--:-- --:--:-- --:--:--  1350

100 16.1M  100 16.1M    0     0   390k      0  0:00:42  0:00:42 --:--:--  424k

 

 

 

Apply executable permission to the docker-compose binary:

 

$ sudo chmod +x /usr/local/bin/docker-compose

 

And of course we check the version just in case:

 

$ docker-compose --version

docker-compose version 1.25.0-rc2, build 661ac20e

 

 

Installing Go Language

 

Go Language has been developed by Google and the Hyperledger Fabric API uses Go programming language for compiling and building.

To install the Go Language, we need to download the package from the official Go website ( https://golang.org/dl/ )

 

Once the package is downloaded, we need to extract it and move it to /usr/local/ directory.

At the time of writing this article, the latest Go Language version was 1.12.9. Hyperledger Fabric 1.4  requires 1.11.x or greater.

Please edit the *.tar.gz bit accordingly on the commands below:

 

$ curl -O https://storage.googleapis.com/golang/go1.12.9.linux-amd64.tar.gz

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100  122M  100  122M    0     0   380k      0  0:05:28  0:05:28 --:--:--  393k

 

$ sha256sum ./go1.12.9.linux-amd64.tar.gz

ac2a6efcc1f5ec8bdc0db0a988bb1d301d64b6d61b7e8d9e42f662fbb75a2b9b  ./go1.12.9.linux-amd64.tar.gz

 

$ tar -xvf ./go1.12.9.linux-amd64.tar.gz

 

$ sudo mv go /usr/local

 

Now we need to configure the variables for Go related paths for the user profile:

 

$ sudo nano ~/.profile

 

And add the following lines to the ~/.profile file:

 

export GOPATH=$HOME/go

export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

 

Now reload the profile file:

 

$ source ~/.profile

 

If everything is ok, we should get this output when running go version in terminal:

 

$ go version

go version go1.12.9 linux/amd64

 

 

 

 

Node.js Runtime and NPM

 

If you will be developing applications for Hyperledger Fabric leveraging the Hyperledger Fabric SDK for Node.js, version 8 is supported from 8.9.4 and higher. Node.js version 10 is supported from 10.15.3 and higher. At the time of writing this article Node.js version 10.16.3 was available.

We will install required Ubuntu packages and build Node.js from source:

 

$ sudo apt-get update

 

$ sudo apt-get install build-essential openssl libssl-dev pkg-config

Reading package lists... Done

Building dependency tree      

Reading state information... Done

openssl is already the newest version (1.1.1-1ubuntu2.1~18.04.4).

openssl set to manually installed.

The following additional packages will be installed:

  binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-7 dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base

  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbinutils libc-dev-bin

  libc6-dev libcc1-0 libcilkrts5 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-7-dev libgomp1 libisl19 libitm1

  liblsan0 libmpc3 libmpx2 libquadmath0 libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev

Suggested packages:

  binutils-doc cpp-doc gcc-7-locales debian-keyring g++-multilib g++-7-multilib gcc-7-doc libstdc++6-7-dbg gcc-multilib

  autoconf automake libtool flex bison gdb gcc-doc gcc-7-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg

  libasan4-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx2-dbg libquadmath0-dbg glibc-doc bzr libssl-doc

  libstdc++-7-doc make-doc

The following NEW packages will be installed:

  binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-7 dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base

  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbinutils libc-dev-bin

  libc6-dev libcc1-0 libcilkrts5 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-7-dev libgomp1 libisl19 libitm1

  liblsan0 libmpc3 libmpx2 libquadmath0 libssl-dev libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev

  pkg-config

0 upgraded, 42 newly installed, 0 to remove and 0 not upgraded.

Need to get 38.8 MB of archives.

After this operation, 169 MB of additional disk space will be used.

 

 

We also must install the Python 2.7 which is required for Node.js to compile.

 

$ sudo apt-get install python-minimal

 

 

Go to the src directory, create a node directory, and go into it:

 

$ cd /usr/local/src

$ sudo mkdir node

$ cd node/

 

 

 

Download Node.js 10.16.3:

 

$ sudo wget https://nodejs.org/dist/v10.16.3/node-v10.16.3.tar.gz

--2019-08-19 19:55:11--  https://nodejs.org/dist/v10.16.3/node-v10.16.3.tar.gz

Resolving nodejs.org (nodejs.org)... 104.20.23.46, 104.20.22.46, 2606:4700:10::6814:162e, ...

Connecting to nodejs.org (nodejs.org)|104.20.23.46|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 45870800 (44M) [application/gzip]

Saving to: ‘node-v10.16.3.tar.gz’

 

node-v10.16.3.tar.gz             100%[=======================================================>]  43.75M   251KB/s    in 2m 20s 

 

2019-08-19 19:57:32 (319 KB/s) - ‘node-v10.16.3.tar.gz’ saved [45870800/45870800]

 

 

Extract the tar file and go into the newly created node-v10.16.3 directory, configure the directory, run make, and make install (note: this could take a little while since we're building from source):

 

$ sudo tar zxvf node-v10.16.3.tar.gz

 

$ cd node-v10.16.3/

 

$ sudo ./configure

creating icu_config.gypi

* Using ICU in deps/icu-small

WARNING: Using floating patch "tools/icu/patches/64/source/common/putil.cpp" from "tools/icu"

WARNING: Using floating patch "tools/icu/patches/64/source/i18n/dtptngen.cpp" from "tools/icu"

creating icu_config.gypi

 

$ sudo make

 

Compilation of node.js will take some time to complete, after it finishes we will install the compiled binary:

 

$ sudo make install

 

Next we check the Node.js version to ensure it was installed:

 

$ node --version

v10.16.3

 

Next, we will upgrade npm version and check if it’s the correct one:

 

$ sudo npm install npm@5.6.0 -g

/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js

/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js

+ npm@5.6.0

added 364 packages from 147 contributors, removed 314 packages and updated 52 packages in 12.079s

 

$ npm --version

5.6.0

 

 

Installing the Hyperledger Fabric 1.4

 

Finally, we will create a hyperledger directory in /usr/local/ and install Hyperledger Fabric samples, binaries and docker images (at the time of writing this article latest Hyperledger Fabric version was 1.4.2):

 

$ cd /usr/local/

$ sudo mkdir hyperledger

$ cd hyperledger

$ curl -sSL http://bit.ly/2ysbOFE | sudo bash -s 1.4.2

 

Installing hyperledger/fabric-samples repo

 

===> Cloning hyperledger/fabric-samples repo and checkout v1.4.2

Cloning into 'fabric-samples'...

remote: Enumerating objects: 110, done.

remote: Counting objects: 100% (110/110), done.

remote: Compressing objects: 100% (91/91), done.

remote: Total 3918 (delta 48), reused 80 (delta 18), pack-reused 3808

Receiving objects: 100% (3918/3918), 1.40 MiB | 2.80 MiB/s, done.

Resolving deltas: 100% (1883/1883), done.

Note: checking out 'v1.4.2'.

 

 

===> List out hyperledger docker images

hyperledger/fabric-javaenv     1.4.2               1cd707531ce7        4 weeks ago         1.76GB

hyperledger/fabric-javaenv     latest              1cd707531ce7        4 weeks ago         1.76GB

hyperledger/fabric-ca          1.4.2               f289675c9874        4 weeks ago         253MB

hyperledger/fabric-ca          latest              f289675c9874        4 weeks ago         253MB

hyperledger/fabric-tools       1.4.2               0abc124a9400        4 weeks ago         1.55GB

hyperledger/fabric-tools       latest              0abc124a9400        4 weeks ago         1.55GB

hyperledger/fabric-ccenv       1.4.2               fc0f502399a6        4 weeks ago         1.43GB

hyperledger/fabric-ccenv       latest              fc0f502399a6        4 weeks ago         1.43GB

hyperledger/fabric-orderer     1.4.2               362021998003        4 weeks ago         173MB

hyperledger/fabric-orderer     latest              362021998003        4 weeks ago         173MB

hyperledger/fabric-peer        1.4.2               d79f2f4f3257        4 weeks ago         178MB

hyperledger/fabric-peer        latest              d79f2f4f3257        4 weeks ago         178MB

hyperledger/fabric-zookeeper   0.4.15              20c6045930c8        5 months ago        1.43GB

hyperledger/fabric-zookeeper   latest              20c6045930c8        5 months ago        1.43GB

hyperledger/fabric-kafka       0.4.15              b4ab82bbaf2f        5 months ago        1.44GB

hyperledger/fabric-kafka       latest              b4ab82bbaf2f        5 months ago        1.44GB

hyperledger/fabric-couchdb     0.4.15              8de128a55539        5 months ago        1.5GB

hyperledger/fabric-couchdb     latest              8de128a55539        5 months ago        1.5GB

hyperledger/fabric-tools       1.2.0               379602873003        13 months ago       1.51GB

hyperledger/fabric-ccenv       1.2.0               6acf31e2d9a4        13 months ago       1.43GB

hyperledger/fabric-orderer     1.2.0               4baf7789a8ec        13 months ago       152MB

hyperledger/fabric-peer        1.2.0               82c262e65984        13 months ago       159MB

 

 

At the end of the git checkout we get the list of the installed docker images. To get always the latest Hyperledger Fabric production release you can use the install command with the version number omitted:

 

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

 

 

Also you may want to add that directory location to your PATH environment variable so that these can be picked up without fully qualifying the path to each binary.

 

export PATH=/usr/local/hyperledger/fabric-samples/bin:$PATH

 

 

Creating genesis block for sample first network

 

 

$ cd /usr/local/hyperledger/fabric-samples/first-network

$ sudo ./byfn.sh generate

 

In the end we can run:

 

$ sudo ./byfn.sh up

Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds

Continue? [Y/n] y

proceeding ...

LOCAL_VERSION=1.4.2

DOCKER_IMAGE_VERSION=1.4.2

Creating network "net_byfn" with the default driver

Creating volume "net_orderer.example.com" with default driver

Creating volume "net_peer0.org1.example.com" with default driver

Creating volume "net_peer1.org1.example.com" with default driver

Creating volume "net_peer0.org2.example.com" with default driver

Creating volume "net_peer1.org2.example.com" with default driver

Creating orderer.example.com    ... done

Creating peer0.org1.example.com ... done

Creating peer1.org2.example.com ... done

Creating peer0.org2.example.com ... done

Creating peer1.org1.example.com ... done

Creating cli                    ... done

CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS                  PORTS                      NAMES

75bde727db71        hyperledger/fabric-tools:latest     "/bin/bash"         1 second ago        Up Less than a second                              cli

89dcf04d28b7        hyperledger/fabric-peer:latest      "peer node start"   7 seconds ago       Up 5 seconds            0.0.0.0:9051->9051/tcp     peer0.org2.example.com

55e03ea3efa2        hyperledger/fabric-peer:latest      "peer node start"   7 seconds ago       Up 2 seconds            0.0.0.0:8051->8051/tcp     peer1.org1.example.com

38c6383cc25c        hyperledger/fabric-peer:latest      "peer node start"   7 seconds ago       Up 4 seconds            0.0.0.0:7051->7051/tcp     peer0.org1.example.com

be7dfbb64fe3        hyperledger/fabric-peer:latest      "peer node start"   7 seconds ago       Up 1 second             0.0.0.0:10051->10051/tcp   peer1.org2.example.com

6719885aa069        hyperledger/fabric-orderer:latest   "orderer"           7 seconds ago       Up 3 seconds            0.0.0.0:7050->7050/tcp     orderer.example.com

 


Build your first network (BYFN) end-to-end test

 

Channel name : mychannel

Creating channel…

 

We have successfully installed Hyperledger Fabric 1.4 on Ubuntu 18.04 LTS. You can now use sample networks we have installed or start developing your own blockchain application.




How to Install Hyperledger Fabric 1.4 on Ubuntu 18.04 LTS
In this tutorial, we will install Hyperledger Fabric 1.4 and it’s...
Uniwebb Software Named a Top California Developer in 2019 Ranking Report by Clutch
Top software developer in California. Uniwebb Software is recognized by...

Leave a Comment

comments powered by Disqus