fabric手动多机部署
发布日期:2021-05-10 01:23:31 浏览次数:24 分类:精选文章

本文共 6231 字,大约阅读时间需要 20 分钟。

Hyperledger Fabric���������������������������

���������������Hyperledger Fabric���������������������������������������������������������������������������������������������Fabric������������������������������

������������

������������������

  • ������������������������������Fabric������
  • ������������������1���Orderer���������4���Peer������
  • ������������������������
    • Orderer���������orderer.example.com
    • 4������������Org1~Org4���������������������������Peer������

������������������

������������ IP������ ������������
Server 1 10.11.6.118 orderer
Server 2 10.11.6.118 org1
Server 3 10.11.6.119 org2
Server 4 10.11.6.120 org3
Server 5 10.11.6.121 org4

������������

1. ���������������������

���������������������������������������������

./network_setup.sh up
./network_setup.sh down

2. ������������������

������������������������������

configtx.yaml������������������������

Profiles:
FourOrgsOrdererGenesis:
Orderer:
*OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
FourOrgsChannel:
Consortium: SampleConsortium
Application:
*ApplicationDefaults
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
Organizations:
- Org3MSP
- Org4MSP

docker-compose-base.yaml���������Peer���������������

version: '3'
services:
peer0.org1.example.com:
container_name: peer0.org1.example.com
extends: file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- /var/run/:/host/var/run/
- ${CRYPTO_CONFIG}/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ${CRYPTO_CONFIG}/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 7051:7051
- 7052:7052
- 7053:7053
peer0.org2.example.com:
container_name: peer2.org2.example.com
extends: file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org2.example.com
- CORE_PEER_ADDRESS=peer0.org2.example.com:7051
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
volumes:
- /var/run/:/host/var/run/
- ${CRYPTO_CONFIG}/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ${CRYPTO_CONFIG}/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 7051:7051
- 7052:7052
- 7053:7053
# ���������������������������������������������������������

3. ������������������������ crypto-config ���������������

cryptogen generate --config=./crypto-config.yaml

4. ������������������

cp docker-compose-e2e-template.yaml docker-compose-e2e.yaml
cd crypto-config/peerOrganizations/org1.example.com/ca/
cp * /etc/hyperledger/fabric-ca-server-config/

5. ������������������

sh up.sh
sh down.sh

6. ������Peer��������� docker-compose ������

��������������� docker-compose-peer.yaml ���������

cp docker-compose-cli.yaml docker-compose-peer.yaml

7. ������Orderer��������� docker-compose ������

��������������� docker-compose-orderer.yaml ���������

cp docker-compose-cli.yaml docker-compose-orderer.yaml

������������������

1. ������������������

configtxgen -profile FourOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

2. ������Channel������������

���������������������������������������

configtxgen -profile FourOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID mychannel -asOrg Org3MSP
configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org4MSPanchors.tx -channelID mychannel -asOrg Org4MSP

������������������������������������������

������������������������������scp���������������������������������������������

scp -r e2e_cli/ *user@target_host:/ Commands������������������������������������������

���������������������

���������������������

docker-compose -f docker-compose-cli.yaml up -d

������������

  • ������CLI���������������Channel
  • docker exec -it cli bash
    peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile $ORDERER_CA
    1. ���������Peer������Channel
    2. ������Org1���

      peer channel join -b mychannel.block -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA

      ������Org2���Org3���Org4���������������������������������

      1. ������ChainCode���������������
      2. ������ChainCode������Org1������������

        peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

        ���������ChainCode���

        peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member','Org3MSP.member','Org4MSP.member')"
        1. ������ChainCode������
        2. peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

          ������������

          • ������������������
            • ������������ERROR1���BAD_RESQUEST������������������������_txn_format������
            • ���������������������������������ChainCode���������������������������������
          • ������������
            • ������������������������������������������������������������
            • ���������������NTP���������������������������������
            • ������������������������������������������������������������������

          ���������������������������������������������������������������������������������������������������������

    上一篇:Lasy Maintenance of MV ——SQL server物化视图的懒惰更新
    下一篇:Alibaba的OceanBase数据库环境配置与安装

    发表评论

    最新留言

    做的很好,不错不错
    [***.243.131.199]2025年04月20日 16时13分55秒