官方文档只说明了如何去新增组织 没有操作删除组织的操作详情,这篇文章简单记录一下如何去操作
官方文档只说明了如何去新增组织 没有操作删除组织的操作详情,这篇文章简单记录一下如何去操作
1\. 一切操作都在cli 容器里执行
2\. docker exec -it cli bash //此命令进入cli容器里
3\. 执行操作必须是管理员身份(Admin)
export 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
export CHANNEL_NAME=mychannel
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
2020-05-21 08:34:04.540 UTC [cli.common] readBlock -> INFO 045 Received block: 13
2020-05-21 08:34:04.540 UTC [channelCmd] fetch -> INFO 046 Retrieving last config block: 13
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config >config.json
jq ‘del(.channel_group.groups.Application.groups.Org3MSP)‘ config.json > modified_config.json
configtxlator proto_encode --input config.json --type common.Config --output config.pb
configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
configtxlator compute_update --channel_id $CHANNEL_NAME --original config.pb --updated modified_config.pb --output del_Org3MSP_update.pb
configtxlator proto_decode --input del_Org3MSP_update.pb --type common.ConfigUpdate | jq . > del_Org3MSP_update.json
echo ‘{"payload":{"header":{"channel_header":{"channel_id":"‘$CHANNEL_NAME‘", "type":2}},"data":{"config_update":‘$(cat del_Org3MSP_update.json)‘}}}‘ | jq . >del_Org3MSP_update_in_envelope.json
configtxlator proto_encode --input del_Org3MSP_update_in_envelope.json --type common.Envelope --output del_Org3MSP_update_in_envelope.pb
这里签名 是指当前通道所有组织 包含准备要删除的组织 (因为这是举例 所以是三个组织 如果是4个5个 那么下面签名需要4个5个组织签名)
友情提示:一定注意环境变量 一定注意环境变量 一定注意环境变量
证书路径 节点地址 端口 改成与自己对应的
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051
peer channel signconfigtx -f del_Org3MSP_update_in_envelope.pb
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=peer0.org2.example.com:9051
peer channel signconfigtx -f del_Org3MSP_update_in_envelope.pb
export CORE_PEER_LOCALMSPID="Org3MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
export CORE_PEER_ADDRESS=peer0.org3.example.com:11051
peer channel signconfigtx -f del_Org3MSP_update_in_envelope.pb
官方文档 是由最后组织节点去提交,去提交就代表已经去签名 但这里为了保险期间防止环境变量出现问题 在做一次环境变量由org1 Admin身份提交
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051
peer channel update -f del_Org3MSP_update_in_envelope.pb -c $CHANNEL_NAME -o orderer.example.com:7050 --tls --cafile $ORDERER_CA
2020-05-21 08:45:35.711 UTC [channelCmd] update -> INFO 04a Successfully submitted channel update
再一次通过 peer fetch 配置块 通过jq 工具解析json 查看是否已经没有组织了
原文:
https://www.jianshu.com/p/4ac1a6b18bff
原文:https://www.cnblogs.com/jiftle/p/14688603.html