Hyperledger Fabric is one of the leading enterprise blockchain platforms. Today we are going to learn how to install it on the latest version of ubuntu 20.04 LTS.
We will be installing the following:
- Docker and Docker Compose
- Go Programming Language
- Node.js Runtime and NPM
Step 1: Create a new USER
Setup a new user, it’s good practice not to use root to install these software.
sudo adduser "name of new user"
Now we need to add our user to the sudo group.
sudo usermod -aG sudo "name of new user"
Switch to our newly created user:
su - "name of new user"
Step 2: Install Prerequisites
Install Git, cURL, docker, docker-compose, Node.js , NPM & Python
sudo apt-get update
sudo apt-get install git curl docker.io docker-compose nodejs npm python
Update NPM to 5.6.0 and Configure Docker
sudo npm install [email protected] -g
sudo usermod -a -G docker $USER
sudo systemctl start docker
sudo systemctl enable docker
Install and configure GoLang
wget https://dl.google.com/go/go1.13.6.linux-amd64.tar.gz tar -xzvf go1.13.6.linux-amd64.tar.gz #Move go to local sudo mv go/ /usr/local #Create a new folder go inside home cd ~ mkdir go #open .bashrc pico ~/.bashrc #go to the end of bashrc file and add the following: export GOROOT=/usr/local/go export GOPATH= /home/"name of new user"/go export PATH=$PATH:$GOROOT/bin #replace "name of new user" with your newly created user
Log out and Log back as a new user
su - "name of new user"
Step 3: Install Hyperledger Fabric Binaries, Docker Containers & Samples
Step 4: Test the Installation
To make sure that everything works fine, you can deploy a test network by using scripts that are provided in the
fabric-samples repository. The test network is provided for learning about Fabric by running nodes on your local machine. Developers can use the network to test their smart contracts and applications. The network is meant to be used only as a tool for education and testing and not as a model for how to set up a network.
Navigate to the test network directory by using the following command:
In this directory, you can find an annotated script,
network.sh, that stands up a Fabric network using the Docker images on your local machine. You can run
./network.sh -h to print the script help text:
From inside the
test-network directory, run the following command to remove any containers or artifacts from any previous runs:
You can then bring up the network by issuing the following command. You will experience problems if you try to run the script from another directory:
This command creates a Fabric network that consists of two peer nodes, one ordering node. No channel is created when you run
./network.sh up, though we will get there in another guide. If the command completes successfully, you will see the logs of the nodes being created:
Check if all the docker containers are running:
docker ps -a
Clean the Network
Congratulations! You have successfully installed Hyperledger Fabric in your machine.