Hyperledger Fabric配置文件解析-orderer.yaml

orderer.yaml是orderer节点的配置文件,凡是orderer需要设置的内容,全在这里找。该orderer.yaml示例配置文件指定了如下五大部分内容。

1.General部分

General部分是orderer.yaml配置文件的基础配置信息部分,主要指定配置如下:
在这里插入图片描述

  1. LedgerType指定分类账本类型。
  2. ListenAddress与ListenPort指定节点监听地址及端口号。
  3. TLS部分指定是否启用TLS验证、TLS证书、签名私钥、信任的根CA证书信息。
  4. Keepalive指定与客户端的连接信息。
  5. LogLevel与LogFormat指定日志级别与日志输出格式。
  6. GenesisMethod、GenesisProfile、GenesisFile指定生成初始区块相关的信息。
  7. LocalMSPDir与LocalMSPID指定MSP目录所在路径及MSP的ID。
  8. BCCSP部分主要指定区块链的加密实现方式,默认为SW(SoftWare),即软件基础的加密方式。

2.FileLedger部分

如果指定分类账本类型为文件类型,则通过FileLedger部分配置文件账本的相关信息。

Location指定区块链的本地存储路径。

Prefix指定临时空间中的前缀名称(未指定Location时)。

3.RAMLedger部分

如果分类账本指定不使用文件账本类型,而是内存账本类型时,则需要通过HistorySize属性指定在内存中保存区块的最大数量。

4.Kafka部分

如果Orderer服务使用Kafka实现排序服务,则进行相关的配置信息指定:

Retry指定连接到Kafka的重试请求信息。

Verbose指定是否启用日志记录。

TLS指定Orderer连接到Kafka的TLS相关设置,包括是否启动TLS,指定TLS密钥、证书及可信任的CA根证书。

Version指定Kafka的版本信息。

5.Debug部分

此部分配置信息相对简单,主要指定广播服务与交付服务的请求保存目录。

全文配置文件参考和解析:

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
 
---
################################################################################
#
#   Orderer Configuration
#
#   - This controls the type and configuration of the orderer.
#
################################################################################
General:
    # 监听地址
    ListenAddress: 127.0.0.1
 
    # 监听端口号
    ListenPort: 7050
 
    # GRPC服务器的TLS设置
    TLS:
        # 在实际生产网络中,应该使用 TLS 安全通信,这个值应该是true
        # 默认不启用
        Enabled: false 
        # 提供 TLS CA 为此节点生成的私钥的路径和文件名。
        PrivateKey: tls/server.key
        # 提供 TLS CA 为该节点生成的公共证书(也称为签名证书)的路径和文件名。
        Certificate: tls/server.crt
        # (应注释掉)此参数通常未设置以供正常使用。
        # 它是附加根证书的路径列表,用于在出站连接期间验证其他排序节点的证书。
        # 它可用于扩充每个通道配置的 MSP 中可用的 TLS CA 证书集。
        # 可信任的根CA证书
        RootCAs:
          - tls/ca.crt
        ClientAuthRequired: false
        ClientRootCAs:
 
    # GRPC服务器的激活设置
    Keepalive:
        # # 客户机ping之间的最小允许时间(除非通过测试确定有必要,否则不应覆盖默认值)
        ServerMinInterval: 60s
        # 连接到客户机的ping之间的时间(除非通过测试确定有必要,否则不应覆盖默认值)
        ServerInterval: 7200s
        # 服务器等待响应的超时时间(除非通过测试确定有必要,否则不应覆盖默认值)
        ServerTimeout: 20s
 
    # 由于所有节点都应该一致,建议将MaxRecVMGSize和MaxSendMsgSize的默认值保持为100MB
    # GRPC服务器和客户端可以接收的最大消息大小(字节)
    MaxRecvMsgSize: 104857600
    # GRPC服务器和客户端可以发送的最大消息大小(字节)
    MaxSendMsgSize: 104857600
 
    # 与其他订购服务节点(如基于Raft的订购服务)通信的订购服务节点的群集设置。
    Cluster:
        # SendBufferSize 是缓冲区中的最大消息数。
        # 如果缓冲区已满,共识消息将被丢弃,交易消息就会被等待去释放。
        SendBufferSize: 10
 
        # 管理客户端TLS证书的文件位置用于与其他订购服务节点建立相互TLS连接。
        # 如果未设置,则服务器将处于常规状态。TLS证书被重复使用
        ClientCertificate:
        # 管理客户端TLS证书的私钥的文件位置。
        # 如果未设置,则服务器将处于常规状态。TLS私钥被重复使用。
        ClientPrivateKey:
 
        # 以下4个属性要么一起设置,要么一起取消设置。
        # 如果设置了它们,那么order节点将使用单独的侦听器进行集群内通信。
        # 如果它们未设置,则使用常规Order侦听器。
        # 如果希望在面向客户机的侦听器和集群内侦听器上使用不同的TLS服务器证书,这非常有用。
        # 定义群集侦听连接的端口
        ListenPort:
        # 定义用于侦听集群内通信的IP
        ListenAddress:
        # 定义用于集群内通信的服务器TLS证书的文件位置。
        ServerCertificate:
        # 定义TLS证书的私钥的文件位置。
        ServerPrivateKey:
 
    # Bootstrap method: 指定获取引导块系统通道的方法。
    # "file" - 包含文件块或系统通道的Config块的文件路径
    # "none" - 允许订购器启动,而无需系统频道配置
    BootstrapMethod: none
 
    # 指定创建此节点时要使用的系统通道创世块的位置和名称。
    # (如果您要创建此节点以加入系统通道,则应覆盖默认值)
    # 如果您在不使用系统通道的情况下创建此节点,则不会使用此值,因此可以留空。
    BootstrapFile:
 
    # 排序节点的本地 MSP 的路径,必须在部署之前创建。
    LocalMSPDir: msp
 
    # 标识了这个排序节点所属的组织
    # MSP ID 必须与此加入将加入的任何通道的配置中存在的排序者组织 MSP ID 匹配。
    LocalMSPID: SampleOrg
 
    # 为Go“pprof”评测启用HTTP服务,如以下所述:
    # https://golang.org/pkg/net/http/pprof
    Profile:
        Enabled: false
        Address: 0.0.0.0:6060
 
    # BCCSP配置BlockChain Crypto服务提供商。
    BCCSP:
        # 默认值指定要使用的首选区块链加密服务提供商。
        # 如果首选提供商不可用,将使用基于软件的提供商(“SW”)。
        # 有效的提供者包括:
        #  - SW: 一种基于软件加密提供程序
        #  - PKCS11: CA硬件安全模块加密提供商。
        Default: SW
 
        # SW配置基于软件的SlowtChain Crypto提供商。
        SW:
            # 默认哈希和安全级别需要重构才能完全配置。
            # 更改这些默认值需要协调,SHA2在多个地方硬编码,而不仅仅是BCCSP
            Hash: SHA2
            Security: 256
            # 密钥的位置. If this is unset, a location will be
            # 如果未设置,将选择使用位置'LocalMSPDir'/keystore
            FileKeyStore:
                KeyStore:
 
        # PKCS#11 Crypto Provider的设置(即默认值:PKCS11)
        PKCS11:
            # Location of the PKCS11 module library
            Library:
            # Token Label
            Label:
            # User PIN
            Pin:
            Hash:
            Security:
            FileKeyStore:
                KeyStore:
 
    # 身份验证包含与验证客户端消息相关的配置参数
    Authentication:
        # 当前服务器时间和客户端请求消息中指定的客户端时间之间的可接受差异
        TimeWindow: 15m
 
 
################################################################################
#
#   SECTION: File Ledger
#
#   - 本节文本账本配置信息。
#
################################################################################
FileLedger:
 
    # 区块存储路径
    Location: /var/hyperledger/production/orderer
 
################################################################################
#
#   SECTION: Kafka
#
#   - Kafka 集群的配置信息
#   
#
################################################################################
Kafka:
 
    # Retry: What do if a connection to the Kafka cluster cannot be established,
    # or if a metadata request to the Kafka cluster needs to be repeated.
    # 无法建立到Kafka集群的连接时的重试请求
    Retry:
        # When a new channel is created, or when an existing channel is reloaded
        # (in case of a just-restarted orderer), the orderer interacts with the
        # Kafka cluster in the following ways:
        # 1. It creates a Kafka producer (writer) for the Kafka partition that
        # corresponds to the channel.
        # 2. It uses that producer to post a no-op CONNECT message to that
        # partition
        # 3. It creates a Kafka consumer (reader) for that partition.
        # If any of these steps fail, they will be re-attempted every
        # <ShortInterval> for a total of <ShortTotal>, and then every
        # <LongInterval> for a total of <LongTotal> until they succeed.
        # Note that the orderer will be unable to write to or read from a
        # channel until all of the steps above have been completed successfully.
        ShortInterval: 5s # 重试时间间隔
        ShortTotal: 10m # 重试的总时间
        LongInterval: 5m # 重试失败后再次发送重试的时间间隔
        LongTotal: 12h # 重试的最长总时间
        # Affects the socket timeouts when waiting for an initial connection, a
        # response, or a transmission. See Config.Net for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        # 网络超时设置
        NetworkTimeouts:
            DialTimeout: 10s
            ReadTimeout: 10s
            WriteTimeout: 10s
        # Affects the metadata requests when the Kafka cluster is in the middle
        # of a leader election.See Config.Metadata for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        # 请求领导人选举时影响元数据的设置
        Metadata:
            RetryBackoff: 250ms # 指定重试的最大时间
            RetryMax: 3 # 重试的最大次数
        # What to do if posting a message to the Kafka cluster fails. See
        # Config.Producer for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        # 向Kafka集群发送消息失败的设置
        Producer:
            RetryBackoff: 100ms # 指定重试的最大时间
            RetryMax: 3 # 重试的最大次数
        # What to do if reading from the Kafka cluster fails. See
        # Config.Consumer for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        # 向Kafka集群读取消息失败的设置
        Consumer:
            RetryBackoff: 2s # 指定重试的最大时间
    # Settings to use when creating Kafka topics.  Only applies when
    # Kafka.Version is v0.10.1.0 or higher
    Topic:
        # The number of Kafka brokers across which to replicate the topic
        ReplicationFactor: 3
    # Verbose: Enable logging for interactions with the Kafka cluster.
    # 是否为与Kafka集群的交互启用日志记录
    Verbose: false
 
    # TLS: TLS settings for the orderer's connection to the Kafka cluster.
    TLS:
    # Orderer连接到Kafka集群的TLS设置
 
      # Enabled: Use TLS when connecting to the Kafka cluster.
      # 连接到Kafka集群时是否使用TLS
      Enabled: false
 
      # PrivateKey: PEM-encoded private key the orderer will use for
      # authentication.
      PrivateKey:
        # As an alternative to specifying the PrivateKey here, uncomment the
        # following "File" key and specify the file name from which to load the
        # value of PrivateKey.
        #File: path/to/PrivateKey
 
      # Certificate: PEM-encoded signed public key certificate the orderer will
      # use for authentication.
      Certificate:
        # As an alternative to specifying the Certificate here, uncomment the
        # following "File" key and specify the file name from which to load the
        # value of Certificate.
        #File: path/to/Certificate
 
      # RootCAs: PEM-encoded trusted root certificates used to validate
      # certificates from the Kafka cluster.
      RootCAs:
        # As an alternative to specifying the RootCAs here, uncomment the
        # following "File" key and specify the file name from which to load the
        # value of RootCAs.
        #File: path/to/RootCAs
 
    # SASLPlain: Settings for using SASL/PLAIN authentication with Kafka brokers
    SASLPlain:
      # Enabled: Use SASL/PLAIN to authenticate with Kafka brokers
      Enabled: false
      # User: Required when Enabled is set to true
      User:
      # Password: Required when Enabled is set to true
      Password:
 
    # Kafka protocol version used to communicate with the Kafka cluster brokers
    # (defaults to 0.10.2.0 if not specified)
    Version:
 
################################################################################
#
#   Debug Configuration
#
#   - orderer的调试配置信息
#
################################################################################
Debug:
 
    # BroadcastTraceDir when set will cause each request to the Broadcast service
    # for this orderer to be written to a file in this directory
    # 对广播服务的每个请求写入此目录中的文件
    BroadcastTraceDir:
 
    # DeliverTraceDir when set will cause each request to the Deliver service
    # for this orderer to be written to a file in this directory
    # 对交付服务的每个请求写入此目录中的文件
    DeliverTraceDir:
 
################################################################################
#
#   Operations Configuration
#
#   - 操作服务用于监控排序节点的健康状况,并依靠双向 TLS 来保护其通信。
#   - 如果打算使用 Prometheus 指标来监控的排序节点,则必须在此处配置操作服务。
################################################################################
Operations:
    # 指定运维服务器的地址和端口。
    ListenAddress: 127.0.0.1:8443
 
    # TLS configuration for the operations endpoint
    TLS:
        # 如果正在使用运营服务,则必须是 ture
        Enabled: false
 
        # 证书是PEM编码的TLS证书的位置
        Certificate:
 
        # PrivateKey指向PEM编码密钥的位置
        PrivateKey:
 
        # 必须设置true为启用客户端和服务器之间的双向 TLS
        # ClientAuthRequired需要在TLS层进行客户端证书身份验证才能访问所有资源
        ClientAuthRequired: false
 
        # 类似于TLS中的客户端根CA证书文件,它包含可用于验证客户端证书的客户端根CA证书列表。
        # 如果客户端注册了 orderer 组织 CA,则此值是 orderer 组织根 CA 证书。
        ClientRootCAs: []
 
################################################################################
#
#   Metrics Configuration
#
#   - This configures metrics collection for the orderer
#   - 默认情况下这是禁用的,但如果你想监控排序者的指标,你需要使用StatsD或Prometheus作为你的 
    - 指标提供者。
################################################################################
Metrics:
    # 将此值设置为statsd、prometheus或者disabled
    Provider: disabled
 
    # The statsd configuration
    Statsd:
      # network type: tcp or udp
      Network: udp
 
      # the statsd server address
      Address: 127.0.0.1:8125
 
      # The interval at which locally cached counters and gauges are pushed
      # to statsd; timings are pushed immediately
      WriteInterval: 30s
 
      # The prefix is prepended to all emitted statsd metrics
      Prefix:
 
################################################################################
#
#   Admin Configuration
#
#   - 这将为订购方配置管理服务器端点
#
################################################################################
Admin:
    # 可以使用的 orderer 管理服务器地址(主机和端口)
    ListenAddress: 127.0.0.1:9443
 
    # TLS configuration for the admin endpoint
    TLS:
        # TLS enabled
        Enabled: false
 
        # TLS CA 颁发的 orderer 签名证书的路径和文件名。
        Certificate:
 
        # TLS CA 发布的 orderer 私钥的路径和文件名。
        PrivateKey:
 
        # 此值必须设置为true。
        # 请注意,虽然 ordererAdmin端点上的所有操作都需要双向 TLS,
        # 但整个网络不需要使用双向 TLS。
        ClientAuthRequired: true
 
        # 管理客户端 TLS CA 根证书的路径和文件名。
        ClientRootCAs: []
 
################################################################################
#
#   Channel participation API Configuration
#
#   - 这为订购方提供了通道参与API配置
#   - 频道参与使用管理服务的ListenAddress和TLS设置。
#     
#
################################################################################
ChannelParticipation:
    # 启用通道参与API
    Enabled: false
 
    # 加入频道时请求主体的最大大小
    MaxRequestBodySize: 1 MB
 
 
################################################################################
#
#   Consensus Configuration
#
#   - 本节包含共识插件的配置选项 它对orderer来说是不透明的,完全取决于一致意见的实现
#     
#
################################################################################
Consensus:
    # The allowed key-value pairs here depend on consensus plugin. For etcd/raft,
    # we use following options:
 
    # 这是排序节点本地文件系统上预写日志的路径
    # 每个频道都有自己的以频道 ID 命名的子目录
    WALDir: /var/hyperledger/production/orderer/etcdraft/wal
 
    # 这是排序节点本地文件系统上快照的路径
    # 每个频道都有自己的以频道 ID 命名的子目录
    SnapDir: /var/hyperledger/production/orderer/etcdraft/snapshot

猜你喜欢

转载自blog.csdn.net/wj8023/article/details/127604630