Hyperledger Fabric相关文件解析
1相关文件说明
这一部分涉及相关配置文件的解析,
网络的启动涉及到多个文件,本文按以下顺序进行分析:
.
├── base
│ ├── docker-compose-base.yaml #1
│ └── peer-base.yaml #2
├── channel-artifacts
├── configtx.yaml #5
├── crypto-config.yaml
├── docker-compose-cli.yaml #3
├── docker-compose-couch.yaml #4
├── docker-compose-e2e-template.yaml 该文件中定义了fabric-ca的配置信息。我们这里用不到,会在讲解Fabric-Ca的文章中说明
3.1 docker-compose-base.yaml
文件详解
先看一下文件内容:
version: '2' #docker版本services: #服务,可以包括若干个容器实例orderer.example.com: #定义一个名称为orderer.example.com的服务container_name: orderer.example.com #当前容器名称extends: #扩展,代表需要加载的文件或服务file: peer-base.yaml service: orderer-basevolumes: #挂载的卷 [本机路径下的文件或目录]:[容器中所映射到的地址]#比如本机下的channel-artifacts/genesis.block文件可以在容器中/var/hyperledger/orderer/orderer.genesis.block访问- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls- orderer.example.com:/var/hyperledger/production/ordererports: #所映射的端口 [本机端口]:[容器端口]- 7050:7050peer0.org1.example.com: #定义一个名称为peer0.org1.example.com的服务container_name: peer0.org1.example.com #当前容器名称extends: #同上file: peer-base.yamlservice: peer-baseenvironment: #定义环境变量- CORE_PEER_ID=peer0.org1.example.com #peer节点的id- CORE_PEER_ADDRESS=peer0.org1.example.com:7051 #peer节点的访问地址- CORE_PEER_LISTENADDRESS=0.0.0.0:7051 #peer节点的监听地址- CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:7052 #peer节点的链码访问地址- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052 #peer节点的链码监听地址 指定为0.0.0.0则自动进行探测- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:8051 #gossip为共识机制- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 #gossip外部节点,表明为锚节点- CORE_PEER_LOCALMSPID=Org1MSPvolumes: #同上,挂载卷- /var/run/:/host/var/run/- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls- peer0.org1.example.com:/var/hyperledger/productionports: #同上,端口- 7051:7051peer1.org1.example.com:container_name: peer1.org1.example.comextends:file: peer-base.yamlservice: peer-base......
3.2 peer-base.yaml
文件详解
version: '2'services:peer-base: #定义一个名称为peer-base的服务image: hyperledger/fabric-peer:$IMAGE_TAG #该服务所依赖的镜像environment: #定义环境变量- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn #定义网络工作模式,这里使用的是bridge方式- FABRIC_LOGGING_SPEC=INFO #定义日志级别为INFO#- FABRIC_LOGGING_SPEC=DEBUG- CORE_PEER_TLS_ENABLED=true #使用TLS- CORE_PEER_GOSSIP_USELEADERELECTION=true #使用选举LEADER的方式- CORE_PEER_GOSSIP_ORGLEADER=false #不指定LEADER- CORE_PEER_PROFILE_ENABLED=true #使用profile- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt #TLS证书路径- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key #TLS密钥路径- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt #TLS根证书路径working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer #工作目录,即进入容器所在的默认位置command: peer node start #启动容器后所运行的第一条命令:启动Peer节点 orderer-base: #定义一个名称为orderer-base的服务image: hyperledger/fabric-orderer:$IMAGE_TAG #该服务所依赖的镜像environment: #环境变量- FABRIC_LOGGING_SPEC=INFO #日志级别- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 #orderer的监听地址- ORDERER_GENERAL_GENESISMETHOD=file # 创世区块文件的类型为file- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block #创世区块在容器中的路径- ORDERER_GENERAL_LOCALMSPID=OrdererMSP #Orderer的本地MSPid- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp #本地Msp文件夹# enabled TLS- ORDERER_GENERAL_TLS_ENABLED=true #使用TLS- ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key #TLS私钥路径- ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt #TLS证书路径- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] #TLS根证书路径- ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1 #以下为kafka集群的配置,本文中没有使用到- ORDERER_KAFKA_VERBOSE=true- 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]working_dir: /opt/gopath/src/github.com/hyperledger/fabric #工作目录,即进入容器所在的默认位置command: orderer #启动容器后所运行的第一条命令:启动orderer
3.3 docker-compose-cli.yaml
文件详解
version: '2'volumes: #声明挂载的卷orderer.example.com:peer0.org1.example.com:peer1.org1.example.com:peer0.org2.example.com:peer1.org2.example.com:networks: #声明一个名称为byfn的网络byfn:services:orderer.example.com: #定义一个名称为orderer.example.com的服务extends: #扩展,代表需要加载的文件或服务 即使用了其中的配置信息file: base/docker-compose-base.yaml service: orderer.example.com container_name: orderer.example.com #当前容器名称networks: #指定当前容器所加入的网络,如果需要加入多个网络,可以定义多个- byfn#以下同上peer0.org1.example.com: container_name: peer0.org1.example.comextends:file: base/docker-compose-base.yamlservice: peer0.org1.example.comnetworks:- byfnpeer1.org1.example.com:container_name: peer1.org1.example.comextends:file: base/docker-compose-base.yamlservice: peer1.org1.example.comnetworks:- byfnpeer0.org2.example.com:container_name: peer0.org2.example.comextends:file: base/docker-compose-base.yamlservice: peer0.org2.example.comnetworks:- byfnpeer1.org2.example.com:container_name: peer1.org2.example.comextends:file: base/docker-compose-base.yamlservice: peer1.org2.example.comnetworks:- byfncli: #定义一个客户端容器,方便与各节点进行交互container_name: cli #客户端容器名称image: hyperledger/fabric-tools:$IMAGE_TAG #该服务所依赖的镜像tty: true #使用伪终端stdin_open: true #标准输入environment: #环境变量- GOPATH=/opt/gopath #指定go的路径- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock#- FABRIC_LOGGING_SPEC=DEBUG- FABRIC_LOGGING_SPEC=INFO #日志级别- CORE_PEER_ID=cli #当前节点的Id- CORE_PEER_ADDRESS=peer0.org1.example.com:7051 #以下与peer-base.yaml相同,表示当前客户端容器默认与peer0.org1.example.com进行交互- CORE_PEER_LOCALMSPID=Org1MSP- CORE_PEER_TLS_ENABLED=true- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt #TLS-peer0.org1.example.com的证书路径- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key #TLS-peer0.org1.example.com的密钥路径- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt #TLS-peer0.org1.example.com的根证书路径- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp @#TLS-组织1中Admin的MSP路径working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer #工作目录,即进入容器所在的默认位置command: /bin/bash #启动容器后所运行的第一条命令:使用bashvolumes: #挂载卷- /var/run/:/host/var/run/- ./../chaincode/:/opt/gopath/src/github.com/chaincode- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifactsdepends_on: #依赖,需要首先按顺序启动以下容器,但是不会等待以下容器完全启动才启动当前容器- orderer.example.com- peer0.org1.example.com- peer1.org1.example.com- peer0.org2.example.com- peer1.org2.example.comnetworks: #指定当前容器所加入的网络- byfn
3.4 docker-compose-couch.yaml
文件详解
在fabric网络中,可以使用默认的levelDb数据库,或者使用CouchDb,该文件主要是对CouchDb进行相关设置。
version: '2'networks: #声明一个名称为byfn的网络byfn:services:couchdb0: #定义一个couchdb0的服务container_name: couchdb0 #指定该容器名称为couchdb0image: hyperledger/fabric-couchdb #该容器所依赖的镜像environment: #环境变量- COUCHDB_USER= #couchdb0的用户名,这里设置为空,表明任何人都可登陆- COUCHDB_PASSWORD= #couchdb0的登陆密码,这里设置为空ports: #所映射的端口- "5984:5984"networks: #使用的网络- byfnpeer0.org1.example.com: #定义一个peer0.org1.example.com的服务environment:- CORE_LEDGER_STATE_STATEDATABASE=CouchDB #指定该服务使用的标准数据库为CouchDB- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984 #指定该服务使用的数据库访问地址- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME= #配置数据库用户名- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=#配置数据库密码depends_on: #表明该服务依赖于couchdb0- couchdb0couchdb1: #以下同上container_name: couchdb1image: hyperledger/fabric-couchdb......
3.5 configtx.yaml
文件详解
该文件中定义了fabric网络中的相关策略信息,内容相对比较多,这里只讲解所用到的部分。
Organizations: #组织信息- &OrdererOrg #配置orderer的信息Name: OrdererOrg #定义名称ID: OrdererMSP #定义IDMSPDir: crypto-config/ordererOrganizations/example.com/msp #指定MSP的文件目录Policies: #定义相关策略Readers: #可读Type: Signature Rule: "OR('OrdererMSP.member')" #具体策略:允许OrdererMSP中所有member读操作Writers: #可写Type: SignatureRule: "OR('OrdererMSP.member')"Admins: #adminType: SignatureRule: "OR('OrdererMSP.admin')"- &Org1 #配置组织一的信息Name: Org1MSP #定义组织一的名称ID: Org1MSP #定义组织一的IDMSPDir: crypto-config/peerOrganizations/org1.example.com/msp #指定MSP的文件目录Policies: #定义相关策略Readers: #可读Type: SignatureRule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')" #Org1MSP中的admin,peer,client均可进行读操作Writers: #可写Type: SignatureRule: "OR('Org1MSP.admin', 'Org1MSP.client')" #Org1MSP中的admin,client均可进行读操作Admins: #同上Type: SignatureRule: "OR('Org1MSP.admin')"AnchorPeers: #指定Org1的锚节点,只有锚节点可以与另一个组织进行通信- Host: peer0.org1.example.com #指定Org1的锚节点的地址 Port: 7051 #指定Org1的锚节点的端口- &Org2 #同上Name: Org2MSPID: Org2MSPMSPDir: crypto-config/peerOrganizations/org2.example.com/mspPolicies:Readers:Type: SignatureRule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')"Writers:Type: SignatureRule: "OR('Org2MSP.admin', 'Org2MSP.client')"Admins:Type: SignatureRule: "OR('Org2MSP.admin')"AnchorPeers:- Host: peer0.org2.example.comPort: 9051
Capabilities: #这一区域主要是定义版本的兼容情况Channel: &ChannelCapabilitiesV1_3: trueOrderer: &OrdererCapabilitiesV1_1: trueApplication: &ApplicationCapabilitiesV1_3: trueV1_2: falseV1_1: false
Application: &ApplicationDefaults #同上,定义具体的策略Organizations:Policies:Readers:Type: ImplicitMetaRule: "ANY Readers"Writers:Type: ImplicitMetaRule: "ANY Writers"Admins:Type: ImplicitMetaRule: "MAJORITY Admins"Capabilities:<<: *ApplicationCapabilities
################################################################################
#
Orderer: &OrdererDefaultsOrdererType: solo #定义网络类型为soloAddresses: #定义orderer的地址- orderer.example.com:7050BatchTimeout: 2s #定义创建一个区块的超时时间BatchSize:MaxMessageCount: 10 #区块内最大消息数AbsoluteMaxBytes: 99 MB #区块内消息所占的最大空间PreferredMaxBytes: 512 KBOrganizations:Policies:Readers:Type: ImplicitMetaRule: "ANY Readers"Writers:Type: ImplicitMetaRule: "ANY Writers"Admins:Type: ImplicitMetaRule: "MAJORITY Admins"BlockValidation: #区块的验证策略Type: ImplicitMetaRule: "ANY Writers"
################################################################################
Channel: &ChannelDefaultsPolicies:Readers: #定义谁可以调用交付区块的APIType: ImplicitMetaRule: "ANY Readers"Writers: #定义谁可以调用广播区块的APIType: ImplicitMetaRule: "ANY Writers"Admins: #定义谁可以修改配置信息Type: ImplicitMetaRule: "MAJORITY Admins"Capabilities:<<: *ChannelCapabilitiesProfiles:TwoOrgsOrdererGenesis:<<: *ChannelDefaultsOrderer:<<: *OrdererDefaultsOrganizations:- *OrdererOrgCapabilities:<<: *OrdererCapabilitiesConsortiums:SampleConsortium:Organizations:- *Org1- *Org2TwoOrgsChannel:Consortium: SampleConsortium<<: *ChannelDefaultsApplication:<<: *ApplicationDefaultsOrganizations:- *Org1- *Org2Capabilities:<<: *ApplicationCapabilities
转载请注明作者与出处:https://www.cnblogs.com/cbkj-xd/ 个人网站主页:https://ifican.top
Hyperledger Fabric相关文件解析相关推荐
- arm linux s文件夹,armv7对应的CACHE操作相关文件解析
最近在使用TI的DRA726芯片.A15端需要访问图像,而图像是在外设空间的,用DMA拷贝到CACHE空间. 这样就导致了DMA的CACHE一致性的问题,需要在DMA之后清除所使用图像空间的数据CAC ...
- Hyperledger Fabric Docker 文件路径权限
为什么80%的码农都做不了架构师?>>> 添加权限路径 Docker -> preferences -> /opt/gopath/src/github.com/hy ...
- 超级账本Hyperledger Fabric的使用
原文地址:超级账本Hyperledger Fabric的使用 说明 网易云课堂:HyperLedger Fabric手动部署教程的视频讲解 超级账本HyperLedger Fabric手动部署教程的文 ...
- Hyperledger Fabric 通道配置文件和容器环境变量详解
Python微信订餐小程序课程视频 https://blog.csdn.net/m0_56069948/article/details/122285951 Python实战量化交易理财系统 https ...
- hyperledger fabric 交易结构以及解析
Fabric 1.0源代码分析(43) Tx(Transaction 交易)_yinchengmvp的技术博客_51CTO博客 Hyperledger Fabric的区块结构 交易结构Hyperled ...
- 记:ELF文件解析初定义——Section段相关讲解
0x00 概论 因为TI的DSP输出文件与传统的ELF文件不符,所以本人就顺道研究了一下现在的ELF的文件格式. 会将其陆续完成在文章中. 承接上文,上文书说到,解析文件头格式,数据段的分配定义,与数 ...
- 区块链相关论文研读3- 关于超级账本Hyperledger Fabric的性能优化
这是2019年6月发表在顶会Sigmod上面的论文,论文题目为<Blurring the Lines between Blockchains and Database Systems: the ...
- 利用Hyperledger Fabric开发你的第一个区块链应用
利用Hyperledger Fabric开发你的第一个区块链应用 本文示例源于fabric-samples中的fabcar https://github.com/hyperledger/fabric- ...
- 利用Hyperledger Fabric开发第一个区块链应用
利用Hyperledger Fabric开发第一个区块链应用 Fabric入门 Fabric 我们通过一个简单的示例程序来了解Fabric应用是如何运行的.在这个例子中使用的应用程序和智能合约(链码) ...
最新文章
- 【TPAMI2022】关联关系驱动的多模态分类
- Focus on the Good 专注于好的方面
- 总结一下最近面试经常被问到的问题(2019年4月)
- 【贪心School】机器学习课程笔记
- PowerShell在SharePoint 2010自动化部署中的应用(1)--代码获取
- 【虹科免费直播预告】光电技术直播月重磅来袭!
- transcad安装教程_Transcad基础视频教程
- 解决 invalid DSN: missing the slash separating the database name
- 创业者需要干掉的三种思维
- Can‘t reconnect until invalid transaction is rolled back
- mac远程控制程序:AnyDesk for Mac
- sakila数仓实战案例
- Design patterns 设计模式
- 小胖机器人宣传语_智能机器人推广宣传语
- Unity-3d小游戏开发-----走迷宫
- t420i升级固态硬盘提升_给自己的办公设备大升级:购入雷克沙固态移动硬盘,享受高速...
- Windows Mobile 6 模拟器上网设置
- 双线路-双路由器备份实例
- mac mysql 忘记初始root密码,重置密码
- [解读小程序]手机归属地查询Demo(四)
热门文章
- 用php写京东抢购,关于抢京东券高并发的问题?
- 【自动驾驶】定位方式:RTK定位与激光融合定位
- faster rcnn源码解读(三)train_faster_rcnn_alt_opt.py
- 《阿里巴巴 Java 开发手册》读书笔记
- Java 泛型中? super T和? extends T的区别
- Java开发的几个注意点
- 深度学习(三)theano学习笔记(2)基础函数-未完待续
- Python基础教程(七):函数、模块
- Python基础教程(五):数字、字符串
- 从hello server开始,到hello client结束