Fabric官网:Introduction — hyperledger-fabricdocs main documentation
1.测试网络
./network.sh up #启动./network.sh down #关闭
2.Fabric核心模块
peer:主节点模块,负责存储区块链数据,运行维护链码
orderer:交易打包、排序模块
cryptogen:组织和证书生成模块
configtxgen:区块和交易生成模块
configtxlator:区块和交易解析模块
peer与orderer属于系统模块,其它三个属于工具模块
3.cryptogen模块的配置文件
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# ---------------------------------------------------------------------------
# "OrdererOrgs" - 管理orderer节点的组织的定义
# ---------------------------------------------------------------------------
OrdererOrgs: # 定义管理orderer节点的组织
# ---------------------------------------------------------------------------
# Orderer
# ---------------------------------------------------------------------------
- Name: Orderer #这个组织的名字叫 Orderer
Domain: hmw.com #这个组织的域名是 hmw.com
# 生成证书的时候,证书内会包含Name和Domain信息,orderer.hmw.com就是这个组织的地址
EnableNodeOUs: true
# ---------------------------------------------------------------------------
# "Specs"
# ---------------------------------------------------------------------------
# Uncomment this section to enable the explicit definition of hosts in your
# configuration. Most users will want to use Template, below
#
# Specs is an array of Spec entries. Each Spec entry consists of two fields:
# - Hostname: (Required) The desired hostname, sans the domain.
# - CommonName: (Optional) Specifies the template or explicit override for
# the CN. By default, this is the template:
#
# "{{.Hostname}}.{{.Domain}}"
#
# which obtains its values from the Spec.Hostname and
# Org.Domain, respectively.
# ---------------------------------------------------------------------------
# - Hostname: foo # implicitly "foo.org1.example.com"
# CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above
# - Hostname: bar
# - Hostname: baz
# ---------------------------------------------------------------------------
# "Specs" - See PeerOrgs for complete description
# ---------------------------------------------------------------------------
# 对于一个Spec来说,配置了CommonName,那么文件夹则命名为CommonName
# 如果没有配置CommonName,则文件名为:{{.Hostname}}.{{Domain}}
# 在下面的例子中,在 organizations/ordererOrganizations/hmw.com/orderers 目录下
# 则会产生两个文件orderer0.hmw.com、orderer1.hmw.com、orderer2.hmw.com,
# 如果没有加CommonName,则目录名为order.example.com与order5.example.comn
Specs:
- Hostname: orderer0
SANS:
- localhost
- Hostname: orderer1
SANS:
- localhost
- Hostname: orderer2
SANS:
- localhost
# CommonName: orderer0.hmw.com
#- Hostname: orderer1
# CommonName: orderer1.hmw.com
# Hostname: orderer2
# CommonName: orderer2.hmw.com
# ---------------------------------------------------------------------------
# "PeerOrgs" - 管理对等节点的组织的定义
# ---------------------------------------------------------------------------
PeerOrgs:
# ---------------------------------------------------------------------------
# 定义Org1组织
# ---------------------------------------------------------------------------
- Name: Org1 #组织名称
Domain: org1.hmw.com #域名称
EnableNodeOUs: true
# 如果设置了 EnableNodeOUs ,就在msp下生成config.yaml文件
# ---------------------------------------------------------------------------
# "Template"
# ---------------------------------------------------------------------------
# Template是按照Template模板生成多个文件,数量由Count决定,起始编号由Start决定
# 如下配置会在 organizations/peerOrganizations/org1.hmw.com/peers目录下,
# 生成两个文件,分别是 peer0.org1.hmw.com 和 peer1.org1.hmw.com
# 如果把Start注释去掉,那么会生成 peer5.org1.hmw.com 和 peer6.org1.hmw.com
Template: # 组织中peer节点的数目
Count: 2
SANS:
- localhost
# Start: 5
# Hostname: {{.Prefix}}{{.Index}} # default
# ---------------------------------------------------------------------------
# "Users"
# ---------------------------------------------------------------------------
# Count: The number of user accounts _in addition_ to Admin
# ---------------------------------------------------------------------------
# Users是生成除了Admin之外多少个user,数量由Count决定
# 对于orderer组织,这个值设置了也没有效果
# 如果配置会在 organizations/peerOrganizations/org1.hmw.com/users目录下,
# 生成两个文件,分别是Admin@org1.hmw.com和User1@org1.hmw.com
# 如果改为2,那么会多一个User2@org1.hmw.com
Users:
Count: 1 #除Admin之外的用户账户数目
4.configtxgen模块配置文件
#Profiles 配置入口
Profiles:
# # TwoOrgsOrdererGenesis用来生成orderer启动时所需的block,用于生成创世区块,名字可以任意
TwoOrgsApplicationGenesis:
<<: *ChannelDefaults
# 指定Orderer系统通道自身的配置信息
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg # 引用 Orderer 部分的配置 &OrdererDefaults
Capabilities: *OrdererCapabilities #引用&OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities: *ApplicationCapabilities
#orderer节点相关信息
Orderer: &OrdererDefaults
# Orderer 类型: 要启动的Orderer实现类型
# 定义order共识机制
OrdererType: etcdraft
# 地址曾经是Client和peer可以连接到的orderer地址列表。 但是,这不允许client关联orderer地
# 址和orderer组织,这对于诸如 TLS 验证之类的事情很有用。 现在,指定订购者地址的首选方法是
# 在您的组织定义中包含 OrdererEndpoints 项
Addresses:
- orderer0.hmw.com:7050
- orderer1.hmw.com:7052
- orderer2.hmw.com:7054
# 定义了EtcdRaft排序类型被选择时的配置
EtcdRaft:
Consenters:
- Host: orderer0.hmw.com
Port: 7050
ClientTLSCert: ../organizations/ordererOrganizations/hmw.com/orderers/orderer0.hmw.com/tls/server.crt
ServerTLSCert: ../organizations/ordererOrganizations/hmw.com/orderers/orderer0.hmw.com/tls/server.crt
- Host: orderer1.hmw.com
Port: 7052
ClientTLSCert: ../organizations/ordererOrganizations/hmw.com/orderers/orderer1.hmw.com/tls/server.crt
ServerTLSCert: ../organizations/ordererOrganizations/hmw.com/orderers/orderer1.hmw.com/tls/server.crt
- Host: orderer2.hmw.com
Port: 7054
ClientTLSCert: ../organizations/ordererOrganizations/hmw.com/orderers/orderer2.hmw.com/tls/server.crt
ServerTLSCert: ../organizations/ordererOrganizations/hmw.com/orderers/orderer2.hmw.com/tls/server.crt
# 区块打包的最大超时时间 (到了该时间就打包区块)
BatchTimeout: 2s
# 区块打包的最大包含交易数(orderer端切分区块的参数)
BatchSize:
# 一个区块里最大的交易数
MaxMessageCount: 10
# 一个区块的最大字节数,任何时候都不能超过
AbsoluteMaxBytes: 99 MB
# 一个区块的建议字节数,如果一个交易消息的大小超过了这个值, 就会被放入另外一个更大的区
# 块中
PreferredMaxBytes: 512 KB
# 参与维护Orderer的组织,默认为空
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
# BlockValidation 指定了必须在来自 orderer 的块中包含哪些签名,以便对等方对其进行验#
# 证。
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
#Organizations部分
Organizations:
- &OrdererOrg
# 组织名称
Name: OrdererOrg
# 组织ID,ID是引用组织的关键
ID: OrdererMSP
# 组织的MSP证书路径
MSPDir: ../organizations/ordererOrganizations/hmw.com/msp
# 定义本层级的组织策略,其权威路径为 /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
Policies:
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
OrdererEndpoints:
- orderer0.hmw.com:7050
- orderer1.hmw.com:7052
- orderer2.hmw.com:7054
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: ../organizations/peerOrganizations/org1.hmw.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.hmw.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')"
#kafka相关配置
Kafka:
Brokers:
- kafka0:9092
- kafka1:9092
- kafka2:9092
- kafka3:9092
Organizations:
Application: &ApplicationDefaults
Organization: