Fabric部署

Fabric相关组件以及工具介绍:

- orderer 共识节点。为交易排序,并生成区块 

- peer共识节点。为交易背书,并记录区块信息 

cryptogen用于生成区块链网络中相应用户的相关证书文件 

- configtxgen 用于生成区块链系统链码的创世区块、新建通道的配置文件、以及组织中锚节点的配置文件

-couchdb  peer节点状态数据库用的是couchdb,每个peer节点对应一个couchdb节点;

-ca 为Hyperledger Fabric行使证书机构的功能,每个组织一个ca服务器;

部署内容:

  1. 生成MSP证书
    工具:cryptogen
    配置文件:crypto-config.yaml
    命令:$ cryptogen generate --config=./crypto-config.yaml
    生成文件: crypto -config文件夹下有ordererOrganizations和 peerOrganizations文件夹
    使用:peer、ca和orderer节点需要部署
    位置:./crypto-config
  2. 生成创世区块
    工具:configtxgen
    配置文件:configtx.yaml
    命令:$ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
    生成文件:genesis.block
    使用:peer和orderer节点需要部署
    位置:./channel-artifacts
  3. 生成Channel配置区块
    工具:configtxgen
    配置文件:configtx.yaml
    命令:$ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
    生成文件: channel.tx
    使用:peer和orderer节点需要部署
    位置:./channel-artifacts
  4.  更新锚节点(AnchorPeers)
    工具:configtxgen
    配置文件:configtx.yaml
    命令:$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

    命令:$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $mychannel -asOrg Org2MSP
    ...
    生成文件: Org1MSPanchors.tx/Org2MSPanchors.tx/...
    使用:peer和orderer节点需要部署
    位置:./channel-artifacts


cryptogen 证书生成工具:

文件crypto-config.yaml这个文件定义了有多少个orderer和peer组织,每个组织有多少个peer;

为组织和属于这些组织的组件生成一组证书和密钥。

每个组织都配置了唯一的根证书(ca-cert),它将特定组件(peers和orders)绑定到该组织。

通过为每一个组织分配唯一的CA证书,模仿一个经典的网络,这个网络中的成员将使用自己的证书颁发机构。Hyperledger Fabric中的交易和通信是通过存储在keystore中的实体的私钥签名,然后通过公钥手段进行验证(signcerts)。

命令:cryptogen  generate --config=./crypto-config.yaml

configtxgen 配置交易生成器:

文件configtx.yaml,这个文件描述了通道有多少个组织加入,以及排序服务属性、区块大小等等;

用于创建4个配置文件: 

 order的创世区块文件(genesis block),

channel的通道交易配置文件(channel configuration transaction),

以及每个peer组织的锚节点配置文件(anchor peer transactions)。


关于crypto-config.yaml中的多个peer组织

Peer节点分为多个组织管理。一个组织由多个Peer节点组成。

每个组织中的第一个节点(peer0节点)作为锚节点与其他组织进行通信,所有节点通过域名都可以相互访问。

例子:

Fabric网络中包括一个Orderer节点和四个Peer节点,以及一个管理节点。

四个Peer节点分属于同一个管理域(example.com)下的两个组织Org1和Org2,这两个组织都加入同一个应用通道(business-channel)中。

每个组织中的第一个节点(peer0节点)作为锚节点与其他组织进行通信,所有节点通过域名都可以相互访问。



configtx.yaml

配置文件定义了整个网络中的相关配置和拓扑结构信息。

该配置文件定义了两个模板:TwoOrgsOrdererGenesis和TwoOrgsChannel。

创建创世区块

其中前者TwoOrgsOrdererGenesis可以用来生成Ordering服务的初始区块文件。

    命令:$ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./orderer.genesis.block

所生成的orderer.genesis.block需要复制到Orderer节点上(与Orderer配置中ORDERER_GENERAL_GENESISFILE指定文件路径一致,默认放到/etc/hyperledger/fabric路径下),在启动Orderering服务时进行使用。
TwoOrgsChannel生成Channel配置区块,以及peer各组织的锚节点的更新。

通道交易配置文件:

    命令:$ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel

通道上各组织锚节点配置文件


peer各组织的锚节点的更新(假设有两个org):
    命令:$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
    命令:$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP

锚节点:各组织的peer节点通过锚节点与其他组织的peer节点或者orderer节点通信。

猜你喜欢

转载自blog.csdn.net/weixin_41926234/article/details/80624101