Build the Hyperledger Fabric 1.2.0 environment on Ubuntu 18.04

Source: Internet
Author: User
Tags install go docker ps docker run couchdb hyperledger fabric

00 Introduction

The open source Blockchain distributed ledger--hyperledger Fabric, launched by the Linux Foundation, has ushered in the 1.2.0 version. The project focuses on performance and reliability, as well as cross-industry collaboration to drive blockchain and distributed ledger technology. Hyperledger Fabric can be used for scenarios such as global supply chain management, financial transactions, asset accounts, and a de-centralized social network, but it is not intended to build a crypto currency.

Below we will take you step-by-step to build your own Hyperledger fabric development environment. The old driver has already started, hurry up with ...

01 Operating System Preparation

We chose this version of ubuntu18.04. For details, please refer to our previous article, "Installing Ubuntu operating system for blockchain development in VirtualBox"

02 Installing Curl

In the following steps we need to use the Curl command to download the installation script and other files, so we need to install Curl first, if it has been installed can be skipped.
1th Step: Install curl, if it has been installed can be skipped

$ sudo apt install curl

03 Installing Docker-ce

Docker divides two how, divided into Docker-ce (Community Edition) and Docker-ee (Enterprise Edition). As the poor class representative of me, can only choose to use the community version. Installing Docker-ce on the Ubuntu operating system, in fact, Docker officially offers three ways.

1. Installing via Docker Warehouse

2. Download the. Deb Package Installation

3. Installing through the installation script

Here we choose the 3rd way to install.

1th Step: Download the installation script using Curl

$ curl -fsSL get.docker.com -o get-docker.sh$ ls get*get-docker.sh

2nd Step: Execute the script to install, this step will need to wait a while.

$ sudo sh get-docker.sh

3rd Step: Set to non-root users can also execute Docker, need to add ordinary users to the Docker group, our current user is called Blockchain.

$ sudo usermod -aG docker blockchain

4th step: Perform Hello-world mirroring to verify that Docker is installed successfully. If you see Hello from docker! This message shows the your installation appears to being working this statement indicates that the installation was successful.

$ sudo docker run hello-world...... 一堆提示信息Hello from Docker!This message shows that your installation appears to be working correctly......一堆提示信息

04 Installing Docker-compose

Compose is a Docker container orchestration tool that defines and runs multi-container applications, and can launch multiple containers in a single command. HyperLedger fabric needs to be docker-compose, so we install it ahead of time.

1th Step: Download a version of Docker-compose, download to the/usr/local/bin/docker-compose directory. For more versions, visit: https://github.com/docker/compose/releases

$ sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

Here to explain: Uname-s get linux,uname-m get x86_64. You can perform a view on the copy to command line.

2nd step: Allow other users to execute compose related commands

$ sudo chmod +x /usr/local/bin/docker-compose

3rd Step: Verify the installation is successful

$ docker-compose --versiondocker-compose version 1.21.2, build a133471

05 Install Go

1th step: Download Golang's tar package

$ wget https://storage.googleapis.com/golang/go1.10.1.linux-amd64.tar.gz

For well-known reasons, Google's corresponding site is not accessible by the wall (brother, accept the reality), we have to think of other ways. It is recommended to download the Golang tar package from a third-party image source, recommend the image source https://studygolang.com/dl, open the URL with a browser, and download the tar package for Linux.

2nd step: Unpack the tar package to/usr/local

$ cd 下载$ sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz

3rd Step: Create the Go directory

$ mkdir $HOME/go

4th step: Open ~./BASHRC with VI, configure environment variables

$ vi ~/.bashrc

Add the following environment variable to save the exit

export GOROOT=/usr/local/goexport GOBIN=$GOROOT/binexport PATH=$PATH:$GOBINexport GOPATH=$HOME/go

Make environment variables effective immediately

$ source ~/.bashrc

5th step: Check if Go is installed.

$ go versiongo version go1.10.3 linux/amd64

06 Installing and detecting git

$ sudo apt install git$ git version

06 Download the boot script for fabric

First create the placed directory, then go to the directory, download the script with Curl

$ cd ~$ mkdir hyperledger-fabric$ cd hyperledger-fabric$ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/release-1.2/scripts/bootstrap.sh -o bootstrap.sh$ lsbootstrap.sh

07 Executing the Boot script

This step installs the fabric by running the script, downloads the fabric-sample, and extracts the Docker image. The download process takes a relatively long time.

$ cd ~/hyperledger-fabric/sudo bash ./bootstrap.sh 1.2.0 1.2.0 0.4.10

After downloading, you can perform Docker images to view the Docker-related images that have been downloaded

$ sudo docker images | grep hyperledger*hyperledger/fabric-ca 1.2.0 66cc132bd09c 2 weeks ago 252MBHYPERLEDG ER/FABRIC-CA latest 66cc132bd09c 2 weeks ago 252mbhyperledger/fabric-tools 1.2. 0 379602873003 2 weeks ago 1.51gbhyperledger/fabric-tools latest 379602873         003 2 weeks ago 1.51gbhyperledger/fabric-ccenv 1.2.0 6acf31e2d9a4 2 weeks ago 1.43gbhyperledger/fabric-ccenv latest 6ACF31E2D9A4 2 weeks ago 1.43gbhyperledger/f              Abric-orderer 1.2.0 4baf7789a8ec 2 weeks ago 152mbhyperledger/fabric-orderer Latest        4baf7789a8ec 2 weeks ago 152mbhyperledger/fabric-peer 1.2.0 82c262e65984         2 weeks ago 159mbhyperledger/fabric-peer latest 82c262e65984 2 weeks ago 159mbhyperledger/fabric-zookeeper 0.4.10 2b51158f3898 3 weeks ago 1.44gbhyperledger/fabric-zo              Okeeper latest 2b51158f3898 3 weeks ago 1.44gbhyperledger/fabric-kafka 0.4.10        936aef6db0e6 3 weeks ago 1.45gbhyperledger/fabric-kafka latest 936aef6db0e6 3 weeks ago 1.45gbhyperledger/fabric-couchdb 0.4.10 3092ECA241FC 3 weeks ago 1.61G          BHYPERLEDGER/FABRIC-COUCHDB latest 3092ECA241FC 3 weeks ago 1.61gbhyperledger/fabric-ca        x86_64-1.0.4 8e691b3509bf 8 months ago 238mbhyperledger/fabric-tools x86_64-1.0.4 6051774928a6 8 months ago 1.33gbhyperledger/fabric-orderer x86_64-1.0.4 b17741e7b036 8 mo Nths ago 151mbhyperledger/fabric-peer x86_64-1.0.4 1ce935adc397 8 months ago 154MBhyper   Ledger/fabric-javaenv  Latest a517b70135c7 8 months ago 1.41gbhyperledger/fabric-javaenv x86_64-1.0.4 A51  7b70135c7 8 months ago 1.41gbhyperledger/fabric-ccenv x86_64-1.0.4 856061b1fed7 8 months Ago 1.28GB

08 Adding environment variables

Open ~./BASHRC with VI

$ vi ~/.bashrc

Add the following environment variable to save the exit

export PATH=/home/blockchain/hyperledger-fabric/fabric-samples/bin:$PATH

Make environment variables effective immediately

$ source ~/.bashrc

Verify that the environment variable is successful

$ fabric-ca-client versionfabric-ca-client: Version: 1.2.0 Go version: go1.10 OS/Arch: linux/amd64

09 Creating and Managing Networks

1th Step: Execute the./byfn.sh generate command to generate the appropriate file

$ cd ~/hyperledger-fabric/fabric-samples/first-network/$ ./byfn.sh generateGenerating certs and genesis block for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' secondsContinue? [Y/n] Yproceeding ..........

Where byfn.sh is the startup script that launches this network, in addition to establishing a network containing 4 nodes and an order service, a container is launched to execute scripts to join nodes, deploy and initialize Chaincode in the channel, and execution of transactions on the deployed Chaincode. The default channel name is MyChannel, which generates a digital certificate and key for the network instance, and generates a Genesis block to start the ordering service; Some configuration transactions to configure the channel

2nd Step: Execute./byfn.sh up start Network

$./byfn.sh upstarting for channel ' MyChannel ' with CLI timeout of ' seconds and CLI delay of ' 3 ' secondscontinue? [y/n] Yproceeding ... Local_version=1.2.0docker_image_version=1.2.0creating Network "NET_BYFN" with the default drivercreating volume "net_ Orderer.example.com "with default drivercreating volume" net_peer0.org1.example.com "with default drivercreating volume "Net_peer1.org1.example.com" with the default drivercreating volume "net_peer0.org2.example.com" with default Drivercreating volume "net_peer1.org2.example.com" with default drivercreating peer0.org2.example.com ... donecreating Orderer.example.com ... donecreating peer0.org1.example.com ... donecreating peer1.org1.example.com ... donecreating pe  Er1.org2.example.com ... donecreating cli ... done ____ _____ _ ____ _____/___|    |_   _|  / \    |     _ \  |_   _|\___ \    | |   / _ \   | |_) |   | |   ___) |    | |  / ___ \  |  _ < | |   |____/    |_| /_/   \_\ |_|  \_\   |_|Build your first network (BYFN) end-to-end Testchannel name:mychannelcreating channel .... 

When we see start, it means the start is successful.
Execution end, show end

========= All GOOD, BYFN execution completed ===========  _____   _   _   ____   | ____| | \ | | |  _ \  |  _|   |  \| | | | | | | |___  | |\  | | |_| | |_____| |_| \_| |____/  

The Docker PS command allows you to view the startup of the node.

$ docker Pscontainer ID IMAGE                                              COMMAND CREATED STATUS PORTS names7c129154a34a dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d   01f8346ab "Chaincode-peer.add ..." 5 minutes ago up 5 minutes DEV-PEER1.ORG2.EXAMPLE.COM-MYCC        -1.03746b3295e48 Dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9 "Chaincode   -peer.add ... " 6 minutes ago up 6 minutes DEV-PEER0.ORG1.EXAMPLE.COM-MYCC        -1.0d2cdb7e80c20 Dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b "Chaincode   -peer.add ... "                 6 minutes ago up 6 minutes                                          Dev-peer0.org2.example.com-mycc-1.091034211fb91 Hyperledger/fabric-tools:       Latest "/bin/bash" 7 minutes ago Up 7 minutes clib38fa60f4e76 Hyperledger/fabric-peer:lat Est "peer node start" 7 minutes ago U P 7 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp PEER0.ORG1.EXAMPLE.COM69FD373480CF Hype        Rledger/fabric-peer:latest "Peer node Start" 7 minutes ago up 7 minutes 0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp PEER1.ORG2.EXAMPLE.COMC                                                                      5f1469bf120 Hyperledger/fabric-orderer:latest               "Orderer" 7 minutes ago up 7 minutes 0.0.0.0:7050->7050/tcp orderer.example.com1faf026e D9C9 Hyperledger/fabric-peer:latest "Peer N Ode start "7 minutes ago up 7 minutes 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp PEER1.O                                                                         RG1.EXAMPLE.COM4E0CB9A0A0AA Hyperledger/fabric-peer:latest "Peer node Start" 7 minutes ago up 7 minutes 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053-& Gt;7053/tcp peer0.org2.example.com

       3rd Step: If we want to stop the network, we can execute the./byfn.sh down command to stop the

$./byfn.sh downstopping for channel ' MyChannel ' with CLI timeout of ' seconds and CLI delay of ' 3 ' secondscontinue? [y/n] Yproceeding ... Stopping cli ... donestopping peer0.org1.example.com ... donestopping peer1.org2.example.com ... donest Opping orderer.example.com ... donestopping peer1.org1.example.com ... donestopping peer0.org2.example.com Ving Tsun cli ... doneremoving peer0.org1.example.com ... doneremoving peer1.org2.example.com ... doneremovi  Ng orderer.example.com ... doneremoving peer1.org1.example.com ... doneremoving peer0.org2.example.com ... doneremoving Network net_byfnremoving Volume net_orderer.example.comRemoving volume net_peer0.org1.example.comRemoving volume net_ Peer1.org1.example.comRemoving Volume net_peer0.org2.example.comRemoving Volume net_peer1.org2.example.comRemoving Volume Net_peer0.org3.example.comWARNING:Volume net_peer0.org3.example.com not found. Removing volume net_peer1.org3.example.comwarning:vOlume net_peer1.org3.example.com not found.7c129154a34a3746b3295e48d2cdb7e80c20untagged: DEV-PEER1.ORG2.EXAMPLE.COM-MYCC-1.0-26C2EF32838554AAC4F7AD6F100ACA865E87959C9A126E86D764C8D01F8346AB: LATESTDELETED:SHA256:AF423F72155AFFE6F12819384004FFDBF3506274458E85ACE79B85AFA9F2EDAFDELETED:SHA256: b3fbcd50f54c60d9454612a3ed2a01b0c4d060b27113fc1a9d1289647d43d0fedeleted:sha256 : 71212a99a5c510e8d4e06d998c9238f8aeab0d39b43585c0f592bcb783212115deleted:sha256 : 6a155ef7756a3361c3c549a4bb9bb8b9138ef53ebfada38d65dc00d874ebc5b6untagged: Dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9: LATESTDELETED:SHA256:C4C8845CAB7101EE6A4456EE544C4A6599C42BBCA545B11045D6B47C1223F205DELETED:SHA256: f2f179f4758793728780f909833f710c71f40e77303bd64eb910d572a641c66bdeleted:sha256:0 3f9cd5e163dc2fae818d7864f8f068330eb7e0b0709a34d40dfcf0e40bd5d43deleted:sha256 : 8747af4513550fd8f0f6cfd22c61fd531b073a1a733d02ff6e3fb97fb6def027untagged: Dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latestdeleted:sha256 : 2bffc21709916a8d9bd1c20a65134ac3ca31ef5cc6e1282cea3b6be28d295acbdeleted:sha256 : 7cf57b3452456b8da30c08d92d0c054fe32b2c91cd047dc8075706af2c14dc0ddeleted:sha256 : 6e5b8c88c9d03c7d776953ee8c1b638d02a60438130c9d174b99455bc43d07b8deleted:sha256: b9eee4e0944c3b35fec12aa4bb5624d02825ab12e71d8a6a73e3de9702831382

10 Summary

With the official boot script, we can quickly build the Hyperledger Fabric 1.2.0 environment, if we need to install Docker-ce and docker-compose. In addition, the official boot script path cannot be accessed, so we can go directly to Hyperledger Fabric's github to find the appropriate script to download and then run it.

11 References

1.https://docs.docker.com/install/linux/docker-ce/ubuntu/
2.https://docs.docker.com/compose/install/#install-compose
3.https://blog.csdn.net/qq_30383511/article/details/80354943
4.https://blog.csdn.net/sinat_36742186/article/details/80809954
5.https://www.jianshu.com/p/8beb3a355f99

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.