简体   繁体   English

单机部署两个fabric网络|| Hyperledger fabric2.0 Blockchain with convector cli

[英]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 中分别存储两个或多个结构网络的数据

1. Analyze the convector first. 1. 先分析对流。

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",

2. What does the hurl new command do? 2. hurl new命令有什么作用?

https://github.com/worldsibu/hurley https://github.com/worldsibu/hurley

  • Hurley is the development environment toolset for Enterprise Blockchain projects. Hurley 是企业区块链项目的开发环境工具集。 It supports Hyperledger Fabric and is being ported to support other chain technologies.它支持 Hyperledger Fabric,并且正在被移植以支持其他链技术。
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网络,当然,你需要独立完成这个工作。

3. Check if the two networks are up. 3. 检查两个网络是否正常。

  • 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 next best thing is the options below.下一个最好的事情是下面的选项。

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. -> 只有工件可供操作,但只有一个实际网络启动。

4. Modify all conflicting items in docker-compose.yaml 4.修改docker-compose.yaml中所有冲突项

  1. docker networks docker 网络
  2. container name容器名称
  3. host port number主机端口号
# 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

4. Generate new artifacts 4. 生成新工件

cd $PWD/.test-env-1 && \
chmod +x generator.sh && \
./generator.sh
cd $PWD/.test-env-2 && \
chmod +x generator.sh && \
./generator.sh

5. Network up 5.网络起来

# 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

6. Modify commands in convector 6.修改convector中的命令

  • The main thing is, you need to modify the commands so that the network issuing convector's commands changes according to the path of the blockchain network's configuration.最主要的是,你需要修改命令,使发出convector命令的网络根据区块链网络配置的路径而改变。

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.

相关问题 在Hyperledger Fabric区块链上修改链码后升级网络配置 - Upgrade network configuration after chaincode modification on hyperledger Fabric blockchain 在Amazon Managed Blockchain Hyperledger Fabric 1.2上以REST API部署和公开Chaincode - Deploy and expose chaincode as REST api on amazon managed blockchain hyperledger fabric 1.2 在 HyperLedger Fabric 中实现高吞吐量的网络配置 - Network Configuration to achieve high throughput in HyperLedger Fabric 无法在 Hyperledger Fabric 上调用 nodejs 链代码 - Amazon Managed Blockchain - Can't invoke nodejs chaincode on Hyperledger Fabric - Amazon Managed Blockchain Hyperledger Fabric First Network的客户端应用程序 - Client app for Hyperledger fabric first network 无法将Hyperledger Fabric网络连接到资源管理器 - Unable to connect hyperledger fabric network to the explorer 有没有办法在 Hyperledger Fabric 中自动生成连接配置文件(使用 CLI)? - Is there a way to generate Connection Profile in Hyperledger Fabric automatically (with CLI)? 使用 javascript 从网络客户端访问 Hyperledger Fabric 2.0 中的私钥? - Accessing private keys in Hyperledger Fabric 2.0 from a webclient using javascript? Hyperledger结构:由于缺少配置数据,网络配置无效 - Hyperledger fabric : Invalid network configuration due to missing configuration data Hyperledger Fabric 按键查询 - Hyperledger fabric query by key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM