【问题标题】:Where can I find out the possible environment variables for Hyperledger Fabric peer command?我在哪里可以找到 Hyperledger Fabric peer 命令的可能环境变量?
【发布时间】:2021-12-16 01:57:26
【问题描述】:

在配置对等节点运行时,示例 docker-compose 文件中包含许多环境变量。有没有什么地方我可以找到它们都记录在案的?

例如

environment:
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_PEER_ID=peer0.org1.example.com
  - CORE_LOGGING_PEER=debug
  - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
  - CORE_PEER_LOCALMSPID=Org1MSP
  - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
  - CORE_PEER_ADDRESS=peer0.org1.example.com:7051

【问题讨论】:

    标签: hyperledger hyperledger-fabric


    【解决方案1】:

    Hyperledger Fabric 提供了一个名为 core.yaml 的配置文件,您可以在文件夹 /etc/hyperledger/fabric/ 上找到peer container中的配置文件

    Fabric 使用Viper 作为配置框架,它提供了通过环境变量覆盖配置文件值的能力。基本上它初始化如下:

    // used to prefix config keys to prevent possible collisions
    viper.SetEnvPrefix("core") 
    
    // enforces to check values configured via environmental variables first
    viper.AutomaticEnv()
    

    这使得 viper 在以CORE 字符串为前缀的环境变量中寻找所有配置键。

    现在,如果我们在示例配置中查看peer section(更新):

    peer:            
        id: jdoe            
        networkId: dev    
        listenAddress: 0.0.0.0:7051    
        address: 0.0.0.0:7051
    

    这些值中的任何一个都可以通过导出适当的环境变量来覆盖,例如对等网络 ID:

    export CORE_PEER_NETWORKID=mypeerID
    

    同样适用于其他部分,例如,如果我们想控制不同组件的日志记录级别:

    logging:
    
        peer:       info
        cauthdsl:   warning
        gossip:     warning
        ledger:     info
        msp:        warning
        policies:   warning
        grpc: error
    

    要让 msp 组件记录调试级别的消息,我们需要导出以下变量:

    export PEER_LOGGING_MSP=debug
    

    请注意,这只有在对等启动之前导出才会生效。

    【讨论】:

      【解决方案2】:

      Hyperledger Fabric 提供了一个sample configuration file,它基本上包含了peer 组件的所有可能属性。当然,您需要使用以下公式将 yaml 属性转换为相应的环境变量名称:

      foo:
      
          bar: baz
      

      变成CORE_FOO_BAR=baz

      这同样适用于orderer 组件,它有自己的sample configuration file

      【讨论】:

      【解决方案3】:

      环境实际上是core.yaml中的项目,替换“。”用“_”

      【讨论】:

        【解决方案4】:

        一些环境变量可以在官方文档的Environment variables for the binaries部分找到。

        对等环境变量

        CORE_PEER_TLS_ENABLED=true
        CORE_PEER_GOSSIP_USELEADERELECTION=true
        CORE_PEER_GOSSIP_ORGLEADER=false
        CORE_PEER_PROFILE_ENABLED=true
        CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
        CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
        CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
        CORE_PEER_ID=peer0.org1.example.com
        CORE_PEER_ADDRESS=peer0.org1.example.com:7051
        CORE_PEER_LISTENADDRESS=0.0.0.0:7051
        CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:7052
        CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
        CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
        CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
        CORE_PEER_LOCALMSPID=Org1MSP
        

        排序节点变量

        ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
        ORDERER_GENERAL_GENESISMETHOD=file
        ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
        ORDERER_GENERAL_LOCALMSPID=OrdererMSP
        ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
        ORDERER_GENERAL_TLS_ENABLED=true
        ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
        ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
        ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
        ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
        ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
        ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2010-09-07
          • 2022-10-07
          • 2011-01-14
          相关资源
          最近更新 更多