fabric004 fabric 核心模块----Peer模块的更为详细的介绍

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36336522/article/details/84337792

peer模块式fabric中最重要的模块,也是fabric系统中使用最多的模块;peer模块在Fabric中被称为主节点模块,主要负责:

存储区块链数据、运行维护链码、提供对外服务接口等作用。


peer的环境变量

export set CORE_VM_ENDPOINT=unix:// /var/run/docker.sock 
export set CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=host 
export set CORE_PEER_PROFILE_ENABLED=true 
export set CORE_LOGGING_LEVEL=debug 
export set CORE_PEER_ID=peer0.org1.qklszzn.com 
export set CORE_PEER_GOSSIP_USELEADERELECTION=true
export set CORE_PEER_GOSSIP_ORGLEADER=false /
export set CORE_PEER_PEER_ADDRESS=peer0.org1.qklszzn.com:7051 
export set CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.qklszzn.com:7052
export set CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.qklszzn.com:7051 
export set CORE_PEER_LOCALMSPID=Org1MSP 
export set CORE_PEER_MSPCONFIGPATH=/opt/hyperledger/fabricconfig/crypto-config/
                                     peerOrganizations/org1.qklszzn.com/peers/peer0.org1.qklszzn.com/msp 
export set CORE_PEER_TLS_ENABLED=false 
export set CORE_PEER_TLS_CERT_FILE=/opt/hyperledger/fabricconfig/crypto-config/                                                                                             peerOrganizations/org1.qklszzn.com/peers/peer0.org1.qklszzn.com/tls/server.crt                               export set CORE_PEER_TLS_KEY_FILE=/opt/hyperledger/fabricconfig/crypto-config/                                                                                             peerOrganizations/org1.qklszzn.com/peers/peer0.org1.qklszzn.com/tls/server.key                           export set CORE_PEER_TLS_ROOTCERT_FILE=/opt/hyperledger/fabricconfig/crypto-config/                                                                                             peerOrganizations/org1.qklszzn.com/peers/peer0.org1.qklszzn.com/tls/ca.crt 


peer模块配置文件

peer模块分成五大部分:logging,peer,vm,chaincode,ledge五大部分

  • logging 定义peer模块中所有模块的日志级别和日志格式
  • peer定义了peer模块一般的配置信息
  • vm定义peer和docker交互的相关配置
  • chaincode定义了链码的相关配置
  • ledge定义了账本相关的配置
Peer---croe.yaml
  ################################################################################
  # LOGGING section
  ################################################################################
  logging:
   
  # Default logging levels are specified here for each of the three peer
  # commands 'node', 'network' and 'chaincode'. For commands that have
  # subcommands, the defaults also apply to all subcommands of the command.
  # Valid logging levels are case-insensitive strings chosen from
   
  # FATAL | PANIC | ERROR | WARNING | INFO | DEBUG
   
  # The logging levels specified here can be overridden in various ways,
  # listed below from strongest to weakest:
  #
  # 1. The --logging-level=<level> command line option overrides all other
  # specifications.
  #
  # 2. The environment variable CORE_LOGGING_LEVEL otherwise applies to
  # all peer commands if defined as a non-empty string.
  #
  # 3. The environment variables CORE_LOGGING_[NODE|NETWORK|CHAINCODE]
  # otherwise apply to the respective peer commands if defined as non-empty
  # strings.
  #
  # 4. Otherwise, the specifications below apply.
  #
  # Developers: Please see fabric/docs/Setup/logging-control.md for more
  # options.
  peer: warning
  node: warning
  network: warning
  version: warning
  protoutils: warning
  error: warning
  msp: warning
  gossip: warning
  grpc: warning
  ledger: warning
  policies: warning
  cauthdsl: warning
   
  format: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'
   
  ###############################################################################
  # Peer section
  ###############################################################################
  peer:
   
  # The Peer id is used for identifying this Peer instance.
peer 节点的编号 id: jdoe
   
  # The networkId allows for logical seperation of networks
  # networkId: dev
  # networkId: test
peer节点的网络编号 networkId: dev
   
  # The Address this Peer will listen on
chaincode的监听地址 listenAddress: 0.0.0.0:7051
  # Represents the peer's endpoint to peers in its organization
  # for other peers, see externalEndpoint
访问地址 address: 0.0.0.0:7051
  # Whether the Peer should programmatically determine its address
  # This case is useful for docker containers.
