How to Install Hyperledger Fabric (for training purposes)?
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmQiNAuqWXG4p528qz1FKbehrrYUbJzvVAUVTtffDVT2dw/image.png)
===================================================================================================
This guide is for people who have little to no experience with Linux, but want to get going with Hyperledger’s Fabric solution.
===================================================================================================
What is Hyperledger?
Hyperledger is the umbrella open source project that the Linux Foundation has created and hosted since 2015. It aims at advancing and promoting cross-industry blockchain technologies to ensure accountability, transparency, and trust among business partners. As a result, Hyperledger makes business network and transactions more efficient.
As it was already mentioned, this tutorial is for people who have little to no experience with Linux, so let’s start from the beginning.
First of all, we need to have a server with Linux installed on it. Of course, you can use VMWARE, Hyper-V (installed on one of your machines) or you can go with some cloud vendor like AWS, GCP, Azure, IBM, etc. Let’s go with Digital Ocean 😊.
Register at Digital Ocean (if you already don’t have an account) and create a new “Droplet”.
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmRQJ88fXAKADvJgsBxNqniYWHvWqDykWbUqTKNVERMvdq/image.png)
Note: You can use something else, not just an Ubunty. However, for the training purposes, we recommend going with Ubunty.
We don’t need a crazy powerful and expensive server. Right now we can go with something that has 4GB of RAM, 2 CPUs and 80 GB disk:
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmXdiCmhAugEJdXEXcr1gFHUbnuDpv57Y2E7QnxtgCLLTq/image.png)
Name your Droplet. As you can see, we named our: CHFA-fra1–02:
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmRiQZ9qgA8xJTLpK7k7rBCw5BnLC9rB6ddMUhJZCVixCp/image.png)
After just a few minutes, our server will be ready. Let’s connect to it. Of course, we need something like putty. Let’s use Kitty 😊.
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmc32crUueKDciZfAKAuTYYAcNJKHChmagUadtQWJgDYru/image.png)
Digital Ocean will ask us to change the password when we connect to our server for the first time. Do so. After password change we should see a similar screen:
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmekYfS5LSja69MK4Eh3MJkPzNgrFNoBECK5etkmC2Y7RJ/image.png)
Now, let’s start the real work. We will begin with cURL install. First, let’s update our package list and install any newer versions using apt :
sudo apt update
sudo apt -y upgrade
Next, we will install curl using apt :
sudo apt install -y curl
The same we installed curl, we will now install git using apt :
sudo apt install git
As you can guess, Python is also required. Since we are running Ubuntu 18.xx, we should already have the Python version we need automatically installed. We will still perform a double check to ensure Python is installed. Type the following command:
python2.7 — version
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmdt6sA9QKavEYhyTj6sPvH2PiX65Cr5DT5oyNCkGhHiEc/image.png)
If for some unknown reason in return we see an error, we can install it using the following command:
sudo apt install -y python-minimal
Note: We also like to install some extra, like Midnight Commander. Execute the following command:
sudo apt install mc
Now it’s a time to install Docker. Before moving on, let’s update our package list again:
sudo apt update
sudo apt upgrade
We will now use apt to install a few packages Docker is dependent upon:
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmbGnfVvWuRmTxyzPWMfPQitjcMqTAwKi6YgMLSjeN6PrH/image.png)
As a next step, we need to curl down our gpg key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmNg8QUgzcJvA5gBFCFwiC8hFqh1p8rX8J7tECt5rLAWkG/image.png)
Let’s validate our fingerprint by executing the following command:
sudo apt-key fingerprint 0EBFCD88
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmYMifqQjnC4S5dboXYQxssUh5aGexwU6uLP8KAruWyxY4/image.png)
Next, let’s add the Docker repository (stable version):
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”
Once more, let’s update our package list:
sudo apt update
Now we will use apt to install the Docker Community Edition:
sudo apt install docker-ce
Next, we need to add our current username to the Docker Group so we can access it in case of “non-root-user” issues:
sudo usermod -aG docker $USER
We also want to set docker to run at system boot. We can do this by executing the following command:
systemctl enable docker
We’ll test the installation and permissions by checking the version of Docker that is installed:
docker run hello-world
We can test our installation by running the hello-world Docker image:
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmQKSt8WqfWZBZtnjL2gnvbCQZPECn5TPfko8DY49EDCux/image.png)
It’s a time to install Docker-Compose. First, we need to pull docker-compose using curl:
sudo curl -L “https://github.com/docker/compose/releases/download/1.18.0/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
We need to change the permissions for docker-compose so we can execute it later:
sudo chmod +x /usr/local/bin/docker-compose
Let’s perform a reboot to ensure everything we’ve done is placed into effect.
sudo reboot now
Now, when all pre-requisites are in place, let’s download Hyperledger to our server.
Please change directories into your desktop:
cd ~/Desktop
Note: If you don’t have a directory called Desktop, we would recommend to create it, because some official material from Linux Foundation training (including provided scripts) does refer to the path, that includes directory Desktop. We can create a required folder by using the following syntax:
mkdir ~/Desktop
Use the following command to curl down the fabric-samples project folder, and Docker images for Hyperledger Fabric v1.4:
curl -sSL https://bit.ly/2ysbOFE | bash -s 1.4.2
Please verify that a new fabric-samples folder is now on your desktop:
ls
Now, take a quick look into what this folder holds.
cd fabric-samples && ls
Lastly, let’s do a sanity checks and verify that everything was correctly installed:
git -v
docker-compose -v
docker -v
Now it’s a time to build our “Starter Network”. “Starter Network” is an extremely scaled-down, barebones Hyperledger Fabric network. It has one peer, one organization, and a single Solo orderer.
Please change directories into fabric-samples:
cd ~/Desktop/fabric-samples
Execute the following commands to Bootstrap the Basics:
sudo wget https://s3.us-east-2.amazonaws.com/lfx-start1/startup.sh
chmod u+x ./startup.sh
./startup.sh
When startup.sh finishes, we will have our Hyperledger installed and ready for the next steps!
Good luck with your studies 😊.
P.S.
Sometimes when we do copy commands from websites and docs (such as .pdf) and past them into a Linux console, they do not work. There are many reasons for that, and we are not going to talk about them in this article. However, to help you to overcome this issue, please download the following text file (save as) that includes all commands mentioned in the article.