手动创建通道失败

来源:6-3 网络搭建完结篇

TeaR_0502

2020-01-11

我在生成的时候都挺顺利的。
docker compose 启动也都正常

peer channel list 响应结果也是预期的(可以连上节点,看到连接的通道是空的)

但是我在创建通道的时候发生了异常

具体指令为
peer channel create -o orderer.t4cloud.com:7050 -c t4channel -f /etc/hyperledger/config/t4cloud.tx

其中的orderer.t4cloud.com,容器启动正常,我之前看过docker启动log,确实是等待服务的日志(视频中说这样就是启动成功了)
通道名称t4channel这个也是正常的,我尝试过使用别的,就会提示通道ID不一致。
最后的交易文件读取正常,如果修改成别的,也会提示文件无法读取

令我困惑的是他的异常提示,是空的,导致百度无法下手,看过好一些,无法解决,只能向老师求助一下。

图片描述

这是我的docker容器运行状态,看起来版本号都是1.0.0应该也没错

图片描述

希望老师能帮忙排查一下问题,谢谢

–以下是补充的order日志

图片描述

我搜索过这个显眼的红色部分的异常(看上去好像是配置错误,但是我确实按照老师的文件配置的)。
有一个问题说是order节点的配置不对,正确的应该是GENESISMETHOD=file,我看了docker-compose中的order配置,也确实是这样的。其他能搜索到的结果都和这个不一样。

然后我注意到了蓝色部分,也去搜索了一下,同样只有疑问没有解决办法。

于是只好又来求助了- -

一下是我使用的configtx配置

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

---
################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles: # 联盟配置

    OneOrgOrdererGenesis: # 系统链 全局组织信息
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org0
                    - *Org1
    TwoOrgChannel: # 业务相关的联盟
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org0
                - *Org1

################################################################################
#
#   Section: Organizations
#
#   - This section defines the different organizational identities which will
#   be referenced later in the configuration.
#
################################################################################
Organizations:

    # SampleOrg defines an MSP using the sampleconfig.  It should never be used
    # in production but may be used as a template for other definitions
    - &OrdererOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: OrdererOrg

        # ID to load the MSP definition as
        ID: OrdererMSP

        # MSPDir is the filesystem path which contains the MSP configuration
        MSPDir: crypto-config/ordererOrganizations/t4cloud.com/msp

    - &Org0
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org0MSP

        # ID to load the MSP definition as
        ID: Org0MSP
#
        MSPDir: crypto-config/peerOrganizations/org0.t4cloud.com/msp

        AnchorPeers:
            # AnchorPeers defines the location of peers which can be used
            # for cross org gossip communication.  Note, this value is only
            # encoded in the genesis block in the Application section context
            - Host: peer0.org0.t4cloud.com
              Port: 7051

    - &Org1
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org1MSP

        # ID to load the MSP definition as
        ID: Org1MSP

        MSPDir: crypto-config/peerOrganizations/org1.t4cloud.com/msp

        AnchorPeers:
            # AnchorPeers defines the location of peers which can be used
            # for cross org gossip communication.  Note, this value is only
            # encoded in the genesis block in the Application section context
            - Host: peer0.org1.t4cloud.com
              Port: 7051

################################################################################
#
#   SECTION: Orderer
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start
    # Available types are "solo" and "kafka"
    OrdererType: solo # 共识机制

    Addresses:
        - orderer.t4cloud.com:7050

    # Batch Timeout: The amount of time to wait before creating a batch
    BatchTimeout: 2s # 出块时间间隔

    # Batch Size: Controls the number of messages batched into a block
    BatchSize:

        # Max Message Count: The maximum number of messages to permit in a batch
        MaxMessageCount: 10

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for
        # the serialized messages in a batch.
        AbsoluteMaxBytes: 99 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed for
        # the serialized messages in a batch. A message larger than the preferred
        # max bytes will result in a batch larger than preferred max bytes.
        PreferredMaxBytes: 512 KB

    Kafka:
        # Brokers: A list of Kafka brokers to which the orderer connects
        # NOTE: Use IP:port notation
        Brokers:
            - 127.0.0.1:9092

    # Organizations is the list of orgs which are defined as participants on
    # the orderer side of the network
    Organizations:

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

以下是我使用的命令

生成证书
./cryptogen generate --config=./crypto-config.yaml

创建创世区块及交易
./configtxgen -profile OneOrgOrdererGenesis -outputBlock ./config/genesis.block -channelID t4channel
./configtxgen -profile TwoOrgChannel -outputCreateChannelTx ./config/t4cloud.tx -channelID t4channel

创建通道
peer channel create -o orderer.t4cloud.com:7050 -c t4channel -f /etc/hyperledger/config/t4cloud.tx

后续异常补充

