Hyperledger Fabric 2.4测试网络启用CouchDB失败求助
Hyperledger Fabric 2.4测试网络启用CouchDB失败排查与解决
问题背景与现象
在Windows系统通过WSL2运行Hyperledger Fabric 2.4测试网络,尝试启用CouchDB以实现基于资产字段的复杂查询,操作步骤如下:
- 进入
test-network/compose/docker/peercfg目录,将stateDatabase值改为Couchdb,并更新CouchDB地址为WSL2主机IP - 执行
./network.sh down和./network.sh up重启网络 - 确保Fabric二进制文件已加入PATH,执行
./network.sh createChannel -c test-channel -s couchdb创建通道
通道创建成功,但组织节点无法加入通道,出现以下错误:
- CLI日志显示TLS握手失败,无法连接到localhost:7051
- Docker节点容器日志显示CouchDB连接超时,无法访问配置的WSL2 IP地址
CLI日志
Status: 201 { "name": "test-channel", "url": "/participation/v1/channels/test-channel", "consensusRelation": "consenter", "status": "active", "height": 1 } Channel 'test-channel' created Joining org1 peer to the channel... Using organization 1 + peer channel join -b ./channel-artifacts/test-channel.block + res=1 + peer channel join -b ./channel-artifacts/test-channel.block + res=1 + peer channel join -b ./channel-artifacts/test-channel.block + res=1 + peer channel join -b ./channel-artifacts/test-channel.block + res=1 2023-06-01 18:01:15.731 BST 0001 ERRO [comm.tls] ClientHandshake -> Client TLS handshake failed after 1.427428ms with error: EOF remoteaddress=127.0.0.1:7051 2023-06-01 18:01:16.734 BST 0002 ERRO [comm.tls] ClientHandshake -> Client TLS handshake failed after 1.777634ms with error: EOF remoteaddress=127.0.0.1:7051 2023-06-01 18:01:18.353 BST 0003 ERRO [comm.tls] ClientHandshake -> Client TLS handshake failed after 1.862285ms with error: EOF remoteaddress=127.0.0.1:7051 Error: error getting endorser client for channel: endorser client failed to connect to localhost:7051: failed to create new connection: context deadline exceeded After 5 attempts, peer0.org1 has failed to join channel 'test-channel'
Docker节点容器日志
docker logs 5d84e7eefad0 2023-06-01 17:00:23.702 UTC 0001 INFO [nodeCmd] serve -> Starting peer: Version: 2.4.9 Commit SHA: 2a13518 Go version: go1.18.10 OS/Arch: linux/amd64 Chaincode: Base Docker Label: org.hyperledger.fabric Docker Namespace: hyperledger 2023-06-01 17:00:23.702 UTC 0002 INFO [peer] getLocalAddress -> Auto-detected peer address: 172.22.0.2:7051 2023-06-01 17:00:23.702 UTC 0003 INFO [peer] getLocalAddress -> Returning peer0.org1.example.com:7051 2023-06-01 17:00:23.706 UTC 0004 INFO [nodeCmd] initGrpcSemaphores -> concurrency limit for endorser service is 2500 2023-06-01 17:00:23.706 UTC 0005 INFO [nodeCmd] initGrpcSemaphores -> concurrency limit for deliver service is 2500 2023-06-01 17:00:23.706 UTC 0006 INFO [nodeCmd] serve -> Starting peer with TLS enabled 2023-06-01 17:00:23.721 UTC 0007 INFO [certmonitor] trackCertExpiration -> The enrollment certificate will expire on 2033-05-29 16:55:00 +0000 UTC 2023-06-01 17:00:23.721 UTC 0008 INFO [certmonitor] trackCertExpiration -> The server TLS certificate will expire on 2033-05-29 16:55:00 +0000 UTC 2023-06-01 17:00:23.721 UTC 0009 INFO [ledgermgmt] NewLedgerMgr -> Initializing LedgerMgr 2023-06-01 17:00:23.746 UTC 000a INFO [leveldbhelper] openDBAndCheckFormat -> DB is empty Setting db format as 2.0 2023-06-01 17:00:23.748 UTC 000b INFO [blkstorage] NewProvider -> Creating new file ledger directory at /var/hyperledger/production/ledgersData/chains/chains 2023-06-01 17:00:23.762 UTC 000c INFO [leveldbhelper] openDBAndCheckFormat -> DB is empty Setting db format as 2.0 2023-06-01 17:00:28.779 UTC 000d WARN [couchdb] handleRequest -> Attempt 1 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 125ms 2023-06-01 17:00:33.906 UTC 000e WARN [couchdb] handleRequest -> Attempt 2 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 250ms 2023-06-01 17:00:39.158 UTC 000f WARN [couchdb] handleRequest -> Attempt 3 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 500ms 2023-06-01 17:00:44.660 UTC 0010 WARN [couchdb] handleRequest -> Attempt 4 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 1s 2023-06-01 17:00:50.662 UTC 0011 WARN [couchdb] handleRequest -> Attempt 5 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 2s 2023-06-01 17:00:57.664 UTC 0012 WARN [couchdb] handleRequest -> Attempt 6 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 4s 2023-06-01 17:01:06.668 UTC 0013 WARN [couchdb] handleRequest -> Attempt 7 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 8s 2023-06-01 17:01:19.670 UTC 0014 WARN [couchdb] handleRequest -> Attempt 8 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 16s 2023-06-01 17:01:40.672 UTC 0015 WARN [couchdb] handleRequest -> Attempt 9 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 32s 2023-06-01 17:02:17.675 UTC 0016 WARN [couchdb] handleRequest -> Attempt 10 of 11 returned error: Get "http://172.18.77.0:5984/": dial tcp 172.18.77.0:5984: i/o timeout. Retrying couchdb request in 1m4s
解决步骤
1. 修复CouchDB地址配置问题
Docker容器默认处于独立的桥接网络中,无法直接访问WSL2主机IP(未配置端口转发或网络共享时)。需将peercfg中的CouchDB地址改为Docker Compose定义的CouchDB服务容器名,比如couchdb0.org1.example.com:5984(对应test-network的默认配置),不要使用WSL2主机IP。
2. 使用官方脚本的内置CouchDB启动方式
无需手动修改peercfg配置,直接通过脚本参数启用CouchDB:
# 彻底清理环境 ./network.sh down docker rm -f $(docker ps -aq) docker volume prune -f # 启动网络并启用CouchDB ./network.sh up -s couchdb # 创建通道 ./network.sh createChannel -c test-channel
脚本会自动配置peer连接到对应的CouchDB容器,无需手动修改地址。
3. 验证CouchDB连通性
启动后,进入peer容器测试CouchDB连接:
docker exec -it peer0.org1.example.com bash curl http://couchdb0.org1.example.com:5984/
若返回CouchDB的状态信息,说明连通正常。
4. 重新加入通道
通道创建后,重新执行节点加入命令:
./network.sh joinChannel -c test-channel
内容的提问来源于stack exchange,提问作者Abhignan Rakshith
相关产品推荐
相关产品推荐

