Hyperledger Fabric部署:configtxgen配置文件读取报错求助
搭建Hyperledger Fabric时configtxgen报错排查
问题场景
从零搭建Hyperledger Fabric,使用docker.io/hyperledger/fabric-tools:2.5.7镜像,运行命令:
cd /fabric ; configtxgen -profile FourOrgsOrdererGenesis -outputBlock genesis.block -channelID channel00
时触发报错:yaml: line 227: did not find expected key
环境信息
configtxgen版本:
root@fabric-tools:/fabric# configtxgen -version configtxgen: Version: v2.5.7 Commit SHA: 5efcea7 Go version: go1.21.9 OS/Arch: linux/amd64
报错日志
2024-04-29 14:26:31.147 EEST 0001 INFO [common.tools.configtxgen] main -> Loading configuration 2024-04-29 14:26:31.149 EEST 0002 PANI [common.tools.configtxgen.localconfig] Load -> Error reading configuration: yaml: line 227: did not find expected key 2024-04-29 14:26:31.150 EEST 0003 PANI [common.tools.configtxgen] func1 -> Error reading configuration: yaml: line 227: did not find expected key panic: Error reading configuration: yaml: line 227: did not find expected key [recovered] panic: Error reading configuration: yaml: line 227: did not find expected key goroutine 1 [running]: go.uber.org/zap/zapcore.CheckWriteAction.OnWrite(0x0?, 0x46?, {0x0?, 0x0?, 0xc0003b6300?}) /vendor/go.uber.org/zap/zapcore/entry.go:196 +0x54 go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc0003c8a90, {0x0, 0x0, 0x0}) /vendor/go.uber.org/zap/zapcore/entry.go:262 +0x3ec go.uber.org/zap.(*SugaredLogger).log(0xc000045d68, 0x4, {0xc00034a140?, 0x0?}, {0x0?, 0xc00034a0f0?, 0x30?}, {0x0, 0x0, 0x0}) /vendor/go.uber.org/zap/sugar.go:316 +0xec go.uber.org/zap.(*SugaredLogger).Panicf(...) /vendor/go.uber.org/zap/sugar.go:202 github.com/hyperledger/fabric/common/flogging.(*FabricLogger).Panic(0xc000045d70, {0xc00050b958?, 0xd24c4c?, 0x16?}) /common/flogging/zap.go:73 +0x57 main.main.func1() /cmd/configtxgen/main.go:261 +0x1cc panic({0xbe08a0?, 0xc00032d2f0?}) /usr/local/go/src/runtime/panic.go:914 +0x21f go.uber.org/zap/zapcore.CheckWriteAction.OnWrite(0x0?, 0xcdc801?, {0x0?, 0x0?, 0xc0003b7440?}) /vendor/go.uber.org/zap/zapcore/entry.go:196 +0x54 go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc0003c8820, {0x0, 0x0, 0x0}) /vendor/go.uber.org/zap/zapcore/entry.go:262 +0x3ec go.uber.org/zap.(*SugaredLogger).log(0xc000045150, 0x4, {0xd2c91f?, 0x15?}, {0xc00050bd70?, 0xadfa90?, 0xff7744?}, {0x0, 0x0, 0x0}) /vendor/go.uber.org/zap/sugar.go:316 +0xec go.uber.org/zap.(*SugaredLogger).Panicf(...) /vendor/go.uber.org/zap/sugar.go:202 github.com/hyperledger/fabric/common/flogging.(*FabricLogger).Panicf(...) /common/flogging/zap.go:74 github.com/hyperledger/fabric/internal/configtxgen/genesisconfig.Load({0x7ffe2e0e1d8f, 0x16}, {0x0, 0x0, 0xd268df?}) /internal/configtxgen/genesisconfig/config.go:238 +0x1bc main.main() /cmd/configtxgen/main.go:279 +0x84c command terminated with exit code 2
问题根源
查看提供的configtx.yaml文件,第227行对应的FourOrgsChannel配置项存在缩进错误:该选项前有多余空格,导致YAML解析器无法识别合法的键名。
错误片段:
FourOrgsChannel: Consortium: SampleConsortium Application: <<: *ApplicationDefaults Organizations: - *Org00 - *Org01 - *Org02 - *Org03
解决方法
将FourOrgsChannel的缩进调整为与上方FourOrgsOrdererGenesis一致,修正后的片段如下:
FourOrgsChannel: Consortium: SampleConsortium Application: <<: *ApplicationDefaults Organizations: - *Org00 - *Org01 - *Org02 - *Org03
修正后重新运行configtxgen命令即可正常执行。
内容的提问来源于stack exchange,提问作者George Cosmin
相关产品推荐
相关产品推荐