在我使用小写的不同的名字的时候,出现了go语言的异常,看起来好像是没有响应信息。
(这个我搜了下说是GO语言的环境有问题,可是当前实在官方的docker镜像中……)
网上说可能是容器环境有问题,我

图片描述

详细信息如下

2020-01-11 17:24:33.455 UTC [msp] GetDefaultSigningIdentity -> DEBU 018 Obtaining default signing identity
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7f2b85f38259]

runtime stack:
runtime.throw(0xddc732, 0x2a)
	/opt/go/src/runtime/panic.go:566 +0x95
runtime.sigpanic()
	/opt/go/src/runtime/sigpanic_unix.go:12 +0x2cc

goroutine 7 [syscall, locked to thread]:
runtime.cgocall(0xb1e190, 0xc4200235f8, 0xc400000000)
	/opt/go/src/runtime/cgocall.go:131 +0x110 fp=0xc4200235b0 sp=0xc420023570
net._C2func_getaddrinfo(0x7f2b780008c0, 0x0, 0xc420181410, 0xc42002a258, 0x0, 0x0, 0x0)
	??:0 +0x68 fp=0xc4200235f8 sp=0xc4200235b0
net.cgoLookupIPCNAME(0x7fff5487d7e4, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/opt/go/src/net/cgo_unix.go:146 +0x37c fp=0xc420023718 sp=0xc4200235f8
net.cgoIPLookup(0xc420016720, 0x7fff5487d7e4, 0x13)
	/opt/go/src/net/cgo_unix.go:198 +0x4d fp=0xc4200237a8 sp=0xc420023718
runtime.goexit()
	/opt/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc4200237b0 sp=0xc4200237a8
created by net.cgoLookupIP
	/opt/go/src/net/cgo_unix.go:208 +0xb4

goroutine 1 [runnable]:
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*ClientConn).GetMethodConfig(0xc42039e820, 0xdd0d4c, 0x20, 0x0, 0x0, 0x0, 0x0)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:676 +0x170
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.newClientStream(0x7f2b86affd40, 0xc4200641b8, 0x14043e0, 0xc42039e820, 0xdd0d4c, 0x20, 0x0, 0x0, 0x0, 0x0, ...)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/stream.go:116 +0x109
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.NewClientStream(0x7f2b86affd40, 0xc4200641b8, 0x14043e0, 0xc42039e820, 0xdd0d4c, 0x20, 0x0, 0x0, 0x0, 0x18, ...)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/stream.go:105 +0x162
github.com/hyperledger/fabric/protos/orderer.(*atomicBroadcastClient).Deliver(0xc4200725e8, 0x7f2b86affd40, 0xc4200641b8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xc0)
	/opt/gopath/src/github.com/hyperledger/fabric/protos/orderer/ab.pb.go:499 +0xba
github.com/hyperledger/fabric/peer/channel.InitCmdFactory(0xc420360100, 0x0, 0x0, 0x14106a0)
	/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/channel.go:179 +0x2c0
github.com/hyperledger/fabric/peer/channel.getGenesisBlock(0xc42035abe0, 0x0, 0x0, 0x0)
	/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/deliverclient.go:141 +0x11c
github.com/hyperledger/fabric/peer/channel.executeCreate(0xc42035abe0, 0xc42035abe0, 0x0)
	/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:183 +0x50
github.com/hyperledger/fabric/peer/channel.create(0xc42027a240, 0xc42036c300, 0x0, 0x6, 0xc42035abe0, 0xdb63de, 0x5)
	/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:213 +0x45
github.com/hyperledger/fabric/peer/channel.createCmd.func1(0xc42027a240, 0xc42036c300, 0x0, 0x6, 0x0, 0x0)
	/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:59 +0x52
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).execute(0xc42027a240, 0xc42036c240, 0x6, 0x6, 0xc42027a240, 0xc42036c240)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:599 +0x234
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1407d60, 0xf, 0xc420010035, 0x7)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:689 +0x367
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).Execute(0x1407d60, 0x36, 0xc420010035)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:648 +0x2b
main.main()
	/opt/gopath/src/github.com/hyperledger/fabric/peer/main.go:118 +0x54e

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/opt/go/src/runtime/asm_amd64.s:2086 +0x1

goroutine 22 [syscall]:
os/signal.signal_recv(0xc420022fa8)
	/opt/go/src/runtime/sigqueue.go:116 +0x157
os/signal.loop()
	/opt/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.1
	/opt/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 6 [select]:
net.cgoLookupIP(0x141ef60, 0xc420016660, 0x7fff5487d7e4, 0x13, 0xc42022e480, 0xc420024668, 0x0, 0x0, 0x0, 0x0)
	/opt/go/src/net/cgo_unix.go:209 +0x2f5
