하이퍼레저v1.4 기존 조직 제거
네트워크에서 조직 제거
네트워크 구조
기존 네트워크 구조
- Orderer : orderer.example.com 1개 존재
- Org1 : peer0, peer1, peer2 존재
- Org2 : peer0, peer1, peer2 존재
- Org3 : peer0, peer1, peer2 존재
새 네트워크 구조
- Orderer : orderer.example.com 1개 존재
- Org1 : peer0, peer1, peer2 존재
- Org2 : peer0, peer1, peer2 존재
Org3 : peer0, peer1, peer2 존재
네트워크 환경 설정
cd fabric-samples/first-network
1. crypto-config.yaml 수정
기존 네트워크 구조
- Orderer : orderer.example.com 1개 존재
- Org1 : peer0, peer1, peer2 존재
- Org2 : peer0, peer1, peer2 존재
- Org3 : peer0, peer1, peer2 존재
새 네트워크 구조
- Orderer : orderer.example.com 1개 존재
- Org1 : peer0, peer1, peer2 존재
- Org2 : peer0, peer1, peer2 존재
Org3 : peer0, peer1, peer2 존재
cd fabric-samples/first-network
2. configtx.yaml 수정
3. base/docker-compose-base.yaml 수정
4. docker-compose-cli.yaml 수정
네트워크 시작
네트워크 준비
# 암호자료 생성
../bin/cryptogen generate --config=./crypto-config.yaml
# 제네시스 블록 생성
export FABRIC_DFG_PATH=$PWD
../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
# 채널 트랜잭션 생성
export CHANNEL_NAME=mychannel
../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
# 조직별 앵커피어 트랜잭션 생성
../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org3MSP
네트워크 실행
# 노드 실행
docker-compose -f docker-compose-cli.yaml up -d
블록 생성
# 각 피어노드 별 cli 컨테이너 접속
# peer0.org1.example.com
docker exec -it cli bash
# peer1.org1.example.com
docker exec -it -e "CORE_PEER_ADDRESS=peer1.org1.example.com:8051" -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/server.crt" -e "CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/server.key" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli bash
# peer0.org2.example.com
docker exec -it -e "CORE_PEER_ADDRESS=peer0.org2.example.com:9051" -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt" -e "CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key" -e "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" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp" cli bash
# peer1.org2.example.com
docker exec -it -e "CORE_PEER_ADDRESS=peer1.org2.example.com:10051" -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/server.crt" -e "CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/server.key" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp" cli bash
# peer0.org3.example.com
docker exec -it -e "CORE_PEER_ADDRESS=peer0.org3.example.com:11051" -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.crt" -e "CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.key" -e "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" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/[email protected]/msp" cli bash
# peer1.org3.example.com
docker exec -it -e "CORE_PEER_ADDRESS=peer1.org3.example.com:12051" -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls/server.crt" -e "CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls/server.key" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls/ca.crt" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/[email protected]/msp" cli bash
# 채널 제네시스 블록 생성
# peer0.org1.example.com
export CHANNEL_NAME=mychannel
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
# Org1 채널 가입 && 앵커피어 업데이트
# peer0.org1.example.com
peer channel join -b mychannel.block
export CHANNEL_NAME=mychannel
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
# peer1.org1.example.com
peer channel join -b mychannel.block
# Org2 채널 가입 && 앵커피어 업데이트
# peer0.org2.example.com
peer channel join -b mychannel.block
export CHANNEL_NAME=mychannel
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
# peer1.org2.example.com
peer channel join -b mychannel.block
# Org3 채널 가입 && 앵커피어 업데이트
# peer0.org3.example.com
peer channel join -b mychannel.block
export CHANNEL_NAME=mychannel
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org3MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
# peer1.org3.example.com
peer channel join -b mychannel.block
체인코드 설치
# Org1 체인코드 설치
# peer0.org1.example.com
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
# peer1.org1.example.com
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
# Org2 체인코드 설치
# peer0.org2.example.com
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
# peer1.org2.example.com
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
# Org3 체인코드 설치
# peer0.org3.example.com
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
# peer1.org3.example.com
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
# 체인코드 인스턴스화
# peer0.org1.example.com
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"
# 체인코드 질의
# peer0.org1.example.com
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
# 체인코드 질의
# peer0.org2.example.com
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
# 체인코드 질의
# peer0.org3.example.com
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
# 블록 정보
# peer1.org1.example.com
export CHANNEL_NAME=mychannel
peer channel getinfo -c $CHANNEL_NAME
# peer1.org2.example.com
export CHANNEL_NAME=mychannel
peer channel getinfo -c $CHANNEL_NAME
# peer1.org3.example.com
export CHANNEL_NAME=mychannel
peer channel getinfo -c $CHANNEL_NAME
네트워크 수정
기존 조직 삭제
# 최신 설정 블록 가져오기
# peer0.org1.example.com
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
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
# Org3 정보 제거 && 새 설정 블록 생성
# peer0.org1.example.com
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json
# ORG3 정보 제거
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 mychannel --original config.pb --updated modified_config.pb --output update.pb
# 새 설정 블록에 헤더 추가
configtxlator proto_decode --input update.pb --type common.ConfigUpdate | jq . > update.json
echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":'$(cat update.json)'}}}' | jq . > update_in_envelope.json
configtxlator proto_encode --input update_in_envelope.json --type common.Envelope --output update_in_envelope.pb
# 새 설정 블록에 서명
# peer0.org1.example.com
peer channel signconfigtx -f update_in_envelope.pb
# 네트워크에 반영
# peer0.org2.example.com
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
peer channel update -f update_in_envelope.pb -c $CHANNEL_NAME -o orderer.example.com:7050 --tls --cafile $ORDERER_CA
# 체인코드 version 2 설치
# peer0.org1.example.com
peer chaincode install -n mycc -v 2.0 -p github.com/chaincode/chaincode_example02/go/
# peer1.org1.example.com
peer chaincode install -n mycc -v 2.0 -p github.com/chaincode/chaincode_example02/go/
# peer0.org2.example.com
peer chaincode install -n mycc -v 2.0 -p github.com/chaincode/chaincode_example02/go/
# peer1.org2.example.com
peer chaincode install -n mycc -v 2.0 -p github.com/chaincode/chaincode_example02/go/
# 체인코드 업그레이드
# peer0.org1.example.com
peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
# 체인코드 질의
# peer0.org1.example.com
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
# peer0.org2.example.com
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
# 체인코드 실행(a에서 b로 10 전송)
# peer0.org2.example.com
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}'
# 체인코드 질의
# peer1.org1.example.com
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
# peer1.org2.example.com
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
# 블록 정보
# peer0.org1.example.com
peer channel getinfo -c $CHANNEL_NAME
# peer0.org2.example.com
peer channel getinfo -c $CHANNEL_NAME
# peer0.org3.example.com
peer channel getinfo -c $CHANNEL_NAME
Author And Source
이 문제에 관하여(하이퍼레저v1.4 기존 조직 제거), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@sunminky/하이퍼레저v1.4-기존-조직-제거저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)