Reader small image

You're reading from  Hyperledger Cookbook

Product typeBook
Published inApr 2019
Reading LevelBeginner
PublisherPackt
ISBN-139781789534887
Edition1st Edition
Languages
Concepts
Right arrow
Authors (3):
Xun (Brian) Wu
Xun (Brian) Wu
author image
Xun (Brian) Wu

Xun (Brian) Wu is a senior blockchain architect and consultant. With over 20 years of hands-on experience across various technologies, including Blockchain, big data, cloud, AI, systems, and infrastructure, Brian has worked on more than 50 projects in his career. He has authored nine books, which have been published by O'Reilly, Packt, and Apress, focusing on popular fields within the Blockchain industry. The titles of his books include: Learn Ethereum (First Edition), Learn Ethereum (Second Edition), Blockchain for Teens, Hands-On Smart Contract Development with Hyperledger Fabric V2, Hyperledger Cookbook, Blockchain Quick Start Guide, Security Tokens and Stablecoins Quick Start Guide, Blockchain by Example, and Seven NoSQL Databases in a Week.
Read more about Xun (Brian) Wu

Chuanfeng Zhang
Chuanfeng Zhang
author image
Chuanfeng Zhang

Chuanfeng Zhang is enthusiastic and passionate about technologies and trading and data analysis, with 20 years' experience in both the technology and finance sectors. He has worked at top investment banks and technology firms including Goldman Sachs, Credit Suisse, and IBM. He has led, designed, and successfully developed many enterprise-scale systems with diverse architectures for algorithmic trading, order management, risk management, business intelligence, and more.
Read more about Chuanfeng Zhang

Zhibin (Andrew) Zhang
Zhibin (Andrew) Zhang
author image
Zhibin (Andrew) Zhang

Andrew Zhang is an IBM Watson Cloud Advocate. He has many years of experience in cloud platforms, big data analytics, and machine learning. He works with start-ups and enterprise clients in the government, education, healthcare, and life science industries. His current interests are in embedding AI and blockchain open source technologies for consumer and enterprise applications. In his spare time, Andrew enjoys reading, traveling, and spending time with his family and friends.
Read more about Zhibin (Andrew) Zhang

View More author details
Right arrow

Installing Hyperledger Fabric on AWS

To install and run the recipe in this chapter, you need AWS EC2 Ubuntu Server 16.04 with 4 GB of memory. We will use the Fabric 1.3 release as it is the most stable release as of writing this recipe.

Getting ready

