使用CouchDB Hyperledger Fabric时错误加入对等通道

时间:2019-12-04 19:10:45

标签: couchdb hyperledger-fabric

我正在使用一个具有两个对等点的简单基本网络,并创建一个频道。没问题,但是当我尝试添加沙发数据库功能时,返回错误:

Channel created, joining Org1...
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.22.0.5:7051: connect: connection refused"

仅当启用了ouch db时,才会发生这种情况,如果没有ouchdb,它将创建通道并将其加入两个对等端。

当我启动不带ouchdb的容器时,我正在使用:

docker-compose -f docker-compose-cli.yaml up -d

使用ouchdb

 docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml up -d

docker-compose-couch.yaml包含:

version: '2'

networks:
  byfn:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "5984:5984"
    networks:
      - byfn

  peer0.org1.example.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb0


  couchdb1:
    container_name: couchdb1
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "7984:5984"
    networks:
      - byfn

  peer0.org2.example.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb1

有什么主意吗?使用Couchdb时是否有任何连接错误的原因?

谢谢

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,并修复了该问题,从而在加入频道时增加了一些延迟。

如果在容器启动后立即创建脚本并加入通道,则说明ouchdb容器正在运行,但其中的数据库不在运行。

我的问题已解决,在我的脚本中创建通道之前添加了“ sleep 2”,以确保couchdb数据库已准备好处理请求。

答案 1 :(得分:0)

与对等方连接似乎存在一些问题,因此一旦连接到网络,请删除所有容器和卷。然后再次开始网络设置。

这次尝试分别启动docker容器,即首先使用以下命令启动所有其他容器:

docker-compose -f docker-compose-cli.yaml up -d

然后,启动您的ouchdb容器,因为在couchdb启动并且尝试搜索对等容器的情况下,您的对等容器可能没有启动。因此,在所有其他容器都装满之后,请使用以下命令:

docker-compose -f docker-compose-couch.yaml up -d