net.lookupIP(0x141ef60, 0xc420016660, 0x7fff5487d7e4, 0x13, 0xc42036c960, 0x0, 0x0, 0x0, 0x40005)
	/opt/go/src/net/lookup_unix.go:70 +0xf9
net.glob..func11(0x141ef60, 0xc420016660, 0xe45118, 0x7fff5487d7e4, 0x13, 0xc4200246c8, 0x720699, 0xc420024708, 0xc420024718, 0x455cc0)
	/opt/go/src/net/hook.go:19 +0x52
net.lookupIPContext.func1(0xc42039e820, 0x7fff5487d7e4, 0x18, 0x0)
	/opt/go/src/net/lookup.go:119 +0x5c
internal/singleflight.(*Group).doCall(0x143be60, 0xc42001ba90, 0x7fff5487d7e4, 0x13, 0xc4201813b0)
	/opt/go/src/internal/singleflight/singleflight.go:93 +0x3c
created by internal/singleflight.(*Group).DoChan
	/opt/go/src/internal/singleflight/singleflight.go:86 +0x339

goroutine 41 [select]:
net.lookupIPContext(0x141ef60, 0xc420016660, 0x7fff5487d7e4, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0)
	/opt/go/src/net/lookup.go:122 +0x7bc
net.internetAddrList(0x141ef60, 0xc420016660, 0xdb57a4, 0x3, 0x7fff5487d7e4, 0x18, 0x0, 0x0, 0x0, 0x0, ...)
	/opt/go/src/net/ipsock.go:241 +0x5e0
net.resolveAddrList(0x141ef60, 0xc420016660, 0xdb5da8, 0x4, 0xdb57a4, 0x3, 0x7fff5487d7e4, 0x18, 0x0, 0x0, ...)
	/opt/go/src/net/dial.go:179 +0x106
net.(*Dialer).DialContext(0xc42004b6c8, 0x141ef60, 0xc420016660, 0xdb57a4, 0x3, 0x7fff5487d7e4, 0x18, 0x0, 0x0, 0x0, ...)
	/opt/go/src/net/dial.go:329 +0x238
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.dialContext(0x141ef60, 0xc420016660, 0xdb57a4, 0x3, 0x7fff5487d7e4, 0x18, 0x0, 0x0, 0xc4201462d0, 0xc420156b80)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/go17.go:53 +0xaa
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.DialContext.func1(0x7f2b86affe00, 0xc420016660, 0x7fff5487d7e4, 0x18, 0x1, 0x0, 0x14106a0, 0xc42018c910)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:341 +0x86
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.newProxyDialer.func1(0x7f2b86affe00, 0xc420016660, 0x7fff5487d7e4, 0x18, 0x13, 0x410a5e, 0x0, 0x0)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/proxy.go:136 +0x143
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.dial(0x7f2b86affe00, 0xc420016660, 0xc420371aa0, 0x7fff5487d7e4, 0x18, 0x410a5e, 0xc42013e1e0, 0xa0, 0x98)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:135 +0x5a
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.newHTTP2Client(0x7f2b86affe00, 0xc420016660, 0x7fff5487d7e4, 0x18, 0x0, 0x0, 0xdc17ea, 0x11, 0x0, 0x0, ...)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:173 +0xbf
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.NewClientTransport(0x7f2b86affe00, 0xc420016660, 0x7fff5487d7e4, 0x18, 0x0, 0x0, 0xdc17ea, 0x11, 0x0, 0x0, ...)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/transport.go:463 +0xae
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*addrConn).resetTransport(0xc4200f7a40, 0xc42036da00, 0x70e60c, 0x0)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:876 +0x282
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*ClientConn).resetAddrConn.func1(0xc4200f7a40)
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:648 +0x34
created by github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*ClientConn).resetAddrConn
	/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:657 +0x756

然后看order节点的日志,好像是没问题,都成功了

图片描述

在这种情况下,我尝试过无视异常,然后加入链,会提示tx文件不存在。
如果再次生成链,会生成失败,提示version为1,我搜了下,好像是代表链已存在。

【最终问题解决,成功创建通道】

注意点
1.创世区块和交易链的通道ID不能一样
2.通道名称,不能有大写,(因为我写JAVA习惯了驼峰),但是在此处会有一场,order节点日志:通道ID有非法自读
3.cli客户端的环境变量中缺少 - GODEBUG=netdns=go 导致响应异常。

谢谢老师大半夜的帮我找错误。

写回答

1回答

自游蜗牛

2020-01-11

这个时候可以看orderer的日志,应该会有错误的提示

0
10
TeaR_0502
非常感谢!
2020-01-12
共10条回复

Hyperledger Fabric实战联盟链-企业端区块链原理精讲

兼顾区块链应用层和底层 进击区块链工程师

787 学习 · 564 问题

查看课程