锚节点地址 addressAutoDetect: false
   
  # Setting for runtime.GOMAXPROCS(n). If n < 1, it does not change the current setting
  gomaxprocs: -1
   
  # Gossip related configuration
  gossip:
  # Bootstrap set to initialize gossip with
启动节点后向哪些节点发起gossip连接以加入网络 bootstrap: 127.0.0.1:7051
   
  # NOTE: orgLeader and useLeaderElection parameters are mutual exclusive
  # setting both to true would result in the termination of the peer, since this is undefined
  # state.
   
  # Defines whenever peer will initialize dynamic algorithm for
  # "leader" selection, where leader is the peer to establish
  # connection with ordering service and use delivery protocol
  # to pull ledger blocks from ordering service
用户组织节点的生成方式 useLeaderElection: true
  # Statically defines peer to be an organization "leader",
  # where this means that current peer will maintain connection
  # with ordering service and disseminate block across peers in
  # its own organization
当前组织节点是都为用户组织节点 orgLeader: false
   
  # ID of this instance

本节点在同一组织内的gossip_id默认是peer.address

endpoint:
  # Maximum count of blocks we store in memory
保存到内存中的区块个数的上限 maxBlockCountToStore: 100
  # Max time between consecutive message pushes(unit: millisecond)
保存消息的最大时间超过则触发转发给其他节点 maxPropagationBurstLatency: 10ms
  # Max number of messages stored until it triggers a push to remote peers
保存消息最大个数-超过触发转发给其他节点 maxPropagationBurstSize: 10
  # Number of times a message is pushed to remote peers
消息转发的次数 propagateIterations: 1
  # Number of peers selected to push messages to
推送消息给指定个数的节点 propagatePeerNum: 3
  # Determines frequency of pull phases(unit: second)
  # Must be greater than digestWaitTime + responseWaitTime
拉去消息的时间间隔 pullInterval: 4s
  # Number of peers to pull from
从制定个数的节点拉去消息 pullPeerNum: 3
  # Determines frequency of pulling state info messages from peers(unit: second)
从节点拉取状态信息消息间隔 requestStateInfoInterval: 4s
  # Determines frequency of pushing state info messages to peers(unit: second)
向其他节点推送状态信息消息的间隔 publishStateInfoInterval: 4s
  # Maximum time a stateInfo message is kept until expired
状态信息消息的超时时间 stateInfoRetentionInterval:
  # Time from startup certificates are included in Alive messages(unit: second)
启动,在心跳消息中镶嵌证书的等待时间 publishCertPeriod: 10s
  # Should we skip verifying block messages or not
是否不对区块信息进行校验,默认false skipBlockVerification: false
  # Dial timeout(unit: second)
gRPC连接拨号的超时时间 dialTimeout: 3s
  # Connection timeout(unit: second)
建立连接的超时时间 connTimeout: 2s
  # Buffer size of received messages
收取消息的缓冲大小 recvBuffSize: 20
  # Buffer size of sending messages
发送消息的缓冲大小 sendBuffSize: 20
  # Time to wait before pull engine processes incoming digests (unit: second)
  # Should be slightly smaller than requestWaitTime
处理摘要数据的等待时间 digestWaitTime: 1s
  # Time to wait before pull engine removes incoming nonce (unit: milliseconds)
  # Should be slightly bigger than digestWaitTime
处理nonce数据的等待时间 requestWaitTime: 1500ms
  # Time to wait before pull engine ends pull (unit: second)
终止拉去数据处理的等待时间 responseWaitTime: 2s
  # Alive check interval(unit: second)
定期发送ALive心跳消息的时间间隔 aliveTimeInterval: 5s
  # Alive expiration timeout(unit: second)
Alive心跳消息超时时间 aliveExpirationTimeout: 25s
  # Reconnect interval(unit: second)
断线后重连的时间间隔 reconnectInterval: 25s
  # This is an endpoint that is published to peers outside of the organization.
  # If this isn't set, the peer will not be known to other organizations.
  externalEndpoint:
   
  # Leader election service configuration
  election:
  # Longest time peer wait for stable membership during leader election startup (unit: second)
  startupGracePeriod: 15s
  # Interval gossip membership sampled to check its stability (unit: second)
  membershipSampleInterval: 1s
  # Time pass since last declaration message before peer decide to go to election (unit: second)
  leaderAliveThreshold: 10s
  # Time between peer sends propose message and declare itself as a leader (sends declaration message) (unit: second)
  leaderElectionDuration: 5s
   
  # Sync related configuration
  sync:
  blocks:
  # Channel size for readonly SyncBlocks messages channel for receiving
  # blocks from oppositie Peer Endpoints.
  # NOTE: currently messages are not stored and forwarded, but rather
  # lost if the channel write blocks.
  channelSize: 10
  state:
  snapshot:
  # Channel size for readonly syncStateSnapshot messages channel
  # for receiving state deltas for snapshot from oppositie Peer Endpoints.
  # NOTE: when the channel is exhausted, the writes block for up to the
  # writeTimeout specified below
  channelSize: 50
  # Write timeout for the syncStateSnapshot messages
  # When the channel above is exhausted, messages block before being
  # discarded for this amount of time
  writeTimeout: 60s
  deltas:
  # Channel size for readonly syncStateDeltas messages channel for
  # receiving state deltas for a syncBlockRange from oppositie
  # Peer Endpoints.
  # NOTE: currently messages are not stored and forwarded,
  # but rather lost if the channel write blocks.
  channelSize: 20
   
  # TLS Settings for p2p communications
  tls:
  enabled: true
  cert:
  file: tls/server.crt
  key:
  file: tls/server.key
  rootcert:
  file: tls/ca.crt
   
  # The server name use to verify the hostname returned by TLS handshake
  serverhostoverride:
   
  # Path on the file system where peer will store data (eg ledger)
  fileSystemPath: /var/hyperledger/fabric/peer
   
  # BCCSP (Blockchain crypto provider): Select which crypto implementation or
  # library to use
  BCCSP:
  Default: SW
  SW:
  # TODO: The default Hash and Security level needs refactoring to be
  # fully configurable. Changing these defaults requires coordination
  # SHA2 is hardcoded in several places, not only BCCSP
  Hash: SHA2
  Security: 256
  # Location of Key Store
  FileKeyStore:
  # If "", defaults to 'mspConfigPath'/keystore
  # TODO: Ensure this is read with fabric/core/config.GetPath() once ready
  KeyStore:
   
  # Path on the file system where peer will find MSP local configurations
  mspConfigPath: msp
   
  # Identifier of the local MSP
  # ----!!!!IMPORTANT!!!-!!!IMPORTANT!!!-!!!IMPORTANT!!!!----
  # Deployers need to change the value of the localMspId string.
  # In particular, the name of the local MSP ID of a peer needs
  # to match the name of one of the MSPs in each of the channel
  # that this peer is a member of. Otherwise this peer's messages
  # will not be identified as valid by other nodes.
  localMspId: Org1MSP
   
  # Used with Go profiling tools only in none production environment. In
  # production, it should be disabled (eg enabled: false)
  profile:
  enabled: false
  listenAddress: 0.0.0.0:6060
   
  ###############################################################################
  # VM section
  ###############################################################################
  vm:
   
  # Endpoint of the vm management system. For docker can be one of the following in general
  # unix:///var/run/docker.sock
  # http://localhost:2375
  # https://localhost:2376
docker服务器Darmon的地址,默认取端口的套接字 endpoint: unix:///var/run/docker.sock
   
  # settings for docker vms
  docker:
启动docker的tls证书 tls:
  enabled: false
  ca:
  file: docker/ca.crt
  cert:
  file: docker/tls.crt
  key:
  file: docker/tls.key
   
  # Enables/disables the standard out/err from chaincode containers for debugging purposes
是否将docker消息绑定到指定的输出 attachStdout: false
   
  # Parameters of docker container creating. For docker can created by custom parameters
  # If you have your own ipam & dns-server for cluster you can use them to create container efficient.
  # NetworkMode Sets the networking mode for the container. Supported standard values are: `host`(default),`bridge`,`ipvlan`,`none`
  # dns A list of DNS servers for the container to use.
  # note: not support customize for `Privileged` `Binds` `Links` `PortBindings`
  # not support set LogConfig using Environment Variables
  # LogConfig sets the logging driver (Type) and related options (Config) for Docker
  # you can refer https://docs.docker.com/engine/admin/logging/overview/ for more detail configruation.
  hostConfig:
  NetworkMode: host
是否启用DNS服务器 Dns:
  # - 192.168.0.1
docker容器的日志配置信息 LogConfig:
日志类型 Type: json-file
  Config:
  max-size: "50m"
  max-file: "5"
  Memory: 2147483648
   
  ###############################################################################
  # Chaincode section
  ###############################################################################
  chaincode:
   
  # The id is used by the Chaincode stub to register the executing Chaincode
  # ID with the Peerand is generally supplied through ENV variables
  # the Path form of ID is provided when deploying the chaincode. The name is
  # used for all other requests. The name is really a hashcode
  # returned by the system in response to the deploy transaction. In
  # development mode where user runs the chaincode, the name can be any string
  id:
  path:
  name:
   
  # Generic builder environment, suitable for most chaincode types
  builder: $(DOCKER_NS)/fabric-ccenv:$(ARCH)-$(PROJECT_VERSION)
   
  golang:
  # golang will never need more than baseos
  runtime: $(BASE_DOCKER_NS)/fabric-baseos:$(ARCH)-$(BASE_VERSION)
   
  car:
  # car may need more facilities (JVM, etc) in the future as the catalog
  # of platforms are expanded. For now, we can just use baseos
  runtime: $(BASE_DOCKER_NS)/fabric-baseos:$(ARCH)-$(BASE_VERSION)
   
  java:
  # This is an image based on java:openjdk-8 with addition compiler
  # tools added for java shim layer packaging.
  # This image is packed with shim layer libraries that are necessary
  # for Java chaincode runtime.
  runtime: $(DOCKER_NS)/fabric-javaenv:$(ARCH)-$(PROJECT_VERSION)
   
  # timeout in millisecs for starting up a container and waiting for Register
  # to come through. 1sec should be plenty for chaincode unit tests
  startuptimeout: 300000
   
  # timeout in millisecs for invokes and initialize commands
  # this timeout is used by all chaincodes in all the channels including
  # system chaincodes. Default is 30000ms (30 seconds)
  executetimeout: 30000
   
  #timeout in millisecs for deploying chaincode from a remote repository.
  deploytimeout: 30000
   
  #mode - options are "dev", "net"
  #dev - in dev mode, user runs the chaincode after starting validator from
  # command line on local machine
  #net - in net mode validator will run chaincode in a docker container
   
  mode: net
   
  # keepalive in seconds. In situations where the communiction goes through a
  # proxy that does not support keep-alive, this parameter will maintain connection
  # between peer and chaincode.
  # A value <= 0 turns keepalive off
  keepalive: 0
   
  # system chaincodes whitelist. To add system chaincode "myscc" to the
  # whitelist, add "myscc: enable" to the list below, and register in
  # chaincode/importsysccs.go
  system:
  cscc: enable
  lscc: enable
  escc: enable
  vscc: enable
  qscc: enable
   
  # logging section for the chaincode container
  logLevel: warning
  logFormat: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'
   
  ###############################################################################
  #
  # Ledger section - ledger configuration encompases both the blockchain
  # and the state
  #
  ###############################################################################
  ledger:
   
  blockchain:
   
  state:
  # stateDatabase - options are "goleveldb", "CouchDB"
  # goleveldb - default state database stored in goleveldb.
  # CouchDB - store state database in CouchDB
  stateDatabase: CouchDB
  couchDBConfig:
  # It is recommended to run CouchDB on the same server as the peer, and
  # not map the CouchDB container port to a server port in docker-compose.
  # Otherwise proper security must be provided on the connection between
  # CouchDB client (on the peer) and server.
  couchDBAddress: 127.0.0.1:5984
  # This username must have read and write authority on CouchDB
  username:
  # The password is recommended to pass as an environment variable
  # during start up (eg LEDGER_COUCHDBCONFIG_PASSWORD).
  # If it is stored here, the file must be access control protected
  # to prevent unintended users from discovering the password.
  password:
  # Number of retries for CouchDB errors
  maxRetries: 3
  # Number of retries for CouchDB errors during peer startup
  maxRetriesOnStartup: 10
  # CouchDB request timeout (unit: duration, e.g. 20s)
  requestTimeout: 35s
  # Limit on the number of records to return per query
  queryLimit: 10000
   
  # historyDatabase - options are true or false
  # Indicates if the history of key updates should be stored in goleveldb
  historyDatabase: true
   
  # Limit on the number of records to return per query
  queryLimit: 10000

猜你喜欢

转载自blog.csdn.net/qq_36336522/article/details/84337792
今日推荐