From the Hyperledger Fabric website (https://hyperledger-fabric.readthedocs.io/en/release-1.3/prereqs.html), the prerequisites for this recipe are as follows:

  • Operating systems: Ubuntu Linux 14.04 / 16.04 LTS (both 64-bit), or macOS 10.12
  • cURL tool: The latest version
  • Docker engine: Version 17.06.2-ce or greater
  • Docker-compose: Version 1.14 or greater
  • Go: Version 1.10.x
  • Node: Version 8.9 or higher (note: version 9 is not supported)
  • npm: Version 5.x
  • Python: 2.7.x

We chose Amazon Ubuntu Server 16.04. If you don't have experience with installing Ubuntu in EC2, please refer to the AWS document: https://aws.amazon.com/getting-started/tutorials/launch-a-virtual-machine/.

You can also chose to install Ubuntu in your local machine virtual box. A tutorial for this can be found at http://www.psychocats.net/ubuntu/virtualbox or https://askubuntu.com/questions/142549/how-to-install-ubuntu-on-virtualbox.

How to do it...

To install Hyperledger on AWS, follow these steps:

  1. Execute the following commands to update the software on your system:
        $ sudo apt-get update
  1. Install curl and the golang software package:
        $ sudo apt-get install curl
$ sudo apt-get install golang
$ export GOPATH=$HOME/go
$ export PATH=$PATH:$GOPATH/bin
  1. Install Node.js, npm, and Python:
        $ sudo apt-get install nodejs
$ sudo apt-get install npm
$ sudo apt-get install python
  1. Install and upgrade docker and docker-compose:
        $ sudo apt-get install docker
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg |
sudo apt-key add -

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

$ sudo apt-get update
$ apt-cache policy docker-ce
$ sudo apt-get install -y docker-ce
$ sudo apt-get install docker-compose
$ sudo apt-get upgrade

  1. Let's customize and update Node.js and golang to the proper versions:
        $ wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
$ tar -xzvf go1.11.2.linux-amd64.tar.gz
$ sudo mv go/ /usr/local
$ export GOPATH=/usr/local/go
$ export PATH=$PATH:$GOPATH/bin
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
$ sudo apt-get install -y nodejs
  1. Verify the installed software package versions:
        $ curl --version
$ /usr/local/go/bin/go version
$ python -V
$ node -v
$ npm -version
$ docker --version
$ docker-compose --version

The result should look like this:

  1. Install Hyperledger Fabric 1.3:
        $ curl -sSL http://bit.ly/2ysbOFE | sudo bash -s 1.3.0

It will take a few minutes to download the Docker images. When it is done, the results should look like this:

This completes the installation of the Hyperledger Fabric on the AWS EC2 machine. We will build up the network in the next recipe.

How it works...

We installed several prerequisites, so let's explain what each software package is and how they work together to build the Hyperledger Fabric platform:

  • cURL: A tool used to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP, or FILE). The command is designed to work without user interaction.
  • Docker: A tool to create, deploy, and run applications using containers. Containers allow developers to package applications with all of the parts it needs, such as libraries and other dependencies, and ship it out as one package.
  • Docker Compose: It is a tool which is used for defining and running Multi-container application. You can create and start all the services with help of a single command from your configuration YAML file.
  • Go: An open source programming language that makes it easy to build simple, reliable, and efficient software. Hyperledger Fabric is primarily developed using the Go language.
  • Node.js: A platform built on Chrome's JavaScript runtime to easily build fast and scalable network applications. Node.js is considered to be more lightweight and efficient since it uses event-driven, non-blocking I/O models, which make it more feasible for data-intensive real-time applications.
  • npm package manager: A tool that will allow you to install third-party libraries (other people's code) using the command line.
  • Python: A general-purpose programming language for developing both desktop and web applications. Python is also used to develop complex scientific and numeric applications. It is designed with features to facilitate data analysis and visualization.

With this Hyperledger Fabric installation, it will download and install samples and binaries to your system. The sample applications installed are useful for learning the capabilities and operations of Hyperledger Fabric:

  • balance-transfer: A sample Node.js app to demonstrate fabric-client and fabric-ca-client Node.js SDK APIs.
  • basic-network: A basic network with certificates and key materials, predefined transactions, and one channel, mychannel.
  • bin: Binary and scripts for fabric-ca, orderer, and peer.
  • chaincode: Chaincode developed for fabcar, marbles, and a few other examples.
  • chaincode-docker-devmode: Develops chaincode in dev mode for rapid code/build/run/debug.
  • config: YAML files to define transaction, orderer, organization, and chaincode.
  • fabcar: A sample Node.js app to demonstrate the capabilities with chaincode deployment, query, and updating the ledger.
  • fabric-ca: Uses the Fabric CA client and server to generate all crypto material and learn how to use attribute-based access control.
  • first-network: Builds the first hyperledger fabric network with byfn.sh and eyfn.sh.
  • Jenkinsfile: Jenkins is a suite of plugins that supports implementing and integrating continuous-delivery pipelines. The definition of a Jenkins pipeline is typically written into a text file, Jenkinsfile, which in turn is checked into a project's source-control repository.
  • scripts: There are two scripts in this directory: bootstrap.sh and Jenkins_Scripts.

Now that we have successfully installed Hyperledger Fabric on an AWS EC2 virtual machine, in the next recipe, we will set up the first Hyperledger Fabric network.

Previous PageNext Page
You have been reading a chapter from
Hyperledger Cookbook
Published in: Apr 2019Publisher: PacktISBN-13: 9781789534887
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (3)

author image
Xun (Brian) Wu

Xun (Brian) Wu is a senior blockchain architect and consultant. With over 20 years of hands-on experience across various technologies, including Blockchain, big data, cloud, AI, systems, and infrastructure, Brian has worked on more than 50 projects in his career. He has authored nine books, which have been published by O'Reilly, Packt, and Apress, focusing on popular fields within the Blockchain industry. The titles of his books include: Learn Ethereum (First Edition), Learn Ethereum (Second Edition), Blockchain for Teens, Hands-On Smart Contract Development with Hyperledger Fabric V2, Hyperledger Cookbook, Blockchain Quick Start Guide, Security Tokens and Stablecoins Quick Start Guide, Blockchain by Example, and Seven NoSQL Databases in a Week.
Read more about Xun (Brian) Wu

author image
Chuanfeng Zhang

Chuanfeng Zhang is enthusiastic and passionate about technologies and trading and data analysis, with 20 years' experience in both the technology and finance sectors. He has worked at top investment banks and technology firms including Goldman Sachs, Credit Suisse, and IBM. He has led, designed, and successfully developed many enterprise-scale systems with diverse architectures for algorithmic trading, order management, risk management, business intelligence, and more.
Read more about Chuanfeng Zhang

author image
Zhibin (Andrew) Zhang

Andrew Zhang is an IBM Watson Cloud Advocate. He has many years of experience in cloud platforms, big data analytics, and machine learning. He works with start-ups and enterprise clients in the government, education, healthcare, and life science industries. His current interests are in embedding AI and blockchain open source technologies for consumer and enterprise applications. In his spare time, Andrew enjoys reading, traveling, and spending time with his family and friends.
Read more about Zhibin (Andrew) Zhang