首先我的fabric版本是2.3.0,在参考冯翔老师的《区块链开发实战》之Hyperledger fabric关键技术这本书上的配置文件configtx.yaml生成创世区块时出现了很多问题。
书上的配置文件configtx.yaml内容为:

Profiles:TestTwoOrgsOrdererGenesis:Orderer:<<: *OrdererDefaultsOrganizations:- *OrdererOrgConsortiums:SampleConsortium:Organizations:- *Org1- *Org2TestTwoOrgsChannel:Consortium: SampleConsortiumApplication:<<: *ApplicationDefaultsOrganizations:- *Org1- *Org2
Organizations:- &OrdererOrgName: OrdererOrgID: OrdererMSPMSPDir: crypto-config/ordererOrganizations/example.com/msp- &Org1Name: Org1MSPID: Org1MSPMSPDir: crypto-config/peerOrganizations/org1.example.com/mspAnchorPeers:- Host: peer0.org1.example.comPort: 7051- &Org2Name: Org2MSPID: Org2MSPMSPDir: crypto-config/peerOrganizations/org2.example.com/mspAnchorPeers:- Host: peer0.org2.example.comPort: 7051
Orderer: &OrdererDefaultsOrdererType: soloAddresses:- orderer.example.com:7050BatchTimeout: 2sBatchSize:MaxMessageCount: 10AbsoluteMaxBytes: 99 MBPreferredMaxBytes: 512 KBKafka:Brokers:- 127.0.0.1:9092Organizations:
Application: &ApplicationDefaultsOrganizations:

上述的配置文件在fabric2.3.0中出现了以下问题:

Error 1:Error reading configuration: While parsing config: yaml: unknown anchor 'OrdererDefaults' referenced [recovered]

因为使用的是最新版本,与书本上的版本不同,而最新版本在结构上做了一些改动。在使用‘*’之前,一定要有‘&’定义过了。所以需要把Profiles的内容移到最后。

Error 2:Error reading configuration: yaml: line 50: did not find expected key


这个是空格出了问题,在提示的行号附近检查空格是否出错。.yaml文件不能使用tab键。

Error 3:Error reading configuration: yaml: map merge requires map or sequence of maps as the value


这个错误说的是什么映射的问题。我实在不知道我的configtx.yaml到底是哪里写错了,因为我刚开始是手打的,就有很多空格问题啊等等。这个问题在StackOverflow上有解答:
就是本文Error 1里提到的,然而没有用。
最后是直接复制可以用的configtx.yaml,在上面进行修改,切记不要修改空格。就没有这些问题了。

Error 4:Error on outputBlock: could not create bootstrapper: could not create channel group: error adding policies to channel group: no policies defined


这个错误也是因为新版本!在configtx.yaml中要有相对应的policies才行。

我根据fabric-samples里面的配置文件修改了configtx.yaml。
修正后的configtx.yaml:

Organizations:- &OrdererOrgName: OrdererOrgID: OrdererMSPMSPDir: ../fabricconfig/crypto-config/ordererOrganizations/example.com/mspPolicies:Readers:Type: SignatureRule: "OR('OrdererMSP.member')"Writers:Type: SignatureRule: "OR('OrdererMSP.member')"Admins:Type: SignatureRule: "OR('OrdererMSP.admin')"Endorsement:Type: SignatureRule: "OR('OrdererMSP.member')"- &Org1Name: Org1MSPID: Org1MSPMSPDir: ../fabricconfig/crypto-config/peerOrganizations/org1.example.com/mspPolicies:Readers:Type: SignatureRule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"Writers:Type: SignatureRule: "OR('Org1MSP.admin', 'Org1MSP.client')"Admins:Type: SignatureRule: "OR('Org1MSP.admin')"Endorsement:Type: SignatureRule: "OR('Org1MSP.peer')"AnchorPeers:- Host: peer0.org1.example.comPort: 7051- &Org2Name: Org2MSPID: Org2MSPMSPDir: ../fabricconfig/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')"Endorsement:Type: SignatureRule: "OR('Org2MSP.peer')"AnchorPeers:- Host: peer0.org2.example.comPort: 7051
Capabilities:# Channel capabilities apply to both the orderers and the peers and must be# supported by both.# Set the value of the capability to true to require it.Channel: &ChannelCapabilities# V2.0 for Channel is a catchall flag for behavior which has been# determined to be desired for all orderers and peers running at the v2.0.0# level, but which would be incompatible with orderers and peers from# prior releases.# Prior to enabling V2.0 channel capabilities, ensure that all# orderers and peers on a channel are at v2.0.0 or later.V2_0: true# Orderer capabilities apply only to the orderers, and may be safely# used with prior release peers.# Set the value of the capability to true to require it.Orderer: &OrdererCapabilities# V1.1 for Orderer is a catchall flag for behavior which has been# determined to be desired for all orderers running at the v1.1.x# level, but which would be incompatible with orderers from prior releases.# Prior to enabling V2.0 orderer capabilities, ensure that all# orderers on a channel are at v2.0.0 or later.V2_0: true# Application capabilities apply only to the peer network, and may be safely# used with prior release orderers.# Set the value of the capability to true to require it.Application: &ApplicationCapabilities# V2.0 for Application enables the new non-backwards compatible# features and fixes of fabric v2.0.# Prior to enabling V2.0 orderer capabilities, ensure that all# orderers on a channel are at v2.0.0 or later.V2_0: trueApplication: &ApplicationDefaultsOrganizations:# Policies defines the set of policies at this level of the config tree# For Application policies, their canonical path is#   /Channel/Application/<PolicyName>Policies: &ApplicationDefaultPoliciesLifecycleEndorsement:Type: ImplicitMetaRule: "MAJORITY Endorsement"Endorsement:Type: ImplicitMetaRule: "MAJORITY Endorsement"Readers:Type: ImplicitMetaRule: "ANY Readers"Writers:Type: ImplicitMetaRule: "ANY Writers"Admins:Type: ImplicitMetaRule: "MAJORITY Admins"# Capabilities describes the application level capabilities, see the# dedicated Capabilities section elsewhere in this file for a full# descriptionCapabilities:<<: *ApplicationCapabilitiesOrderer: &OrdererDefaultsOrdererType: soloAddresses:- orderer.example.com:7050BatchTimeout: 2sBatchSize:MaxMessageCount: 10AbsoluteMaxBytes: 99 MBPreferredMaxBytes: 512 KBKafka:Brokers:- 127.0.0.1:9092Organizations:# Policies defines the set of policies at this level of the config tree# For Orderer policies, their canonical path is#   /Channel/Orderer/<PolicyName>Policies:Readers:Type: ImplicitMetaRule: "ANY Readers"Writers:Type: ImplicitMetaRule: "ANY Writers"Admins:Type: ImplicitMetaRule: "MAJORITY Admins"# BlockValidation specifies what signatures must be included in the block# from the orderer for the peer to validate it.BlockValidation:Type: ImplicitMetaRule: "ANY Writers"# Capabilities describes the orderer level capabilities, see the# dedicated Capabilities section elsewhere in this file for a full# descriptionCapabilities:<<: *OrdererCapabilities################################################################################
#
#   CHANNEL
#
#   This section defines the values to encode into a config transaction or
#   genesis block for channel related parameters.
#
################################################################################
Channel: &ChannelDefaults# Policies defines the set of policies at this level of the config tree# For Channel policies, their canonical path is#   /Channel/<PolicyName>Policies:# Who may invoke the 'Deliver' APIReaders:Type: ImplicitMetaRule: "ANY Readers"# Who may invoke the 'Broadcast' APIWriters:Type: ImplicitMetaRule: "ANY Writers"# By default, who may modify elements at this config levelAdmins:Type: ImplicitMetaRule: "MAJORITY Admins"# Capabilities describes the channel level capabilities, see the# dedicated Capabilities section elsewhere in this file for a full# descriptionCapabilities:<<: *ChannelCapabilitiesProfiles:TestTwoOrgsOrdererGenesis:<<: *ChannelDefaultsOrderer:<<: *OrdererDefaultsOrganizations:- <<: *OrdererOrgConsortiums:SampleConsortium:Organizations:- <<: *Org1- <<: *Org2TestTwoOrgsChannel:<<: *ChannelDefaultsConsortium: SampleConsortiumApplication:<<: *ApplicationDefaultsOrganizations:- <<: *Org1- <<: *Org2

还有个需要注意的是MSPDir的值是相对路径。
成功生成创世区块:

