Blockchain 如何在Hyperledger中为新频道创建新对等点

Blockchain 如何在Hyperledger中为新频道创建新对等点,blockchain,hyperledger-fabric,hyperledger,Blockchain,Hyperledger Fabric,Hyperledger,我一直在学习Hyperledger的基本网络教程,我正在探索拥有2个对等点和2个通道的可能性,每个通道一个对等点 我已经使用configtxgen的命令为第二个通道创建了一个名为mychannel2.tx的通道配置文件: ../bin/configtxgen -profile OneOrgChannel -outputCreateChannelTx /config/channel2.tx -channelID mychannel2 但是,我不知道如何创建第二个对等方来添加到此通道。我猜我必须配

我一直在学习Hyperledger的基本网络教程,我正在探索拥有2个对等点和2个通道的可能性,每个通道一个对等点

我已经使用configtxgen的命令为第二个通道创建了一个名为
mychannel2.tx
的通道配置文件:

../bin/configtxgen -profile OneOrgChannel -outputCreateChannelTx /config/channel2.tx -channelID mychannel2
但是,我不知道如何创建第二个对等方来添加到此通道。我猜我必须配置
crypto-config.yaml
文件,但是我不知道如何添加对等方

但是一旦我添加了一个对等点,我应该能够使用的start.sh脚本创建一个通道,并让第二个对等点像这样加入通道:

# Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx

# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block

要创建一个新的对等点,您只需为该对等点生成由其组织签名的适当加密材料。为此,您可以使用
cryptogen
cli工具,在该工具中,您可以简单地重用现有的
crypto config.yaml
文件,在该文件中,您需要使用模板定义组织中的对等方数量和要生成的用户证书数量:

PeerOrgs:
  - Name: Org1
    Domain: org1.example.com
    Template:
      Count: 2
    Users:
      Count: 1
  - Name: Org2
    Domain: org2.example.com
    Template:
      Count: 2
    Users:
      Count: 1
在上面的示例中,它定义了两个组织,每个组织有两个对等方和一个用户

接下来,您必须使用
configtxgen
定义一个通道,该通道指定了您的需求,以满足您的需求:

2个对等点和2个通道,每个通道一个对等点

因此,需要定义将指定这些通道的概要文件,现在的问题是这些对等方是否属于同一组织。假设他们来自不同的组织,因此配置如下所示:

Profiles:

    TwoOrgsOrdererGenesis:
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
    ChannelOne:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
    ChannelTwo:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org2

最后,一旦您拥有每个通道的配置事务,您就可以将它们提交给订购服务,创建一个新的通道,然后将对等方加入到适当的通道中。请注意,您实际上不需要更改
crypto-config.yaml

第二个问题是,如果我使用
configtx.yaml
,除了您在此处显示的内容之外,我还必须编辑“组织”部分,对吗?(在其中添加Org2信息)第一个问题:为什么我不需要更改
crypto config.yaml
?我想我需要使用它来生成对等工件?
cryptogen
工具,例如
crypto config.yaml
用于为对等方、管理员和用户生成加密材料。在您的情况下,您可以简单地按原样使用它,因为您只需要两个对等点,每个组织一个。目前组织部分已经包括Org1和Org2,因此不需要更改,除非您在问题中没有提到其他细节。我已经更新了docker compose.yml以添加一个新的org
peer0.org2.example.com
(并为其提供了新的端口),我还在
configtx.yaml
中添加了org2,并创建了主机:
peer0.org2.example.com
,我更新了
crypto config.yaml
,并在PeerOrgs下添加了一个组织。我运行了cryptogen命令并成功生成了2个对等点,运行了configtxgen命令并创建了2个通道,但是,当我运行启动脚本来启动容器时,我不断得到
错误:没有这样的容器:peer0.org2.example.com
。我可以给你发个短信让你解决这个问题吗?
FABRIC_CFG_PATH=. configtxgen -profile ChannelOne -channelID channelone -outputCreateChannelTx=channelone.tx

FABRIC_CFG_PATH=. configtxgen -profile ChannelTwo -channelID channeltwo -outputCreateChannelTx=channeltwo.tx