orderer模块主要负责对交易进行排序,并将排序好的交易打包成区块。
usage: orderer [>] > [> ...]
Hyperledger Fabric orderer node
Flags:
--help #显示帮助信息
Commands:
help [>...]
#显示子命令的帮助信息
start*
#启动orderer节点
version
#显示版本信息
orderer模块的配置选项可以通过环境变量或者配置文件的方式来配置,在具体操作中,如果是通过Docker方式启动,一般使用环境变量配置方式。如果是采用直接命令启动,一般是采用配置文件方式
环境变量的配置示例如下:
注意:下面的环境变量配置信息仅供参考,并不完整
export set ORDERER_GENERAL_LOGLEVEL=debug
export set ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
export set ORDERER_GENERAL_GENESISMETHOD=file
export set ORDERER_GENERAL_GENESISFILE=/home/zym/fabric-ws/simple-demo/order/orderer.genesis.block
export set ORDERER_GENERAL_LOCALMSPID=OrdererMSP
export set ORDERER_GENERAL_LOCALMSPDIR= /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/msp
export set ORDERER_GENERAL_TLS_ENABLED=false
export set ORDERER_GENERAL_TLS_PRIVATEKEY=/home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/server.key
export set ORDERER_GENERAL_TLS_CERTIFICATE=/home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/server.crt
export set ORDERER_GENERAL_TLS_ROOTCAS=[/home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/ca.crt]
配置文件示例如下:
注意:这个示例就是《Fabric实战(2)运行一个简单的fabric网络(容器外)》的orderer.yaml文件
General:
LedgerType: file
ListenAddress: 0.0.0.0
ListenPort: 7050
TLS:
Enabled: false
PrivateKey: /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/server.key
Certificate: /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/server.crt
RootCAs:
- /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/ca.crt
ClientAuthEnabled: false
ClientRootCAs:
LogLevel: debug
#LogFormat: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x} %{color:reset} %{message}'
GenesisMethod: file
GenesisProfile: TestOrgsOrdererGenesis
GenesisFile: /home/zym/fabric-ws/simple-demo/order/orderer.genesis.block
LocalMSPDir: /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/msp
LocalMSPID: OrdererMSP
Profile:
Enabled: false
Address: 0.0.0.0:6060
BCCSP:
Default: SW
SW:
Hash: SHA2
Security: 256
FileKeyStore:
KeyStore:
FileLedger:
Location: /home/zym/fabric-ws/simple-demo/order/production/orderer
Prefix: hyperledger-fabric-ordererledger
RAMLedger:
HistorySize: 1000
Kafka:
Retry:
ShortInterval: 5s
ShortTotal: 10m
LongInterval: 5m
LongTotal: 12h
NetworkTimeouts:
DialTimeout: 10s
ReadTimeout: 10s
WriteTimeout: 10s
Metadata:
RetryBackoff: 250ms
RetryMax: 3
Producer:
RetryBackoff: 100ms
RetryMax: 3
Consumer:
RetryBackoff: 2s
Verbose: false
TLS:
Enabled: false
PrivateKey:
Certificate:
#File: path/to/Certificate
RootCAs:
#File: path/to/RootCAs
Version:
orderer模块的配置文件一共有4部分组成,分别是: General、FileLedger、RAMLedger、Kafka。
General部分包含了orderer模块基本控制信息:
General:
LedgerType: file #账本类型,支持ram、json、file。ram表示账本的数据存储在内存中,一般用于测试环境。json和file表示账本数据保存在文件中,在实际生产环境一般是使用file
ListenAddress: 0.0.0.0 #orderer服务监听的地址
ListenPort: 7050 #orderer服务监听的端口号
TLS:
Enabled: false #是否使能TLS通信
#TLS私钥文件
PrivateKey: /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/server.key
#TLS公钥文件
Certificate: /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/server.crt
#TLS根证书文件
RootCAs:
- /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/tls/ca.crt
ClientAuthEnabled: false #是否启用客户端验证
ClientRootCAs: #客户端根证书
LogLevel: debug #日志级别
GenesisMethod: file #创世块来源方式,支持provisional或者file,provisional表示GenesisProfile指定的内容在默认的配置文件中配置自动生成的,file表示使用GenesisFile指定的现成创世区块
GenesisProfile: TestOrgsOrdererGenesis
GenesisFile: /home/zym/fabric-ws/simple-demo/order/orderer.genesis.block
#orderer的msp路径
LocalMSPDir: /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/orderers/orderer.simple-network.com/msp
LocalMSPID: OrdererMSP #orderer的名称,在configtxgen模块的配置文件中指定。
Profile:
Enabled: false #是否启动go Profile
Address: 0.0.0.0:6060 #go profile信息访问地址
BCCSP:
Default: SW #采用的加密机制,SW为软件实现,PKCS11表示采用硬件实现
SW:
Hash: SHA2 #hash算法类型
Security: 256 #hash长度
FileKeyStore:
KeyStore:
FileLedger:
#账本文件的存储路径
Location: /home/zym/fabric-ws/simple-demo/order/production/orderer
#账本文件存放在临时目录时候的目录名,如果已经指定了Location,则该选项无效
Prefix: hyperledger-fabric-ordererledger
RAMLedger:
#内存中保存的区块的数量,超过这个数目的区块将被放弃。
HistorySize: 1000
如果orderer节点的共识类型选择了solo,那么该节点的所有配置均无效。
Kafka:
Retry:
#操作失败端重试状态下重试的时间间隔
ShortInterval: 5s
#短重试状态下重试的时间
ShortTotal: 10m
#长重试状态下重试的时间间隔
LongInterval: 5m
#长重试状态下重试的时间
LongTotal: 12h
NetworkTimeouts:
#等待超时时间
DialTimeout: 10s
#读超时时间
ReadTimeout: 10s
#写超时时间
WriteTimeout: 10s
Metadata:
RetryBackoff: 250ms
RetryMax: 3
Producer:
RetryBackoff: 100ms
RetryMax: 3
Consumer:
RetryBackoff: 2s
#Kafka客户端日志级别,在orderer的运行日志中显示kafka日志
Verbose: false
TLS:
#Kafka是否启动TLS
Enabled: false
#TLS私钥
PrivateKey:
#TLS证书
Certificate:
#File: path/to/Certificate
#TLS根证书
RootCAs:
#File: path/to/RootCAs
#Kafa版本
Version: