[英]Deploy two fabric network on single machine || Hyperledger fabric2.0 Blockchain with convector cli
Could you please help me to deploy two fabric network on single machine so that it will run two different applications.您能否帮我在一台机器上部署两个结构网络,以便它运行两个不同的应用程序。 when I create new application it will clear all data of other application(fabric network) from couchdb.
当我创建新应用程序时,它将从 couchdb 清除其他应用程序(结构网络)的所有数据。
How can we separately store data for two or more fabric network in couchdb我们如何在 couchdb 中分别存储两个或多个结构网络的数据
npm run env:restart
https://github.com/hyperledger-labs/convector https://github.com/hyperledger-labs/convector
// hyperledger-labs/convector/package.json
"env:restart": "hurl new -p $PWD/.convector-dev-env",
hurl new
command do? hurl new
命令有什么作用? https://github.com/worldsibu/hurley https://github.com/worldsibu/hurley
hurl new
[-n --network <path>] # Path to the network definition file
[-o --organizations <amount-of-organizations>]
[-u --users <users-per-organization>]
[-c --channels <amount-of-channels>]
[-p --path <path-to-install-the-network>]
[-i --inside] # Whether or not the `hurl` command will runs inside the same Docker network where the blockchain was provisioned
[--skip-cleanup] Skips cleaning up the <path>/data folder
It is a command that creates network artifacts of the fabric through the hurl command and executes them.它是一个通过 hurl 命令创建结构的网络工件并执行它们的命令。 If you want to build multiple fabric networks during this process, of course, you need to work to do this independently.
如果你想在这个过程中构建多个Fabric网络,当然,你需要独立完成这个工作。
Analyzing hurl is as follows.分析hurl如下。
First, according to the input parameter, createNetwork is called, which calls the init function by the constructor of the cli class.首先根据入参调用createNetwork,通过cli class的构造函数调用init function。
The init function creates new configurations and starts up the network. init function 创建新配置并启动网络。
At this time, new configurations are created based on a predefined template, and you look at the docker-compose side of the templates.这时候,新的配置是基于预定义的模板创建的,你看一下模板的 docker-compose 端。
The container names of docker-compose are all static and the peer's ports are already bound and distributed. docker-compose的容器名称都是static,peer的端口已经绑定分发。
In other words, it has been developed in a structure in which collision can only occur and two networks cannot be launched.换句话说,它已经发展成一个只能发生碰撞而不能启动两个网络的结构。
To solve this, hurl must be changed or a new blockchain network must be artificially built.为了解决这个问题,必须改变 hurl 或者必须人为地建立一个新的区块链网络。
The --skip-cleanup
option is a parameter that does not delete data. --skip-cleanup
选项是不删除数据的参数。
hurl new -p $PWD/.test-env-1 --skip-cleanup
hurl new -p $PWD/.test-env-2 --skip-cleanup
-> remains two blockchain configurations -> 保留两个区块链配置
-> there are only artifacts for operation, but only one of the actual networks is up. -> 只有工件可供操作,但只有一个实际网络启动。
# clean network
docker stop $(docker ps -a | awk '$2~/hyperledger/ {print $1}')
docker rm -f $(docker ps -a | awk '$2~/hyperledger/ {print $1}') $(docker ps -a | awk '{ print $1,$2 }' | grep dev-peer | awk '{print $1 }') || true
docker rmi -f $(docker images | grep dev-peer | awk '{print $3}') || true
# in $PWD/.test-env-1, all files
# (docker-compose, crypto-config, configtx, network-profiles ...)
hurley_dev_net -> hurley_dev_net-1
*hurley.lab -> *hurley.lab-1
# in $PWD/.test-env-2, all files
# (docker-compose, crypto-config, configtx, network-profiles ...)
hurley_dev_net -> hurley_dev_net-2
*hurley.lab -> *hurley.lab-2
# in $PWD/.test-env-2, docker-compose.yaml
host ports -> +1000
ex1) 7050:7050 -> 8050:7050
ex2) 7051:7051 -> 8051:8051
cd $PWD/.test-env-1 && \
chmod +x generator.sh && \
./generator.sh
cd $PWD/.test-env-2 && \
chmod +x generator.sh && \
./generator.sh
# change shell script
vi $PWD/.test-env-1/restart.sh
vi $PWD/.test-env-2/restart.sh
# delete below lines
`
ITEMS=$(docker ps -a | awk '$2~/hyperledger/ {print $1}')
if [ ! -z "$ITEMS" ]; then
docker stop $(docker ps -a | awk '$2~/hyperledger/ {print $1}')
docker rm -f $(docker ps -a | awk '$2~/hyperledger/ {print $1}') $(docker ps -a | awk '{ print $1,$2 }' | grep dev-peer | awk '{print $1 }') || true
docker rmi -f $(docker images | grep dev-peer | awk '{print $3}') || true
fi
`
# first network up
cd $PWD/.test-env-1 && \
chmod +x restart.sh && \
./restart.sh
# second network up
cd $PWD/.test-env-2 && \
chmod +x restart.sh && \
./restart.sh
for example例如
// origin
"cc:install": "f() { hurl install $1 node --debug -P ./chaincode-$1 -p $PWD/.convector-dev-env; }; f"
// after
"cc:install-test-1": "f() { hurl install $1 node --debug -P ./chaincode-$1 -p $PWD/.test-env-1; }; f"
"cc:install-test-2": "f() { hurl install $1 node --debug -P ./chaincode-$1 -p $PWD/.test-env-2; }; f"
+
Since convector and hurley codes are tailored to a single network, it is correct to use a tool other than the above tool if you want to launch multiple networks. +
由于对流和 hurley 码是针对单个网络量身定制的,因此如果您想启动多个网络,则使用上述工具以外的工具是正确的。
+
Also, it is strange to launch a multi fabric network on a single host. +
此外,在单个主机上启动多结构网络很奇怪。 Rather, think about how to split the channels.相反,考虑如何拆分渠道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.