Codementor Events

Hyperledger Fabric on windows

Published May 09, 2021
Hyperledger Fabric on windows

In this article we are going to explore Hyperledger Fabric installation on windows machine, basically a setup for development environment. Hyperledger Fabric is permissioned dristributed ledger.

My main intention to write this post is to help people who want to get started with hyperledger and their primary operating system is windows.

We are going to user Windows 10, with OS build version 19041 or higher because that's minimum version required by WSL(Windows Subsystem for Linux).

WSL lets developers run Linux environment on windows machine as a sub system.

We will install WSL2 on windows machine manully

Open power shell in Admin mode.
Note: To use WSL2 below mentioned OS Build is needed
Image 2.png

  1. Enable windows SubSystem for Linux
    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem Linux /all /norestart

    Image 4.png

    After running above command to verify that Windows subsystem is enabled refer to below image
    Image 001.png

  2. Enable Virtual Machine feature
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    Image 7.png
    After running above command to verify that Virtual machine platform is enabled refer to below image
    Image 002.png

  3. Download linux kernel update package:
    To update the WSL package download setup at the below-mentioned link, it needs admin privilege.
    WSL2 Linux kernel update package for x64 machines
    Image 10.png
    Image 11.png
    Image 11.png

  4. Set WSL-2 as default version
    wsl --set-default-version 2
    Image 12.png
    WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel
    For information on key differences with WSL 2 please visit https://aka.ms/wsl2

  5. Install Ubuntu app from windows store:

    • Open the Microsoft Store and install Ubuntu 20.04 LTS here

    Image 13.png
    Image 15.png

  6. Install windows terminal

    • It enables multiple tabs, quickly between the Linux command line and the windows command prompt.
      Image 16.png

    Note: Above terminal is a utility and it is very productive.

  7. Ubuntu command line setup:

    Note: You have to run the Windows terminal with Administrator rights.

    • Open Windows Terminal and add a new ubuntu tab, you won’t be able to see the ubuntu terminal. Under add new terminal section.
      Image 18.png
    • Open Installed, “Ubuntu 20.04 LTS” once, So that it will be linked with Windows terminal.
      Image 18.png
    • After following step 2 then Ubuntu will be registered with Windows Terminal.
      Image 20.png
  8. Updating and installing basic packages for Ubuntu.
    sudo apt update && sudo apt upgrade
    Image 29.png
    for more detail, please refer here.

  9. Docker Installation on Windows
    System requirement for docker installation on windows 10 OS builds version 1903 or higher.

    we have already enabled WSl2 on windows refer steps 1-4

    • Virtualization should be enabled on the windows machine, most of it supports
      Image 22.png

    • Download Docker for windows latest version from here

    • Install Docker
      Image 23.png
      Image 24.png

    • Open docker and it will be running in apptray

    • To check docker version run following below command
      docker –version
      docker-compose --version
      Image 25.png

  10. Enable Docker for ubuntu
    Image 27.png

    1. Go to Settings
    2. Resources
    3. WSL integration
    4. Enable Ubuntu-20.04
    5. Then hit Apply & restart
    6. This may take few minutes
    7. After Enabling this we will get docker in the ubuntu command line
      Image 013.png
    8. Run following command to check if you are able to access it on Ubuntu
      docker –version
      docker-compose --version
      Image 28.png
  11. Hyperledger fabric installation on Linux(Ubuntu)
    Run following command to install and update basic packages on Ubuntu
    sudo apt update
    sudo apt upgrade
    Image 29.png

    After running above command most of common required packages will be in installed.
    We need to make sure below following packages will be installed.

    • cURL
      Check if cURL already exists
      curl -v
      Image 30.png
      If cURL doesn't exists then install it via following command
      sudo apt-get install curl

    • Go
      Check if Go lang exists
      go version
      Image 31.png
      If Go doesn't then install with following steps:
      Download the Go lang package for Linux from here.

      sudo wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz
      Image 33.png

      The following command will extract the zip file at the downloaded location tar xvf go1.16.3.linux-amd64.tar.gz
      Image 34.png
      Set GOPATH using following command

      export GOPATH=$HOME/go
      export PATH = $PATH:$GOPATH/bin
      Image 38.png

      Run the following command to verify that Go lang is installed successfully

      go version
      Image 35.png

    • Docker
      Doker we have already installed in the previous section and with help of WSL.
      Run the following command to verify it

        `docker --version`
      

      docker-compose --version
      Image 25.png

    • Git
      Run the following command to if git is installed
      git --version
      Image 37.png

  12. Install Hyperledger Fabric and Fabric samples

    Note: Hyperledger fabric version is 2.3.2

    • Create a directory with following command
      Creates a new Directory: mkdir -p $HOME/go/src/github.com/
      Navigate to that created directory: cd $HOME/go/src/github.com/
      Image 39.png

    • Download the latest release of fabric samples and docker images.
      The following link will clone Fabric-samples located at
      https://github.com/hyperledger/fabric-samples
      Run following command under $HOME/go/src/github.com/ directory
      curl -sSL https://bit.ly/2ysbOFE | bash -s
      Image 40.png

    • After running below respective images will be downloaded to docker
      Image 42.png

    • After downloading, your folder structure looks like below
      Image 014.png

    • Open folder in your favourite editor, mine is vscode
      simply run following command
      code .
      Image 43.png

      Note: if you don't have installed vscode it will install first then you
      need to run same command again

  13. Running fabric test network:

    • Open windows terminal and navigate to fabric folder
      cd $wsl
      cd go/src/github.com/fabric-samples
      Image 015.png
    • Go to test-network
      cd test-network
    • Run following command to remove existing any container or artifacts form previous run.
      ./network.sh down
      Image 005.png
    • Running following will boot up fabric test network
      ./network.sh up
      Image 006.png
    • Run following command to list down all running docker images in docker
      docker ps -a
      Image 007.png
      Same you can look at docker GUI
      Image 009.png

Now, we have succesfully installed and ran fabric on windows machine.
I hope this helps you to set up hyperledger fabric on windows machine

Discover and read more posts from arvind maurya
get started
post commentsBe the first to share your opinion
Jeremy Blong
a year ago

thanks for this!! I was running into many binary/config errors along the setup process even while using WSL but this clarified it… bump for the algo! Very helpful article - bookmarked!

arvind maurya
a year ago

Great to hear that. let me know if you need me to write on another topic that might help you!!

Jeremy Blong
a year ago

Thanks bud! If I hit any serious roadblocks I’ll reach out here and trade work for guidance if need be - I can code ya something but I’m fairly certain it should be fairly simplistic or straight-forward from what I’ve done with HLF so far but I’ll def reach out if need be :D

Oumar DIA
2 years ago

Hi,
I am having trouble installing vscode in Docker. Having an error @ “code .”
Help please

Anil Varma
3 years ago

Great compilation steps… saved hell amount of time for configuring on windows 10 Home

Subhra Sankha Bose
2 years ago

did you able to setup Successfully following the steps?

Show more replies