我正在使用一个简单的基本网络,有两个对等点,并创建一个通道。它工作正常,但当我尝试添加couch db功能时,返回错误:
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"
这仅在启用couch db时发生,如果不启用couch db,它将创建通道并将其加入两个对等体。
当我在没有couchdb的情况下启动容器时,我使用:
docker-compose -f docker-compose-cli.yaml up -d
而使用couchdb
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条答案
按热度按时间ehxuflar1#
我也有同样的问题,我修复了它,在加入频道时增加了一点延迟。
如果脚本在容器启动后立即创建并加入通道,则表示couchdb容器正在运行,但其中的数据库没有运行。
在脚本中创建通道之前添加一个“sleep 2”,以确保couchdb数据库已准备好为请求提供服务,从而解决了我的问题。
2w2cym1i2#
似乎在与对等体连接时出现了一些问题,因此一旦网络断开,请删除所有容器和卷。然后重新开始网络设置。
并尝试在这一次单独地提升码头集装箱,即首先使用以下工具提升所有其他集装箱:
然后,启动你的couchdb容器,因为当couchdb启动并试图搜索对等容器时,你的对等容器可能没有启动。因此,在所有其他容器都启动后,使用以下命令: