Build fabric multi-machine deployment environment __ block chain

Source: Internet
Author: User
Tags create directory hyperledger fabric

Recently, in learning Hyperledger fabric, you need to test fabric's multiple-machine deployment environment at the company's request, so there are three virtual machines installed locally for testing. The software used is VirtualBox, the virtual machine version is Ubuntu17.0.4, the virtual machine is nat+host only mode. The IP addresses and functions of three virtual machines are as follows:

192.168.56.105 Orderer node, peer0.org1.example.com node, peer1.org1.example.com node
192.168.56.102 peer0.org2.example.com node, peer1.org2.example.com node
192.168.56.104 peer0.org3.example.com node, peer1.org3.example.com node
I. Pre-deployment preparatory work:

1. Download Docker and Docker-compose

Use the following command to download Docker and Docker-compose:

# Apt Install Docker.io

# Apt Install docker-compose

You can check the Docker and Docker-compose versions after the download is complete

# Docker--version

# Docker-compose--version

2, download go programming language

Download go1.8.3.linux-amd64.tar.gz compressed files on the website and upload them to three virtual machines, create directory/home/fabric-1, upload to this directory, and then unzip:

# tar-c/home/fabric-1-xzf go1.8.3.linux-amd64.tar.gz

Then modify the system environment variables under the/etc/profile folder:

Export Goroot=/home/fabric-1/go

Export gobin= $GOROOT/bin

Export Gopath=/home/workspacego

Export path=.: $PATH: $GOBIN

Remember to use the command source/etc/profile to make the environment variable effective, create the/home/workspacego folder before setting the environment variable, enter go at the command line, and if the following command appears, the installation is successful.


Ii. generation of keys,certificates,artifacts files

1, first from the GitHub download fabric source

# Go get github.com/hyperledger/fabric

After the download is complete, you can see the latest source code under the/home/workspacego folder, we need fabric v1.0.1 version of the source code, so use the following command to switch to the v1.0.1 version:

# Cd/home/workspacego/src/github.com/hyperledger/fabric

# git checkout v1.0.1

2. Download Fabric Docker Images

# cd/home/workspacego/src/github.com/hyperledger/fabric/examples/e2e_cli/

# source Download-dockerimages.sh-c x86_64-1.0.1-f x86_64-1.0.1

Then you will download Docker images, this process takes a while, please wait patiently.

3, download a good image, we will set up the fabric of multiple computer network environment.

First, we want to modify the Configtx.yaml,crypto-config.yaml and generateartifacts.sh files, in the Configtx.yaml file, by default there are two organizations, we need to add an organization ORG3, as shown in the following figure:


and modify organizations tag to increase the ORG3 organization:


In the Crypto-config.yaml file, change the Peerorgs tag:


In generateartifacts.sh, change the function replaceprivatekey (), adding the following line:


Change the function generatechannelartifacts () to add the following line:


After modifying these files, we run the script to generate some of the necessary files:

#./generateartifacts.sh MyChannel

This script will generate the Channel-artifacts folder and the Crypto-config folder, the Channel-artifacts folder contains information about channel, and the Crypto-config folder contains the public key of all nodes. Private key and certificate information. The two folders are only generated on one machine and then copied to the other two machines.

Third, configure the node file

First, create the Docker-compose-peer.yaml file based on the Docker-compose-cli.yaml file:

# CP Docker-compose-cli.yaml Docker-compose-peer.yaml

Modify the Docker-compose-peer.yaml file as follows: (on the 192.168.56.105 machine)


On the 192.168.56.102 machine:


On the 192.168.56.104 machine:


On the 192.168.56.105 machine, add the Docker-compose-orderer.yaml file and add the following:


In addition, in each node also need to modify the corresponding Docker-compose-base.yaml file, add the corresponding node configuration information, note, because I was built on a computer environment, so each node should be configured with a different port.

192.168.56.105:



192.168.56.102:


192.168.56.104:


Once these are configured, we start the peer node on each machine, using the following command:

# docker-compose-f Docker-compose-orderer.yaml up-d

This command starts on the 192,168, 56,105 node and initiates the sorting node

# docker-compose-f Docker-compose-peer.yaml up-d

This command is started on three nodes.

Then in 192. 168.56.105 nodes to enter the container for testing:

# Docker exec-it CLI Bash

#./scripts/scripts.sh MyChannel

The scripts.sh script includes creating channels, adding nodes to channels, downloading Chaincode, initializing Chaincode, and Invoke,query methods. If the execution of the script succeeds, our entire network of multiple-machine deployments is up.

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.