fabric使用配置文件configtx.yaml生成创世区块时遇到的坑相关推荐

  1. 以太坊创世区块与链配置载入分析

    本文首发于深入浅出区块链社区 原文链接:以太坊创世区块与链配置载入分析,原文已更新,请读者前往原文阅读. 创世区块作为第零个区块,其他区块直接或间接引用到创世区块.因此节点启动之初必须载入正确的创世区 ...

  2. Hyperledger Fabric 通道配置文件和容器环境变量详解

    Python微信订餐小程序课程视频 https://blog.csdn.net/m0_56069948/article/details/122285951 Python实战量化交易理财系统 https ...

  3. 从0到1简易区块链开发手册V0.3-数据持久化与创世区块

    Author: brucefeng Email: brucefeng@brucefeng.com 编程语言:Golang 1.BoltDB简介 Bolt是一个纯粹Key/Value模型的程序.该项目的 ...

  4. Hyperledger Fabric区块链工具configtxgen配置configtx.yaml

    configtx.yaml是Hyperledger Fabric区块链网络运维工具configtxgen用于生成通道创世块或通道交易的配置文件,configtx.yaml的内容直接决定了所生成的创世区 ...

  5. Fabric 1.0源代码分析(8)configtx(配置交易) #genesis(系统通道创世区块)

    # Fabric 1.0源代码笔记 之 configtx(配置交易) #genesis(系统通道创世区块) ## 1.genesis概述 genesis,即创世区块,此处特指系统通道的创世区块. 相关 ...

  6. Hyperledger Fabric 核心模块(2)configtxgen configtx.yaml配置文件

    1. Channel / 通道配置 要写入创世区块或配置交易的通道参数 Channel: &ChannelDefaults# 定义本层级的通道访问策略,其权威路径为 /Channel/< ...

  7. configtx.yaml中文注解

    2019独角兽企业重金招聘Python工程师标准>>> configtx.yaml是Hyperledger Fabric区块链网络运维工具configtxgen用于生成通道创世块或通 ...

  8. Fabric 各种配置文件梳理(二)

    1.docker-compose网络服务配置文件 Fabric使用了容器技术,所以需要一个简化的方式来集中化管理这些容器节点.我们使用docker-compose工具来实现一步到位的节点容器管理,而且 ...

  9. Fabric基础配置文件解析(一)

      今天打算写一个关于fabric初始化中两个重要的配置文件crypto-config.yaml 和 configtx.yaml的内容解析博客,本片就先来学习第一个比较简单的配置文件-crypto-c ...

最新文章

  1. iOS 关于Blocks
  2. leetcode-- 338. Counting Bits
  3. HTML文件上传与下载
  4. 从shiro源码角度学习工厂方法设计模式
  5. Spring官方RSocket Broker 0.3.0发布: 快速构建你的RSocket架构
  6. AbstractQueuedSynchronizer浅析——同步
  7. 2011 MVP大奖礼品包,那是相当的给力啊!!
  8. 用vector实现二维向量
  9. WPF之Manipulation
  10. java 多态性 变量_java – 与实例变量的多态性
  11. SublimeText3快捷键简要总结
  12. 深度学习自学(三十七):基于用户自定义要求3D房间自动设计研究
  13. 如何在Mac设置开机自启程序项
  14. Linux进程的管理与调度(五) -- Linux下0号进程的前世(init_task进程)今生(idle进程)
  15. Cannot find module ‘https-proxy-agent‘
  16. 超详细的免费下载论文方法
  17. 真香啊,手把手教你使用 Python 获取基金信息
  18. schtasks /run 拒绝访问
  19. 【SpringBoot】Bean 注入失败问题汇总
  20. 南怀瑾讲述99个人生道理

热门文章

  1. 剑走偏锋之ICMP隧道
  2. u盘安装linux卡logo,安装Ubuntu16.04卡在logo界面
  3. 导入mysql 1044_MySQL导入sql文件错误#1044
  4. Linux 基础之虚拟机创建与系统安装
  5. 首都师范大学 计算机学院,首都师范大学信息工程学院
  6. OllyDbg下载与安装
  7. python 删除指定后缀文件_python3 遍历删除特定后缀名文件的方法_天津SEO
  8. 与机器人恋爱?人工智能已开始影响人类伦理观
  9. big_screen,一款超强大的Python 可视化大屏!
  10. java 阿里云服务器流下载慢的可能原因