无法将对等容器连接到CouchDB

时间:2018-12-10 18:33:59

标签: docker docker-compose couchdb hyperledger-fabric

我在将对等容器连接到CouchDB时遇到问题。我想这是一个docker网络问题,但找不到解决方案。

对等日志:

2018-12-10 16:13:26.075 UTC [couchdb] handleRequest -> DEBU 06a HTTP Request: GET / HTTP/1.1 | Host: cdbp0.controltower.com:5984 | User-Agent: Go-http-client/1.1 | Accept: multipart/related | Accept-Encoding: gzip |  |
2018-12-10 16:13:26.076 UTC [couchdb] handleRequest -> WARN 06b Retrying couchdb request in 2m8s. Attempt:11  Error:Get http://cdbp0.controltower.com:5984/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2018-12-10 16:15:34.077 UTC [couchdb] VerifyCouchConfig -> DEBU 06c Exiting VerifyCouchConfig()
panic: Error in instantiating ledger provider: Unable to connect to CouchDB, check the hostname and port: Get http://cdbp0.controltower.com:5984/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

CouchDB日志显示如下错误:

[error] 2018-12-10T16:32:28.948825Z nonode@nohost emulator -------- Error in process <0.325.0> with exit value:
{database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,"src/mem3_shards.erl"},{line,403}]},{mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards.erl"},{line,378}]},{mem3_shards,load_shards_from_disk,2,[{file,"src/mem3_shards.erl"},{line,407}]},{mem3_shards,for_docid,3,[{file,"src/mem3_shards.erl"},{line,91}]},{fabric_doc_open,go,3,[{file,"src/fabric_doc_open.erl"},{line,38}]},{chttpd_auth_cache,ensure_auth_ddoc_exists,2,[{file,"src/chttpd_auth_cache.erl"},{line,187}]},{chttpd_auth_cache,listen_for_changes,1,[{file,"src/chttpd_auth_cache.erl"},{line,134}]}]}

Docker撰写:

  p0.controltower.com:
    extends:
      file: compose-base.yml
      service: peer
    container_name: p0.controltower.com
    dns_search: .
    environment:
      - CORE_PEER_ID=p0.controltower.com
      - CORE_PEER_ADDRESSAUTODETECT=true
      - CORE_PEER_LOCALMSPID=ControlTowerMSP
      - CORE_PEER_ADDRESS=p0.controltower.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=p0.controltower.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=p0.controltower.com:7051
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=frenchspoon_compose_frenchspoon.net
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=cdbp0.controltower.com:5984
      - CORE_PEER_TLS_SERVERHOSTOVERRIDE=p0.controltower.co
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
      - NODECHAINCODE=/etc/hyperledger/chaincode/src/chaincode_example/node/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    #command: peer node start --peer-chaincodedev=true
    ports:
      - 7051:7051
      #- 7052:7052
      - 7053:7053
    volumes:
        - /var/run/:/host/var/run/
        - ./crypto-config/peerOrganizations/controltower.com:/etc/hyperledger/crypto/peer
        - ./config:/etc/hyperledger/configtx
        - ./chaincode:/etc/hyperledger/chaincode
    depends_on:
      - o0.controltower.com
      - cdbp0.controltower.com
    networks:
      - frenchspoon.net

  cdbp0.controltower.com:
    dns_search: .
    extends:
      file: compose-base.yml
      service: couchdb
    container_name: cdbp0.controltower.com
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - 5984:5984
    networks:
      - frenchspoon.net

compose-base.yml:

  couchdb:
    image: hyperledger/fabric-couchdb

  peer:
    image: hyperledger/fabric-peer
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: sh -c 'echo "Sleep 20 sec waiting CouchDB"; sleep 20; peer node start'
    dns_search: .
    environment:
      # - CORE_PEER_ADDRESSAUTODETECT=true
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_LOGGING_LEVEL=DEBUG
      - CORE_NEXT=true
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_REQUESTTIMEOUT=240000
      - CORE_PEER_ENDORSER_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      # - CORE_PEER_GOSSIP_IGNORESECURITY=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/crypto/peer/peers/p0/msp
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/crypto/peer/peers/p0/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/crypto/peer/peers/p0/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/crypto/peer/peers/p0/tls/ca.crt
      - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
      - FABRIC_CFG_PATH=/etc/hyperledger/fabric/
      - BASE_DOCKER_NS=hyperledger
      - DOCKER_NS=hyperledger
      - ARCH=x86_64
      - PROJECT_VERSION=1.1.0
      - BASE_VERSION=0.4.6

如您所见,由于在另一篇文章中已建议使用dns_search,因此我尝试添加它。我还修剪了先前尝试的所有docker卷,更新了CouchDB。我想知道是否应该尝试使用Fabric 1.3,但是我还不熟悉1.2,所以我不希望更改版本。

我还想知道它是否链接到CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE变量,但我真的不知道这个变量是什么。

0 个答案:

没有答案