创建超级账本结构网络(BAD_REQUEST)时出错

时间:2020-03-07 17:30:56

标签: hyperledger-fabric

我正在尝试在本地计算机上运行Hyperledger Fabric网络(在Minikube上使用Kubernetes,在ubuntu 18上运行),但遇到了我无法理解的错误。 也许我创建网络的方式有问题。

我无法在此处添加所有配置,因此我将它们上传到git存储库- https://github.com/nirkov/Hyperledger-Fabric-On-Kubernetes

我要做的第一件事是使用Zookeeper和 fabric-tool pods-

创建Kafka集群。
NAME                      READY   STATUS    RESTARTS   AGE
fabric-tools              1/1     Running   0          48s
kafka-statefulset-0       1/1     Running   2          2m4s
kafka-statefulset-1       1/1     Running   2          2m4s
kafka-statefulset-2       1/1     Running   2          2m4s
kafka-statefulset-3       1/1     Running   2          2m4s
zookeeper-statefulset-0   1/1     Running   0          4m6s
zookeeper-statefulset-1   1/1     Running   0          4m5s
zookeeper-statefulset-2   1/1     Running   0          4m5s

然后我将所需文件复制到共享文件夹并创建网络配置文件-

kubectl exec -it fabric-tools -- /bin/bash
cryptogen generate --config /fabric/config/crypto-config.yaml &&
cp -r crypto-config /fabric/ &&
for file in $(find /fabric/ -iname *_sk); do echo $file; dir=$(dirname $file); mv ${dir}/*_sk ${dir}/key.pem; done &&
cp /fabric/config/configtx.yaml /fabric/ &&
 configtxgen -profile FourOrgsOrdererGenesis -outputBlock 

我知道了-

org1.example.com
org2.example.com
org3.example.com
org4.example.com

制作网络资料-

onfigtxgen -profile FourOrgsOrdererGenesis -outputBlock genesis.block -channelID kafka-orderer-channel &&
> configtxgen -profile FourOrgsChannel -outputCreateChannelTx orderer-system-channel.tx -channelID orderer-system-channel

得到-

2020-03-12 22:25:40.666 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-12 22:25:40.865 IST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: kafka
2020-03-12 22:25:40.866 IST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /fabric/configtx.yaml
2020-03-12 22:25:40.867 IST [common.tools.configtxgen] doOutputBlock -> INFO 004 Generating genesis block
2020-03-12 22:25:40.868 IST [common.tools.configtxgen] doOutputBlock -> INFO 005 Writing genesis block
2020-03-12 22:25:41.064 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-12 22:25:41.176 IST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /fabric/configtx.yaml
2020-03-12 22:25:41.176 IST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-03-12 22:25:41.260 IST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx

创建-outputAnchorPeersUpdate(在订购系统通道上)-

configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org1MSPanchors.tx -channelID orderer-system-channel -asOrg Org1MSP &&
> configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org2MSPanchors.tx -channelID orderer-system-channel -asOrg Org2MSP &&
> configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org3MSPanchors.tx -channelID orderer-system-channel -asOrg Org3MSP &&
> configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org4MSPanchors.tx -channelID orderer-system-channel -asOrg Org4MSP

还有-

2020-03-12 22:25:54.768 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-12 22:25:54.969 IST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /fabric/configtx.yaml
2020-03-12 22:25:54.969 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-03-12 22:25:54.971 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
2020-03-12 22:25:55.172 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-12 22:25:55.459 IST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /fabric/configtx.yaml
2020-03-12 22:25:55.460 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-03-12 22:25:55.462 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
2020-03-12 22:25:55.575 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-12 22:25:55.762 IST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /fabric/configtx.yaml
2020-03-12 22:25:55.762 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-03-12 22:25:55.764 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
2020-03-12 22:25:55.871 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-12 22:25:56.072 IST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /fabric/configtx.yaml
2020-03-12 22:25:56.072 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-03-12 22:25:56.074 IST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update

我创建了证书颁发机构和订购者部署(一个副本应与4个kafka经纪人联系)并检查其日志(这是订购者日志的最后一部分)-

ster.local:9093 (unregistered)
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka.sarama] updateMetadata -> DEBU 03e client/brokers registered new broker #2 at kafka-statefulset-2.kafka-headless.default.svc.cluster.local:9093
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka.sarama] updateMetadata -> DEBU 03f client/brokers registered new broker #1 at kafka-statefulset-1.kafka-headless.default.svc.cluster.local:9093
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka.sarama] updateMetadata -> DEBU 040 client/brokers registered new broker #3 at kafka-statefulset-3.kafka-headless.default.svc.cluster.local:9093
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka.sarama] updateMetadata -> DEBU 041 client/brokers registered new broker #0 at kafka-statefulset-0.kafka-headless.default.svc.cluster.local:9093
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka.sarama] func1 -> DEBU 042 Successfully initialized new client
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka.sarama] func1 -> DEBU 043 Closing Client
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka] startThread -> INFO 044 [channel: kafka-orderer-channel] Start phase completed successfully
2020-03-12 22:27:33.981 IST [orderer.consensus.kafka.sarama] func1 -> DEBU 045 Closed connection to broker kafka-statefulset-0.kafka-headless.default.svc.clus

日志对我来说似乎很好(?)。

在结构目录(所有文件所在的共享内存)中,我可以看到以下文件-

Org1MSPanchors.tx          Org3MSPanchors.tx          config                     crypto-config              ledger
Org2MSPanchors.tx          Org4MSPanchors.tx          configtx.yaml              genesis.block              orderer-system-channel.tx

现在我正在尝试创建网络-

kubectl exec -it fabric-tools -- /bin/bash
cd /fabric 
bash-5.0# export ORDERER_URL="orderer:31010" &&
> export CORE_PEER_ADDRESSAUTODETECT="false" &&
> export CORE_PEER_NETWORKID="nid1" &&
> export CORE_PEER_LOCALMSPID="Org1MSP" &&
> export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/" 
bash-5.0# export FABRIC_CFG_PATH="/etc/hyperledger/fabric"
bash-5.0# peer channel create -o ${ORDERER_URL} -c ${CHANNEL_NAME} -f /fabric/${CHANNEL_NAME}.tx 

并收到此错误-

2020-03-12 22:32:50.178 IST [channelCmd] InitCmdFactory->信息001 认可者和订购者的连接已初始化错误:出现意外 状态:BAD_REQUEST-验证通道创建事务时出错 对于新频道“ orderer-system-channel”,无法成功应用 更新模板配置:错误授权更新:错误 验证DeltaSet:[组] / Channel / Application的策略不正确 满意:隐式策略评估失败-共有0个子策略 满意,但此政策要求“管理员”子政策中的1个 满意

在尝试创建网络后,在订购者日志中也出现错误-

2020-03-12 23:26:53.324 IST [orderer.common.broadcast] ProcessMessage -> WARN 043 [通道:订购者系统通道]由于错误而从172.17.0.11:37160拒绝广播配置消息:错误 验证新频道的频道创建交易 'orderer-system-channel',无法成功将更新应用于 模板配置:授权错误更新:验证错误 DeltaSet:[组] / Channel / Application的策略不满足: 隐式策略评估失败-满足0个子策略,但是 此政策要求满足“管理员”子政策中的1个 2020-03-12 23:26:53.325 IST [comm.grpc.server] 1->信息044流 呼叫完成grpc.service = orderer.AtomicBroadcast grpc.method =广播grpc.peer_address = 172.17.0.11:37160 grpc.code = OK grpc.call_duration = 5.155124ms 2020-03-12 23:26:53.408 IST [common.deliver]句柄->警告045从读取错误 172.17.0.11:37158:rpc错误:代码=已取消desc =上下文已取消2020-03-12 23:26:53.409 IST [comm.grpc.server] 1->信息046流 呼叫完成grpc.service = orderer.AtomicBroadcast grpc.method =传送grpc.peer_address = 172.17.0.11:37158 error =“ rpc 错误:代码=已取消desc =上下文已取消” grpc.code =已取消 grpc.call_duration = 90.669002ms

所有Pod都在运行(由于我的CPU不够,所以org4除外)-

NAME                                                 READY   STATUS    RESTARTS   AGE
certification-authority-deployment-b585c94b7-9w8vw   1/1     Running   0          101s
fabric-tools                                         1/1     Running   0          3m6s
kafka-statefulset-0                                  1/1     Running   2          4m23s
kafka-statefulset-1                                  1/1     Running   2          4m22s
kafka-statefulset-2                                  1/1     Running   1          4m22s
kafka-statefulset-3                                  1/1     Running   2          4m22s
orderer-55488f9578-7bwk9                             1/1     Running   0          70s
org1peer1-598497ff5d-2p7hp                           2/2     Running   0          49s
org1peer2-d666fdff9-8dlrw                            2/2     Running   0          49s
org2peer1-55f9cdb959-6vjbx                           2/2     Running   0          48s
org2peer2-6f9d769d66-vrhws                           2/2     Running   0          47s
org3peer1-fb54cbf56-7h6cr                            2/2     Running   0          45s
org3peer2-64bf845bd5-vvg85                           2/2     Running   0          45s
zookeeper-statefulset-0                              1/1     Running   0          6m23s
zookeeper-statefulset-1                              1/1     Running   0          6m23s
zookeeper-statefulset-2                              1/1     Running   0          6m23s

服务-

NAME                          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                        AGE
certification-authority-svc   ClusterIP   10.104.178.207   <none>        30054/TCP,7054/TCP             72s
kafka-headless                ClusterIP   None             <none>        9093/TCP                       3m55s
kubernetes                    ClusterIP   10.96.0.1        <none>        443/TCP                        7m19s
orderer                       ClusterIP   10.104.179.108   <none>        31010/TCP                      42s
org1peer1-svc                 ClusterIP   10.103.238.74    <none>        30110/TCP,30111/TCP,5984/TCP   12s
org1peer2-svc                 ClusterIP   10.111.161.8     <none>        30110/TCP,30111/TCP,5984/TCP   11s
org2peer1-svc                 ClusterIP   10.96.139.55     <none>        30110/TCP,30111/TCP,5984/TCP   9s
org2peer2-svc                 ClusterIP   10.108.136.52    <none>        30110/TCP,30111/TCP,5984/TCP   6s
org3peer1-svc                 ClusterIP   10.99.208.201    <none>        30110/TCP,30111/TCP,5984/TCP   5s
org3peer2-svc                 ClusterIP   10.104.156.222   <none>        30110/TCP,30111/TCP,5984/TCP   3s
zookeeper-cs                  ClusterIP   10.110.213.102   <none>        2181/TCP                       5m56s
zookeeper-headless            ClusterIP   None             <none>        2888/TCP,3888/TCP              5m56s

我真的很困惑,不知道可能是什么问题,也无法在线找到解决方案。有人可以帮我吗?

一些配置文件-

configtx.yaml-

Organizations:
    - &OrdererOrg
        Name: OrdererOrg
        ID: OrdererMSP
        MSPDir: crypto-config/ordererOrganizations/example.com/msp
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"

    - &Org1
        Name: Org1MSP
        ID: Org1MSP
        MSPDir: crypto-config/peerOrganizations/org1.example.com/msp
        # Using for "gossip" - A fundamental element of the network so that peers
        # can get to know each other and communicate with each other even though they
        # are not linked at the beginning of the configuration. 
        AnchorPeers:
            - Host: org1peer1
              Port: 30110
            - Host: org1peer2
              Port: 30110
        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: crypto-config/peerOrganizations/org2.example.com/msp
        AdminPrincipal: Role.MEMBER
        AnchorPeers:
            - Host: org2peer1
              Port: 30110
            - Host: org2peer2
              Port: 30110
        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')"

    - &Org3
        Name: Org3MSP
        ID: Org3MSP
        MSPDir: crypto-config/peerOrganizations/org3.example.com/msp
        AnchorPeers:
            - Host: org3peer1
              Port: 30110
            - Host: org3peer2
              Port: 30110
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.peer', 'Org3MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org3MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org3MSP.peer')"

    - &Org4
        Name: Org4MSP
        ID: Org4MSP
        MSPDir: crypto-config/peerOrganizations/org4.example.com/msp
        AnchorPeers:
            - Host: org4peer1
              Port: 30110
            - Host: org4peer2
              Port: 30110
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.peer', 'Org4MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org4MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org4MSP.peer')"



Capabilities:
    # Apply for both Orderers and Peers
    Channel: &ChannelCapabilities
        V2_0: true

    # Apply only for Orderers
    Orderer: &OrdererCapabilities
        V2_0: true

    # Apply only for Peers
    Application: &ApplicationCapabilities
        V2_0: true



Orderer: &OrdererDefaults
    OrdererType: kafka
    Addresses:
        - orderer:31010

    # The time to waiting before creating a new batch
    BatchTimeout: 1s
    BatchSize:
        # Maximum message in batch
        MaxMessageCount: 100
        AbsoluteMaxBytes: 90 MB
        PreferredMaxBytes: 512 KB

    # Kafka number of Broker should be minimum set to 4 for achieving crash fault tolerance
    # (the minimum is 3 but 4 is for case that one Broker go down for a while). 
    Kafka:
        Brokers:
            - kafka-statefulset-0.kafka-headless.default.svc.cluster.local:9093
            - kafka-statefulset-1.kafka-headless.default.svc.cluster.local:9093
            - kafka-statefulset-2.kafka-headless.default.svc.cluster.local:9093
            - kafka-statefulset-3.kafka-headless.default.svc.cluster.local:9093

    Organizations:

    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"

     # BlockValidation specifies what signatures must be included in the block
        # from the orderer for the peer to validate it.
        BlockValidation:
            Type: ImplicitMeta
            Rule: "ANY Writers"

    Capabilities:
        <<: *OrdererCapabilities



Channel: &ChannelDefaults
    Policies:
        # Who may invoke the 'Deliver' API
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        # Who may invoke the 'Broadcast' API
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        # By default, who may modify elements at this config level
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"

    Capabilities:
        <<: *ChannelCapabilities



Application: &ApplicationDefaults

    Organizations:

    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        LifecycleEndorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"
        Endorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"



Profiles:
    FourOrgsOrdererGenesis:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        # specify which organizations this orderer is going to serve
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
                    - *Org3
                    - *Org4

    # FourOrgsChannel is the channel the our organizations are going to join                
    FourOrgsChannel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
                - *Org3
                - *Org4
            Capabilities:
                <<: *ApplicationCapabilities 

0 个答案:

没有答案