首页 > 解决方案 > 如何在超级账本结构中添加 raft 而不是 kafka?

问题描述

如何在 hyperledger fabric altoros fabric-supply-chain 项目中 添加raft而不是 kafka?这是我的 configtxtemplate-OneOrg-orderer.yaml 文件

---
################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:

    OrdererGenesis:
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *ORG1
    common:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *ORG1

    CHANNEL_NAME:
        Consortium: SampleConsortium
        Application:
            Organizations:
                - *ORG1

################################################################################
#
#   Section: Organizations
#
#   - This section defines the different organizational identities which will
#   be referenced later in the configuration.
#
################################################################################
Organizations:

    # SampleOrg defines an MSP using the sampleconfig.  It should never be used
    # in production but may be used as a template for other definitions
    - &OrdererOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: OrdererMSP

        # ID to load the MSP definition as
        ID: OrdererMSP

        # MSPDir is the filesystem path which contains the MSP configuration
        MSPDir: crypto-config/ordererOrganizations/DOMAIN/msp

    - &ORG1
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: ORG1MSP

        # ID to load the MSP definition as
        ID: ORG1MSP

        MSPDir: crypto-config/peerOrganizations/ORG1.DOMAIN/msp

        AnchorPeers:
            # AnchorPeers defines the location of peers which can be used
            # for cross org gossip communication.  Note, this value is only
            # encoded in the genesis block in the Application section context
            - Host: peer0.ORG1.DOMAIN
              Port: 7051


################################################################################
#
#   SECTION: Orderer
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start
    # Available types are "solo" and "kafka"
    OrdererType: solo

    Addresses:
        - orderer.DOMAIN:7050

    # Batch Timeout: The amount of time to wait before creating a batch
    BatchTimeout: 2s

    # Batch Size: Controls the number of messages batched into a block
    BatchSize:

        # Max Message Count: The maximum number of messages to permit in a batch
        MaxMessageCount: 10

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for
        # the serialized messages in a batch.
        AbsoluteMaxBytes: 98 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed for
        # the serialized messages in a batch. A message larger than the preferred
        # max bytes will result in a batch larger than preferred max bytes.
        PreferredMaxBytes: 512 KB

    Kafka:
        # Brokers: A list of Kafka brokers to which the orderer connects
        # NOTE: Use IP:port notation
        Brokers:
            - 127.0.0.1:9092

    # Organizations is the list of orgs which are defined as participants on
    # the orderer side of the network
    Organizations:

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

您能否检查一下我哪里出错了以及我必须在哪些文件中进行更改。我浏览了 raft 的文档,但我不能很好地理解它,也没有我可以通过的好的资源或教程。如果您知道任何好的来源或示例,请提供帮助。我看到超级账本结构社区不如比特币或以太坊这样的区块链强大。我在上面构建应用程序时遇到了很多麻烦。我会请求你帮助我,从我能学到最好的地方。

标签: hyperledger-fabrichyperledgerblockchain

解决方案


您可以阅读文档以获取更多详细信息和解释,而关键概念是:

  1. 为了使用 Raft,您需要配置您的排序服务以使用 TLS。

  2. 将订购者类型更改为

    OrdererType: etcdraft
    
  3. 您需要通过添加到配置以下部分来设置您的中心集(Raft 副本):

    Consenters:
    
        - Host: raft0.example.com
          Port: 7050
          ClientTLSCert: path/to/ClientTLSCert0
          ServerTLSCert: path/to/ServerTLSCert0
        - Host: raft1.example.com
          Port: 7050
          ClientTLSCert: path/to/ClientTLSCert1
          ServerTLSCert: path/to/ServerTLSCert1
        - Host: raft2.example.com
          Port: 7050
          ClientTLSCert: path/to/ClientTLSCert2
          ServerTLSCert: path/to/ServerTLSCert2
    

您在其中提供配置以设置您的集群,包括您的中心的 TLS 证书。

例如 Raft 的配置文件可能如下所示,SampleDevModeEtcdRaft配置文件:

SampleDevModeEtcdRaft:
  <<: *ChannelDefaults
Capabilities:
  <<: *ChannelCapabilities
  Orderer:
    <<: *OrdererDefaults
    OrdererType: etcdraft
    EtcdRaft:
    Consenters:
        - Host: raft0.example.com
          Port: 7050
          ClientTLSCert: path/to/ClientTLSCert0
          ServerTLSCert: path/to/ServerTLSCert0
        - Host: raft1.example.com
          Port: 7050
          ClientTLSCert: path/to/ClientTLSCert1
          ServerTLSCert: path/to/ServerTLSCert1
        - Host: raft2.example.com
          Port: 7050
          ClientTLSCert: path/to/ClientTLSCert2
          ServerTLSCert: path/to/ServerTLSCert2        
  Organizations:
      - *OrdererOrg
    Capabilities:
      <<: *OrdererCapabilities
  Application:
    <<: *ApplicationDefaults
    Organizations:
    - <<: *OrdererOrg
  Consortiums:
    SampleConsortium:
      Organizations:
      - *Org1
      - *Org2

推荐阅读