/ Hyperledger

Installing Hyperledger on Windows

In todays post we are going to focus on setting up our windows machine to run Hyperledger applications. At a minimum your machine should meet the following requirements:

  • 2 GHz dual core processor or better
  • 2 GB system memory
  • 25 GB of free hard drive space
  • Either a DVD drive or a USB port for the installer media

Additionally, your machine should not have Docker installed nor have HyperV enabled. We will be using VirtualBox to run an Ubuntu 16.04 image, which will host our Hyperledger applications. So lets get started.

Installing VirtualBox

Firstly, you will need to download and install the latest version of VirtualBox. Once you are up and running, you should be greeted with a screen similar to this

01_InitialView

Click New to create a new virtual machine, selecting the type as Linux and version as Ubuntu (64-bit)

02_CreateVirtualMachine

For the memory and disk space requirements, just copy my settings here

02_MemorySize

04_HardDisk

Once you have completed the setup you should be greeted by the following screen

05_UbuntuVMCreated

VirtualBox needs a base Ubuntu image to boot off. Download the image and save to your local disk. We will use this iso image to boot from in VirtualBox. Click Start in VirtualBox, browse to the iso disk you just downloaded and follow the on screen prompts. Eventually you should reach a screen like this, where I am setting up my User account

06_UserAccount

Installing required software on Ubuntu

So we have our nice clean fresh image installed, we now need to install the required software in order to run and develop some Hyperledger applications. We will be installing the following:

  1. Curl
  2. Docker
  3. Docker compose
  4. Node.js
  5. Go

Curl

In the terminal window we have already open, type the following

$ sudo apt install curl

followed by

$ curl -V

This should install curl using the apt package manager for Ubuntu and display output similar to the below. I installed version number 7.47.0, but newer packages may have been released when you are running this command.

07_InstallCurl

Docker

Next up is docker. As we have just installed Ubuntu Xenial 16.04 (LTS) in the previous section on our new VM, we can go ahead and install Docker. If you are running a different version of Ubuntu, please follow the installation notes on the docker website. There are some pre-requisites that we need to run through first before we can install Docker.

First up, we need to update the apt packge index:

$ sudo apt-get update

Next we need to install packages to allow apt to use a repository over HTTPS:

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

Add dockers official GPG key to apt

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

We then just need to verify we have the correct key ending in 0EBF CD88

$ sudo apt-key fingerprint 0EBFCD88

We then need to install the correct docker apt repository:

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

If everything has gone well you should out output similar to this

08_InstallDockerCEOutput

Next we need to update our apt-get repositories

$ sudo apt-get update

and finally we can now install Docker CE (CE is the Community Edition - ideal for individual developers and small teams looking to get started with Docker and experimenting with container-based apps)

$ sudo apt-get install docker-ce

Manage Docker as non root user

When docker starts, it looks for a group called docker. Any users within that group are able to run docker without sudo command. So next we need to create a group called docker and add our user to it

$ sudo groupadd docker
$ sudo usermod -aG docker $USER

At this stage in our VM we need log out and restart our VM in order for the group membership policy to be updated. Once logged back on, continue with running Hello World.

To ensure everything has installed successfully you should, you should run dockers equivalent of hello world, which downloads a test image and runs it in a container, printing Hello from Docker to the console, with some other messages. NOTE: We are not using the sudo command here.

$ docker run hello-world

11_RunDockerHelloWorld_withoutSudo

Next up is Docker Compose

Docker Compose

To install docker compose run the following:

$ sudo apt update
$ sudo apt install docker-compose

Now verify the versions installed by running

$ docker --version && docker-compose --version

You should have Docker version 17.03.1-ce or greater, and Docker Compose version 1.9.0 or greater. On my first attempt to install Docker Compose I noticed that my version was actually below 1.9.0. I had to install by directly reaching out to github for the version in question by running the following commands. If you already have the correct version of Docker Compose, then please skip these commands.

$ sudo curl -L https://github.com/docker/compose/releases/download/1.20.1/docker-compose-`uname -s`-`uname -m` > ./docker-compose
$ sudo mv ./docker-compose /usr/bin/docker-compose
$ sudo chmod +x /usr/bin/docker-compose
$ docker-compose --version

Node

Install node using

$ sudo bash -c "cat >/etc/apt/sources.list.d/nodesource.list" <<EOL
deb https://deb.nodesource.com/node_6.x xenial main
deb-src https://deb.nodesource.com/node_6.x xenial main
EOL
$ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
$ sudo apt update
$ sudo apt install nodejs
$ sudo apt install npm
$ node --version && npm --version

Verify that the node version is greater than 6.9 and npm version is greater than 3.x

14_InstallNodeNPM_Part2

Go

Run the following commands on the terminal to install Go:

$ sudo apt update
$ sudo curl -O https://storage.googleapis.com/golang/go1.10.darwin-amd64.tar.gz
$ sudo tar -xvf go1.10.darwin-amd64.tar.gz
$ sudo mv go /usr/local
$ echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
$ source ~/.profile
$ go version

Verify the version of Go is v1.8 or greater.

Conclusion

Now we have our machine up and running, with all the required software, we are now ready to start running some Hyperledger projects. We will be looking at these in future posts.

Gavin Duffy

Gavin Duffy

Software developer based in Dundalk, Ireland. Looking to document my learning of technology. Focused recently on blockchain, domain driven design, azure architecture. Say hi on twitter @triopsy

Read More