问题描述
我正在尝试使用超级分类帐结构创建两个渠道.在一个渠道中,将有两个组织,在另一个渠道中,将有另外两个组织.在每个组织中,将有两个同行.因此,共有4个组织的8个同行具有两个渠道.到目前为止,我已经完成了这些操作:
I am trying to make two channels with hyper ledger fabric. In one channel there will be two organizations and in another channel, there will be another two organizations. In every organization, there will be two peers. So total 8 peers in 4 organizations with two channels. Until now I have done these:
- 在
crypto-config.yaml
文件中,我声明了一个订购者和四个组织.在每个组织中,我都声明模板数量为2,用户数量为1(任何人都可以解释模板数量的含义吗?同行总数是多少?) - 然后使用
cryptogen generate --config=./crypto-config.yaml
命令生成密钥和证书. - 在
configtx.yaml
文件中,我声明了两个带有其组织名称的通道:
- In
crypto-config.yaml
file I have declared one orderer and four organizations. In every organization, I have declared template count: 2 and users count: 1 (can anyone please explain the meaning of template count? Is it a total number of peers?) - Then used
cryptogen generate --config=./crypto-config.yaml
command to generate keys and certificates. - In
configtx.yaml
file, I have declared two channels with their organization's name:
个人资料:
FourOrgsOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
TwoOrgsChannel1:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
TwoOrgsChannel2:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org3
- *Org4
组织:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/acme.com/msp
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.acme.com/msp
AnchorPeers:
- Host: peer0.org1.acme.com
Port: 7051
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/org2.acme.com/msp
AnchorPeers:
- Host: peer0.org2.acme.com
Port: 7051
- &Org3
Name: Org3MSP
ID: Org3MSP
MSPDir: crypto-config/peerOrganizations/org3.acme.com/msp
AnchorPeers:
- Host: peer0.org3.acme.com
Port: 7051
- &Org4
Name: Org4MSP
ID: Org4MSP
MSPDir: crypto-config/peerOrganizations/org4.acme.com/msp
AnchorPeers:
- Host: peer0.org4.acme.com
Port: 7051
订购者:& OrdererDefaults
OrdererType: solo
Addresses:
- orderer.acme.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Kafka:
Brokers:
- 127.0.0.1:9092
Organizations:
应用程序:& ApplicationDefaults
Organizations:
-
然后我使用此命令创建了创世块
Then I have created genesis block using this command
configtxgen -profile FourOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
可能我需要做两个创世记块,因为有两个渠道.在那种情况下,将是什么而不是上面的命令?
Probably, I need to make two genesis block as there are two channels. In that case, what will be the command instead of above one?
-
我使用以下命令进行通道事务和锚定对等事务.
I have used following commands to make channel transaction and anchor peer transaction.
configtxgen -profile TwoOrgsChannel1 -outputCreateChannelTx ./channel-artifacts/channel1.tx -channelID mychannel1
configtxgen -profile TwoOrgsChannel2 -outputCreateChannelTx ./channel-artifacts/channel2.tx -channelID mychannel2
configtxgen -profile TwoOrgsChannel1-outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel1 -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel1 -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel1 -asOrg Org2MSP
configtxgen -profile TwoOrgsChannel2-outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID mychannel2 -asOrg Org3MSP
configtxgen -profile TwoOrgsChannel2-outputAnchorPeersUpdate ./channel-artifacts/Org4MSPanchors.tx -channelID mychannel2 -asOrg Org4MSP
最后使用此命令组成:
Finally used this command to make up:
CHANNEL_NAME=mychannel1 docker-compose -f docker-compose-cli.yaml up –d
每当我尝试运行时:
CHANNEL_NAME=mychannel2 docker-compose -f docker-compose-cli.yaml up –d
这意味着已经有同行在运行.
It is saying already peers are running.
所以我的问题是:
- 如何为不同的组织创建多个渠道?一世没有得到任何详尽的例子.
- 是否可以在两个渠道之间进行交流?
- 如果peer0同时订阅了两个频道怎么办?它会能够吗沟通两个渠道并在两个渠道中传输数据?
- How can I create multiple channels for different organizations? Idid not get any elaborative examples.
- Is it possible to communicate between two channels?
- What if peer0 is subscribed to both channels? Will it be able tocommunicate both channels and transfer data in both channels?
推荐答案
经过反复试验,我发现了问题所在.实际上,我认为,如果要创建多个通道,则必须多次使用docker-compose命令,这是不正确的.创建多个通道的正确语法为:
After some trial and error, I have found the problem. Actually, I thought, if I want to make multiple channels then I have to use docker-compose command multiple times, which is not correct. The correct syntax for creating multiple channels are:
export FABRIC_CFG_PATH = $ PWD
export FABRIC_CFG_PATH=$PWD
configtxgen -profile FourOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
configtxgen -profile FourOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
configtxgen -profile TwoOrgsChannel1 -outputCreateChannelTx ./channel-artifacts/channel1.tx -channelID mychannel1
configtxgen -profile TwoOrgsChannel1 -outputCreateChannelTx ./channel-artifacts/channel1.tx -channelID mychannel1
configtxgen -profile TwoOrgsChannel2 -outputCreateChannelTx ./channel-artifacts/channel2.tx -channelID mychannel2
configtxgen -profile TwoOrgsChannel2 -outputCreateChannelTx ./channel-artifacts/channel2.tx -channelID mychannel2
configtxgen -profile TwoOrgsChannel1 -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel1 -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel1 -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel1 -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel1 -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel1 -asOrg Org2MSP
configtxgen -profile TwoOrgsChannel1 -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel1 -asOrg Org2MSP
configtxgen -profile TwoOrgsChannel2 -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID mychannel2 -asOrg Org3MSP
configtxgen -profile TwoOrgsChannel2 -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID mychannel2 -asOrg Org3MSP
configtxgen -profile TwoOrgsChannel2 -outputAnchorPeersUpdate ./channel-artifacts/Org4MSPanchors.tx -channelID mychannel2 -asOrg Org4MSP
configtxgen -profile TwoOrgsChannel2 -outputAnchorPeersUpdate ./channel-artifacts/Org4MSPanchors.tx -channelID mychannel2 -asOrg Org4MSP
docker-compose -f docker-compose-cli.yaml up -d
docker-compose -f docker-compose-cli.yaml up -d
这篇关于在Hyperledger Fabric中配置多通道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!