Combing various configuration files of Fabric (1)

1.core.yaml : An example configuration file for Peer nodes, with six parts (slightly changed with version changes)

  • Log section: specify module log level
  • peer part: Peer service core configuration content
  • vm part: configure the environment in which the chain code runs, such as a Docker container
  • Chain code part: chain code related configuration
  • ledger part: ledger configuration information
  • metrics (indicators) section: system performance measurement framework

2.orderer.yaml: Orderer node example configuration file

  • General section: the basic configuration information section of the configuration file
  • FileLedge part: If the specified ledger type is a file type, then configure the relevant information of the file ledger through this part
  • RAMLedge: Specifies the maximum number of memory ledger type blocks
  • Kafka: Configuration information specification of Kafka sorting service
  • Debug: Mainly specify the request storage directory for broadcast services and delivery services

3.crypto-config.yaml : Specify the details of relevant organizations in the entire network (after version 2.x, it is divided into three yaml files) to produce organizational structure and configuration files required for identity certificates

 OrdererOrgs:
  - Name: Orderer
    Domain: example.com #Domain name
    EnableNodeOUs: true
    Specs:
      - Hostname: orderer #The value of hostname+Domain forms the complete domain name of the Orderer node
        SANS:
          - localhost

PeerOrgs:
  - Name: Org1
    Domain: org1.example.com #Complete domain name: peer0.org1.example.com
    EnableNodeOUs: true #Produce config.yaml file under msp
    Template:
      Count: 1 #Specify the number of nodes
      SANS:
        - localhost
    Users :
      Count: 1 #Specify the number of users

PeerOrgs:
  - Name: Org2
    Domain: org2.example.com
    EnableNodeOUs: true
    Template:
      Count: 1
      SANS:
        - localhost
    Users:
      Count: 1

4.config.tx : Configuration files required to produce GenesisBlock and Channel. For example, the relevant configuration of the specified orderer service, as well as the current alliance information and the organization information contained in the alliance, the configuration of these information is defined in this file.

The configtx file is mainly used to generate a genesis block, create a channel configuration transaction, and create an anchor node update configuration transaction (a configuration transaction is a type of transaction in Fabric, which can be parsed by the order node and used to configure the order node).

The configtx.yaml file is divided into several sections: Organizations, Capabilities, Application, Orderer, CHANNEL, Profile. 

##################################################################

#   Section: Organizations

##################################################################

Organizations:  #指定OrdererOrg和PeerOrg的权限信息
    - &OrdererOrg
        Name: OrdererOrg
        ID: OrdererMSP
        MSPDir: ../organizations/ordererOrganizations/example.com/msp
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"
        OrdererEndpoints:
            - orderer.example.com:7050
    - &Org1
        Name: Org1MSP
        ID: Org1MSP
        MSPDir: ../organizations/peerOrganizations/org1.example.com/msp
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org1MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org1MSP.peer')"
    - &Org2
        Name: Org2MSP
        ID: Org2MSP
        MSPDir: ../organizations/peerOrganizations/org2.example.com/msp
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org2MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org2MSP.peer')"

##################################################################

#   SECTION: Capabilities 

In the #Capabilities configuration section, the direct translation of capability is capability, which can be understood as the control of the version of the components in the Fabric network, and then control the corresponding features through the version. If the newly updated feature is not supported by the old version of the component, it may not be able to verify or submit the transaction, resulting in different ledgers on different versions of the node, so use Capabilities to make the old component that does not support the feature stop processing the transaction until it is updated to upgrade the Channel representation Orderers and peers must be satisfied at the same time, Orderer only needs to be satisfied by orderers, and Application only needs to be satisfied by peers.

##################################################################

Capabilities: #Specify the permission information of the channel

    Channel: &ChannelCapabilities

        V2_0: true //channel version number

    Orderer: &OrdererCapabilities

        V2_0: true //orderer version

    Application: &ApplicationCapabilities

        V2_0: true //application version

##################################################################

# SECTION: Application application 

The #Application configuration section is used to define the application parameters to be written into the genesis block or configure the transaction.
#Application configuration section, some application-related parameters that will be compiled into the genesis block or configure the application of the transaction, among which organizations: do not configure here, in the following profiles configuration section, the file type generated according to the needs to configure.

##################################################################

Application: &ApplicationDefaults #Specify the organization that initially joins the channel

    Organizations:

    Policies: # Define the application control policy at this level

        Readers:

            Type: ImplicitMeta

            Rule: "ANY Readers"

        Writers:

            Type: ImplicitMeta

            Rule: "ANY Writers"

        Admins:

            Type: ImplicitMeta

            Rule: "MAJORITY Admins"

        LifecycleEndorsement:

            Type: ImplicitMeta

            Rule: "MAJORITY Endorsement"

        Endorsement:

            Type: ImplicitMeta

            Rule: "MAJORITY Endorsement"

    Capabilities:

        <<: *ApplicationCapabilities

##################################################################

# SECTION: Orderer sorting node

The #Orderer configuration section is used to define the ordering node parameters to be encoded into the genesis block or channel transactions.

##################################################################

Orderer: &OrdererDefaults #Specify the information of the Orderer node

    OrdererType: etcdraft // sorting algorithm

    Addresses:

        - orderer.flight.com:7050 //Sorting node address and port number

    EtcdRaft: //raft consensus configuration

        Consenters:

        - Host: orderer.flight.com

          Port: 7050

          ClientTLSCert: ../organizations/ordererOrganizations/flight.com/orderers/orderer.flight.com/tls/server.crt //Client TLS certification path

          ServerTLSCert: ../organizations/ordererOrganizations/flight.com/orderers/orderer.flight.com/tls/server.crt //Server-side TLS certification path

    BatchTimeout: 2s //Batch processing timeout

    BatchSize: //The batch size associated with the message

        MaxMessageCount: 10 //The maximum number of transactions in a block

        AbsoluteMaxBytes: 99 MB //The maximum number of bytes in a block

        PreferredMaxBytes: 512 KB //The recommended number of bytes for a block (if exceeded, put in a larger block)

    Organizations:

    Policies:

        Readers:

            Type: ImplicitMeta

            Rule: "ANY Readers"

        Writers:

            Type: ImplicitMeta

            Rule: "ANY Writers"

        Admins:

            Type: ImplicitMeta

            Rule: "MAJORITY Admins"

        BlockValidation: //block verification condition

            Type: ImplicitMeta

            Rule: "ANY Writers"

##################################################################

# CHANNEL channel section This section defines values ​​that encode code into configuration transactions or generation blocks for channel-related parameters.

##################################################################

Channel: &ChannelDefaults # Define the channel access strategy at this level

    Policies:

        Readers: // can invoke "deliver" API

            Type: ImplicitMeta

            Rule: "ANY Readers"

        Writers: // can invoke "broadcast" API

            Type: ImplicitMeta

            Rule: "ANY Writers"

        Admins: # By default, who can modify elements at this configuration level

            Type: ImplicitMeta

            Rule: "MAJORITY Admins"

    Capabilities: # Capabilities configures the ability requirements of the channel level, which is directly quoted here

        <<: *ChannelCapabilities

##################################################################

# Profile# Custom configuration section 

# The profiles configuration section is equivalent to the unified entrance of the configtxgen tool. By setting different configtxgen -profile parameters to determine what files to use configtxgen to generate, the profiles configuration section uses the configuration section prepared above to configure different files according to needs (although it can be displayed configuration, but it is best to use the method of referencing the default configuration, which means encapsulation).

##################################################################

Profiles: //This part is changed according to the project role

     TwoOrgsApplicationGenesis: #Organization definition identifier, customizable, the -profile parameter in the command must be consistent
        <<: *ChannelDefaults # referenced as the attribute of ChannelCapabilities
        Orderer: #Configuration attribute, system keyword, cannot be modified
            <<: *OrdererDefaults # Referenced as the attribute of OrdererDefaults
            Organizations:
                - *OrdererOrg # Referenced as the attribute of OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums: # Defines the organization contained in the system
            SampleConsortium:
                Organizations: # Organization contained in the system-
                    *Org1 # Refers to the config contained below
                    - *Org2
    TwoOrgsChannel: # Channel definition identifier, customizable
        Consortium: SampleConsortium
        <<: *ChannelDefaults                
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
            Capabilities:
                <<: *ApplicationCapabilities
 

  configtxgen --help 
  # Output the path and name of the genesis block file
  `-outputBlock string`
  # Specify the name of the created channel, if not specified, the system will provide a default name.
  `-channelID string`
  # Indicates the path of the output channel file And the name
  `-outputCreateChannelTx string`
  # Specify the node in the configuration file
  `-profile string`
  # Update the configuration information of the channel
  `-outputAnchorPeersUpdate string`
  # Specify the organization name
  `-asOrg string`

 Generate the creation block file, where -profile corresponds to the name we defined in the previous configuration file, -outputBlock specifies the path and name of the generated creation block file, -channelID is the name of the channel (the name of the channel is optional, but Note that it should be different from the channel name when generating the channel file below). Use the following command to get a file genesis.block in the channel-artifacts directory in the current directory .

configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/genesis.block -channelID fabric-channel

Generate a channel file, where -profile corresponds to the name we defined in the previous configuration file, -outputBlock specifies the path and name of the generated channel file, and -channelID is the name of the channel. The name of the channel is arbitrary, but be careful to be different from the channel name when generating the genesis block file above). Use the following command to get a file channel.tx in the channel-artifacts directory in the current directory .

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel

Generate the anchor node update file, where -p profile corresponds to the name we defined in the previous configuration file, -outputBlock specifies the path and name of the generated anchor node file, - channelID is the name of the channel (to generate the channel file with the above same as the channel name at the time). Use the following command to get a file Org1MSPanchors.tx in the channel-artifacts directory in the current directory .

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

おすすめ

転載: blog.csdn.net/m0_61970067/article/details/122537736