VM Setup
Development Environment Setup
At this stage, we will go through the necessary steps to set up the development environment for the course.
To avoid any irregularities, we recommend using the resulting configuration for the duration of the course. Nevertheless, if you want to substitute the software used or tune the hardware requirements, you can do so at your own risk.
Create a virtual machine
Note: In this section, you can find the instructions on how to create a virtual machine (VM) on your computer. It is also possible to host a VM on a preferred cloud provider where the process described below is fully or partially automated.
Download and install the Oracle VM VirtualBox platform package for your operating
system.
Download a desktop image of Ubuntu 20.04.2.0 LTS (FocalFossa).
Create a new virtual machine:
a. Run Oracle VM VirtualBox Manager.
b. Click on the New (or Ctrl+N ).
c. In the Name and operating system window, enter anyVM’s name and folder, and choose the Linux type and the Ubuntu (64-bit) version.
Next, select a memory size of 4096 MB.
Then, create a hard disk for your virtual machine.
Select the VDI hard disk file type.
Choose the dynamically allocated storage type.
Finally, specify the disk file location and size (25GB is recommended) and click on the Create button.
Once the hard disk file is created, click on the Create button to create a virtual machine.
Configure a VM:
Select a VM from the list in VirtualBox Manager and open the Settings menu ( Ctrl+S ).
In the Settings window, go to System and select the Processor tab. Set the number of processors to 2.
Next, go to Storage and set up the IDE controller.
In the Attributes section on the right side of the window, click on the CD icon, and choose the virtual optical disk file.
In the file system explorer, choose the .iso Ubuntu file that was downloaded in step 2.
Go to Network. In the Adapter 1 tab, choose NAT for the Attached to parameter.
Click on the OK button to accept the changes.
Start the VM and go through the Ubuntu installation process.
Note : It is recommended to install the minimal version of the operating system. In addition, if you created the virtual hard drive file as shown above, you can safely select the Erase disk and install Ubuntu installation type.
Enable full screen mode for the VM (optional).
By default, the interface of the guest operating system(OS) will be displayed in windowed mode. The size of the window is not ideal and if you maximize the window, the resolution of the guest OS user interface will be the same. In most cases, working in a guest OS with low resolution is uncomfortable. In this section, you will learn how to make the VirtualBox full screen for the Ubuntu guest OS.
a. When your VM is powered off, go to Settings and setthe video memory to 128MB if possible. Select the VMSVGA graphics controller.Click on the OK button to save the changes.
b. Install VirtualBox Guest Additions on the guest OS.
i. Start the machine. In the VM window, go to Devices, clickon Insert
Guest Additions CD image to insert the ISO disk intothe virtual CD
drive of the VM.
ii. In the autorun window, click on the Run button and enter a password to confirm running the installer.
Install software dependencies
git
To install git, run the following command in the terminal window.
sudo apt install -y git
Docker
To properly installDocker, follow theofficial installationguide. Make sure that theDockerversion is18.03or greaterby running
docker --version
(Optional) If you do not want to preface thedockercommand withsudo, follow theManage Docker as a non-root userguide.
docker-compose
To installdocker-compose,run
sudo apt install -y docker-compose
or follow theinstallation guideto obtain more recentversions.
Make sure that thedocker-composeversion is1.14.0or greater by running
docker-compose --version
Node.js
To install Node.js version 12.x, run the followingcommands.
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
Golang (optional)
The course uses Node.js as the main programming language,but it can still be useful to have Golang installed to practice with examples providedby Hyperledger Fabric developers.
Download Golang version1.15.xor greater from theofficial website. Navigate to the directory with the downloaded archiveand extract it into the/usr/local directory.
sudo tar -C /usr/local -xzf go1.16.linux-amd64.tar.gz
Note: In the command above, replace the archive namewith the actual downloaded file name.
Add/usr/local/go/binto thePATHenvironment variable.You can do this by adding this line to your/etc/profile(for a system-wide installation)or$HOME/.profile:
export PATH=$PATH:/usr/local/go/bin
Apply the changes.
source $HOME/.profile
build-essential
build-essentialis a package containing tools criticalfor building different software modules. To install the package, run the following commands.
sudo apt update
sudo apt install -y build-essential
Hyperledger Fabric samples, binaries, and Docker images
Run the Hyperledger Fabric bootstrap script from the $HOME/go/src/github.com/hyperledgerfolder.
mkdir -p $HOME/go/src/github.com/hyperledger
cd $HOME/go/src/github.com/hyperledger
curl -sSL http://bit.ly/2ysbOFE | bash -s -- 2.2.2 1.4.
Thebootstrap scriptabove clones thefabric-samplesrepository, downloads all necessary Dockerimages, and places the platform-specific binariesinto thebinfolder in the fabric-samplesrepo.
In thefabric-samples, checkout to thev2.2.2tag.
cd fabric-samples
git checkout v2.2.
Next, clone thefabricrepository and switch the branchto therelease-2.2.
cd ..
git clone https://github.com/hyperledger/fabric
cd fabric
git checkout release-2.
IDE
Note: IDE is a matter of choice. In this section,we describe how to install the Visual Studio Code inside of a VM. However, you can use any preferredtools, establishSecure Shellaccess between your host machine and a VM, mount workspaces,etc.
Go to Ubuntu Software, find Visual Studio Code there,and click install.
Open Visual Studio Code and go to the Extensions ( Ctrl+Shift+X )tab on the left side of
the window. Find and install the plugins for Go, JavaScript,Shell script, and Docker.
Run the Hyperledger Fabric network
test-network
Spin up the network
Navigate to thetest-networkfolder.
# cd ~/go/src/github.com/hyperledger/fabric-samples/test-network/
Spin up the network. As a default configuration, wewill use a network with a predefined
mychannelchannel, CouchDB-based world state, andcertificate authorities as identity
providers.
# ./network.sh up createChannel -ca -s couchdb
Add Org3 (optional)
To add the third organization to the network, followthe steps below.
Spin up the network as shown above.
Navigate to thetest-network/addOrg3folder.
cd
~/go/src/github.com/hyperledger/fabric-samples/test-network/addOrg3
Extend the network.
# ./addOrg3.sh up -ca -s couchdb
Clean network artifacts
To clean network artifacts, follow the steps below.
Navigate to thetest-networkfolder.
# cd ~/go/src/github.com/hyperledger/fabric-samples/test-network/
Clean Org3 artifacts, if necessary.
# ./addOrg3/addOrg3.sh down
Clean remaining network artifacts.
# ./network.sh down
Last updated
Was this helpful?