Ada*_*Jha 4 hyperledger hyperledger-fabric
我想向现有的运行网络中添加新的订购者。目前我的网络如下:
泊坞窗ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
998b93eb81c6 hyperledger/fabric-tools:latest "/bin/bash" About a minute ago Up About a minute cli
87bada2d914b hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:8050->7050/tcp orderer2.example.com
5907f35bb5b4 hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:8750->7050/tcp orderer6.example.com
7876e35f2fb9 hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:10050->7050/tcp orderer4.example.com
fba3185ec9c6 hyperledger/fabric-peer:latest "peer node start" About a minute ago Up About a minute 0.0.0.0:7051->7051/tcp peer0.org1.example.com
8b5e4348f04c hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:9050->7050/tcp orderer3.example.com
a5cffb73ceca hyperledger/fabric-couchdb "tini -- /docker-ent…" About a minute ago Up About a minute 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0
6be4405ec45b hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:11050->7050/tcp orderer5.example.com
790c9aa84911 hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:8055->7050/tc
Run Code Online (Sandbox Code Playgroud)
我尝试在etcdraft文件中添加订购者,但无法正常工作。我在这里使用第一网络。
您可以按照以下步骤在RAFT共识协议设置中添加新的订购者。这是一个漫长的过程,因此我稍后还将添加脚本,但是现在您可以按照以下步骤进行操作。在这里,我使用结构样本中的first-network来启动具有5个订购者的网络。
首先,在OrdererOrgs下的crypto-config中:规范:为您的订购者创建一个新的主机名(使用与其他域名和域名相同的域名)。
然后,运行命令cryptogen extend --config=./crypto-config.yaml
NOTE:“扩展”部分,以便它生成您需要的内容,而不重新生成所有内容。
现在,我们首先将订购者添加到系统通道,然后在订购者拥有系统通道的所有块时,将其移至应用程序通道,因此请确保您做得正确。
使用进入您的cli容器并使用docker exec -it cli bash
有效的订购者信息对其进行引导,因为您将需要OrdererMSP来注销此更改。
以下是一些需要用命令程序引导cli的环境变量:
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp
CORE_PEER_ADDRESS=orderer.example.com:7050
CORE_PEER_LOCALMSPID=OrdererMSP
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
CHANNEL_NAME=[system-channel-name]
Run Code Online (Sandbox Code Playgroud)
接下来的事情是确保所有二进制文件都在cli容器中工作,因为我们将在此处使用jq和configtxlator工具将块从protobuf转换为json并返回
获取最新的配置块: peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
转换为json和trim标头: configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json
打开json文件,查找“ ConsensusType”部分,在该标题下应有另一个标签“ consenters”。现在,您必须在上面创建的最新订购者的此部分中添加新的TLS证书。但是这里的证书是以Base64编码的形式,因此首先您必须查找tlscert,然后必须在base64中进行转换,然后将其插入此部分。
就我而言,tls证书在这里:
crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
Run Code Online (Sandbox Code Playgroud)
现在,将其添加到上面给出的部分中,就像提到其他部分一样:
{
"client_tls_cert": "xxxxxxxxxxxx",
"host": "new_orderer.example.com",
"port": 7050,
"server_tls_cert": "xxxxxxxxxxxx"
}
Run Code Online (Sandbox Code Playgroud)
添加base64编码的cert而不是上面给出的xxxxxxxx并将更改保存为modified_config.json
将JSON形式的步骤6转换为块 configtxlator proto_encode --input config.json --type common.Config --output config.pb
将JSON从步骤7转换为块 configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
计算步骤8和9中的块之间的增量: configtxlator compute_update --channel_id $CHANNEL_NAME --original config.pb --updated modified_config.pb --output orderer_update.pb
将增量更改回json: configtxlator proto_decode --input orderer_update.pb --type common.ConfigUpdate | jq . > orderer_update.json
现在,我们有一个解码后的更新文件– orderer_update.json –我们需要将其包装在信封消息中。此步骤将使我们返回之前删除的标头字段。我们将其命名为:orderer_update_in_envelope.json
echo '{"payload":{"header":{"channel_header":{"channel_id":"$CHANNEL_NAME", "type":2}},"data":{"config_update":'$(cat orderer_update.json)'}}}' | jq . > orderer_update_in_envelope.json
Run Code Online (Sandbox Code Playgroud)
configtxlator proto_encode --input orderer_update_in_envelope.json --type common.Envelope --output orderer_update_in_envelope.pb
Run Code Online (Sandbox Code Playgroud)
peer channel update -f orderer_update_in_envelope.pb -c $CHANNEL_NAME -o orderer.example.com:7050 --tls --cafile $ORDERER_CA
Run Code Online (Sandbox Code Playgroud)
通过检查已获取的配置块是否包含(即将)添加的节点的证书,确保将要添加的节点是系统通道的一部分。
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
Run Code Online (Sandbox Code Playgroud)
然后,将此配置块移动到channel-artifacts文件夹,并在订购者的docker-compose文件中将该路径添加到该env变量:
ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
Run Code Online (Sandbox Code Playgroud)
启动订购者后,您可能会注意到此时已将其连接到木筏并且Steprequests成功,并且由于使用了相同的创世块,因此您的频道和块被阻止。尽管需要做的是使网络知道这个新订购者的地址。
等待Raft节点复制其证书已添加到的所有通道的现有节点中的块。完成此步骤后,节点开始为通道提供服务。
将新添加的Raft节点的端点添加到系统通道的通道配置中,为此,您必须再次重复通道更新事务的整个过程,就像我们之前(第5至14日)所做的那样,而唯一要做的就是做不同的是在步骤7中,您必须这样做:
打开json文件,查找“ OrdererAddresses”部分,在该标题下应有另一个标签“ addresses”。在该阵列中为新的订购者端点添加新的IP和PORT。将更改另存为modified_config.json,然后按照上述步骤进行其余操作。
一旦您的同龄人获得了这个新的阻止,他们现在就知道了新订购者的地址并可以联系它。
CHANNEL_NAME=[application-channel-name]
Run Code Online (Sandbox Code Playgroud)
您必须在“ 同意者”部分中添加相同的tls证书,然后在复制了应用程序通道的块之后,可以在“ 地址”部分中添加订购者的端点,然后它将开始反映您将对应用程序通道进行的所有最新更改。 。
归档时间: |
|
查看次数: |
355 次 |
最近记录: |