fabric-samples/distributed-deploy
zeoio 59bed6da40 distributed-deploy: fix README link image name error
Signed-off-by: zeoio <kinsleer@outlook.com>
2020-04-29 10:01:42 +08:00
..
bcp-install-api distributed-depoly: add copyright to codes, configs file 2020-04-29 10:01:42 +08:00
bcp-install-biz distributed-depoly: add copyright to codes, configs file 2020-04-29 10:01:42 +08:00
bcp-install-common distributed-depoly: add copyright to codes, configs file 2020-04-29 10:01:42 +08:00
bcp-install-main distributed-depoly: add copyright to codes, configs file 2020-04-29 10:01:42 +08:00
static distributed-deploy: update README_CN/EN, add images for them 2020-04-29 10:01:42 +08:00
.gitignore distributed-deploy: delete temp files 2020-04-29 10:01:42 +08:00
AUTHORS distributed-deploy: add LICENSE, AUTHORS, etc 2020-04-29 10:01:39 +08:00
LICENSE distributed-deploy: add LICENSE, AUTHORS, etc 2020-04-29 10:01:39 +08:00
pom.xml distributed-deploy: add distributed deploy tools for prod env 2020-04-29 10:01:39 +08:00
README.md distributed-deploy: fix README link image name error 2020-04-29 10:01:42 +08:00
README_CN.md distributed-deploy: fix README link image name error 2020-04-29 10:01:42 +08:00
start.sh distributed-deploy: add LICENSE, AUTHORS, etc 2020-04-29 10:01:39 +08:00

Introduction

This project is aimed to automate the deployment process of the hyperledger fabric。Hyperledger Fabric is a platform for distributed ledger solutions and the examples released can easily deploy the Hyperledger Fabric network in a standalone machine environment ,including order, peer chaincode and so on。However, If you want to build up the Hyperledger Fabric network in the distributing development environments, it is not a easy task and you have to deploy the modules in each of the machine manually, which is including lots of configurations and commands and inconvenient。Our preject is a tool to help you to install the hyperledger fabric in the distributing development environments easily and conveniently.

The deployment tool provides basic mechanisms for deployment, repairment, and scaling of applications. Firstly, once you have completed the configuration of the orderer and peerwitch include the information of the role,the domain and ip addressthe tool can deploy the orderer and the peer according the configuration you written by itselfSecondly, when the hyperledger fabric network is runningthe tool can scale your hyperledger fabric network up and down with a simple command.

Prerequisites

The tool run at the Linux OS and make sure the requirements as follow:

  • jDK1.8 or above
  • Maven
  • Docker
  • Docker-compose
  • Fabric 1.4.2

How to build

You can build the tool for your machine by executing the following commands:

cd fabric-samples/distributed-deploy/
mvn package -DskipTests

After that the jar is built in the bcp-install-main/target and you enter the root of the fabric and run the command make releaseand you need to copy the configtxgen,configtxlator and cryptogen to the directory of the path as follow:

bcp-install-main/resources/generateInstallPackage/masterPackage/tools/linux

How to use

Install the intall.jar

In this sectionwe will show how to use our tool to deploy the hyperledger fabric network includding two peers named peer0 and peer1 and three orderers named orderer0orderer2orderer3 in the distributing development environments。

After you have built the bcp-install.jar in your project, now you need to copy the jar to the directory named masterPackage and slavePackage, they are both under the generateInstallPackage as the picture1 show;You should notice that you also need to upload the masterPackage and slavePackage to the machines, the masterPackage should be uploaded to master node and slavePackage should be the slave one.

Then we will show you how to deploy the the hyperledger fabric network, in the presentation below, we have two peer nodes named peer0 and peer1,and we have three orderer nodes named oderder0,orderer1,orderer2,and we choose peer0 as master node and the others are the slave ones.

About the initconfig.propertise

In this section, you will learn about the configuration of the file initconfig.propertise. The file initconfig.propertise is located in the directory masterPackage and is important to the tool for the deployment, since it contains the information about fabric network such as info of the organization in the hyperledgerthe channel info such as the chanelName and the information of orderer node and the peer node and so on. The description about the attribution in initconfig.propertise is shown in the table below and in this example, our initconfig.propertise is also shown below。

Attribution Description
network the name of the fabric network
channelName the name of the channel name
orgMSPID the MSPID of the organization
orgName the name of the organization
OrdererDomain the domain of the orderer
PeerDomain the domain of the peer
ordererHostConfig the host of the order node
peerHostConfig the host of the peer node
metricPortConfig the port which the peer use to transaction
couchDBPortConfig the couchdb port

Table description of the attribution about the initconfig.propertise

Config your initconfig.properties

The initconfig.properties in the masterPackage offer the info of all the hyperledger fabric network you want to buildand you need to config the information of your network in itsuch as the ip and port of the node。In the examplejust as the picture2 show belowyou can see that we set all of the ip and port of the nodes of fabric network includding peer0、peer1、orderer0、orderer1 and orderer2.

Intall your hyperledger fabric

When you come to this stepyou can run the script to deploy your network。In previous stepyou have uploaded the slavePackage to every slave machineand under the directorythere is a script named start-installService-slave.sh。Now you need to run the scrip named start-installService-slave.sh in the slavePackage directory in each of the slave machine with the command below,the parameter of p should follow the absolute path the fabric network you want to deploy.In this example, we choose /home/deploy as our deployment path.

./start-installService-slave.sh -p /path/to/deloy

After completed the deployment in the slave machineyou need to deploy the master machine。Remember that in this examplewe choose the peer0 as our master machine and we upload the masterPackage in it and now we need to run the script start-installService-master.sh with the command below。The parameter m is symbol for the pattern you want to deploy your networkyou have two choicesthe newInstall and updateNetworkwhich newInstall means you are the first time to install the fabric network and the updateNetwork means you want to update the network。The parameter p is just as the start-installService-slave.sh aboveshould be follow the absolute path the fabric network you want to deploy。In this examplewe run the command sh start-installService-master.sh -m newInstall -p /home/deploy” to start the deployment in the master machine.

./start-installService-slave.sh -m newInstall/updateNetwork  -p /path/to/deloy

Scale up/down your hyperledger fabric

In this sectionyou will learn how to scale up the hyperledger fabric network using our tool.

When you want to scale up or down your fabric networkyou need to config the config properties initconfig.propertise。For exampleif you want to scale up your networkyou should add the node info such as the domainip and port and so on into the peerHostConfig section or ordererHostConfig sectionaccording to which one you want to add。When you want to scale down the networkyou need to delete the node info in the peerHostConfig section or ordererHostConfig sectionaccording to which one you want to delete.

After you have completed the modification about the initconfig.propertiseyou can startup your peer node or orderer node.

When you want to add a new peer in your fabric networkfirstlyyou should run the start-installService-master.sh in the master machinein this examplewe execute the command belowyou need to pay attention to the path follow the parameter pwhich need to be the same as the path as you intall the network in the master machine.

./start-installService-master.sh -m updateNetwork -p /home/bcp-master

After thatyou need to run the script start-installService-slave.sh in the slave machineit is keypoint that you should only run the script on the machine you want to add to the network.not all the salve machine.And in this example,we run the command below in the slave machine.

./start-installService-slave.sh -p /home/deploy

When you want to add a new orderer in your fabric networkone thing you should notice is the addition of the orderer node will be influence the fabric network and there will be a little difference from the steps when you add a peer node. Firstlyyou should run the start-installService-master.sh in the master machinein this examplewe execute the command belowyou need to pay attention to the path follow the parameter pjust as the mention above,which need to be the same as the path as you install the network in the master machine.

./start-installService-master.sh -m updateNetwork -p /home/bcp-master

After thatyou need to run the script start-installService-slave.sh in the slave machineit is key-point that you should not only run the script on the machine you want to add to the network but also all the salve machines you have intall the orderer node. And in this example,we run the command below in the slave machine.

./start-installService-slave.sh -p /home/deploy

Attribution

Thank you for considering to help out with the source code! We welcome contributions from anyone on the internet, and are grateful for even the smallest of fixes!

If you'd like to contribute to the project, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base.

License

The source code of our project are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. ** Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/.