首页 > 解决方案 > Hyperledger Fabric 网络中的 CouchDB 错误 - 数据库不存在

问题描述

我有一个非常简单的 Hyperledger Fabric 测试网络。网络通过 Docker Compose 正常启动,peer 和 orderer 之间的连接很好。每个对等点都有一个单独的容器作为他们的数据库,使用 CouchDB。

系统:Ubuntu 18.04

当对等点尝试与其 CouchDB 容器交互时会出现此问题,然后会出现错误消息并且对等点节点退出。

这是来自 CouchDB 的容器日志:

这是我在 couchdb 容器日志中收到的错误:

[信息] 2019-11-26T10:28:38.398968Z nonode@nohost <0.195.0> -------- Apache CouchDB 已在http://any:5986/上启动

[info] 2019-11-26T10:28:38.399538Z nonode@nohost <0.7.0> -------- 应用程序沙发在节点 nonode@nohost 上启动

[info] 2019-11-26T10:28:38.399838Z nonode@nohost <0.7.0> -------- 应用程序 ets_lru 在节点 nonode@nohost 上启动

[info] 2019-11-26T10:28:38.428548Z nonode@nohost <0.7.0> -------- 应用程序 rexi 在节点 nonode@nohost 上启动

[信息] 2019-11-26T10:28:38.441617Z nonode@nohost <0.201.0> -------- _nodes 的 open_result 错误 {not_found,no_db_file}

[警告] 2019-11-26T10:28:38.441655Z nonode@nohost <0.271.0> -------- 创建缺少的数据库:_nodes

[信息] 2019-11-26T10:28:38.470566Z nonode@nohost <0.201.0> -------- _dbs 的 open_result 错误 {not_found,no_db_file}

[警告] 2019-11-26T10:28:38.470600Z nonode@nohost <0.285.0> -------- 创建缺少的数据库:_dbs

[警告] 2019-11-26T10:28:38.470639Z nonode@nohost <0.284.0> -------- 创建缺少的数据库:_dbs

[info] 2019-11-26T10:28:38.478597Z nonode@nohost <0.7.0> -------- 应用程序 mem3 在节点 nonode@nohost 上启动

[info] 2019-11-26T10:28:38.478957Z nonode@nohost <0.7.0> -------- 应用程序结构在节点 nonode@nohost 上启动

[info] 2019-11-26T10:28:38.529437Z nonode@nohost <0.7.0> -------- 应用程序 chttpd 在节点 nonode@nohost 上启动

[通知] 2019-11-26T10:28:38.553132Z nonode@nohost <0.322.0> -------- chttpd_auth_cache 更改侦听器死亡 database_does_not_exist at mem3_shards:load_shards_from_db/6(line:395) <= mem3_shards:load_shards_from_disk /1(line:370) <= mem3_shards:load_shards_from_disk/2(line:399) <= mem3_shards:for_docid/3(line:86) <= fabric_doc_open:go/3(line:38) <= chttpd_auth_cache:ensure_auth_ddoc_exists/2 (line:187) <= chttpd_auth_cache:listen_for_changes/1(line:134)

[错误] 2019-11-26T10:28:38.555361Z nonode@nohost 模拟器-------- 进程 <0.323.0> 中的错误,退出值:

{database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,"src/mem3_shards.erl"},{line,395}]},{mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards. erl"},{line,370}]},{mem3_shards,load_shards_from_disk,2,[{file,"src/mem3_shards.erl"},{line,399}]},{mem3_shards,for_docid,3,[{file ,"src/mem3_shards.erl"},{line,86}]},{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}] }]}

这是来自尝试到达 CouchDB 的对等容器的错误日志:

2019-11-26 10:29:00.236 UTC [ledgermgmt] CreateLedger -> INFO 021 使用创世块创建分类帐 [allarewelcome]

2019-11-26 10:29:00.238 UTC [fsblkstorage] newBlockfileMgr -> INFO 022 从块存储中获取块信息

恐慌:运行时错误:无效的内存地址或零指针取消引用

恐慌:运行时错误:无效的内存地址或零指针取消引用

[信号SIGSEGV:分段违规代码=0x1 addr=0x28 pc=0xcecbb6]

标签: ubuntucouchdbhyperledger-fabric

解决方案


我检查了容器本身的 compose-yaml 和 env 变量,似乎一切都很好。couchDB 也按预期运行。这是附加信息,因为我非常不确定问题可能是什么。

**core.yml:**

    ledger:

      blockchain:

      state:
         stateDatabase - options are "goleveldb", "CouchDB"
         goleveldb - default state database stored in goleveldb.
         CouchDB - store state database in CouchDB
        stateDatabase: CouchDB
         Limit on the number of records to return per query
        totalQueryLimit: 100000
        couchDBConfig:

           couchDBAddress: 127.0.0.1:5984

           username:

           password:

           maxRetries: 3

           maxRetriesOnStartup: 12

           requestTimeout: 35s

           internalQueryLimit: 1000

           maxBatchUpdateSize: 1000

           warmIndexesAfterNBlocks: 1

           createGlobalChangesDB: false

    **docker-compose.yml:**

    peer0.org1.example.com:
        container_name: peer0.org1.example.com
        image: hyperledger/fabric-peer
        environment:
          - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
          - CORE_PEER_ID=peer0.org1.example.com
          - FABRIC_LOGGING_SPEC=info
          - CORE_CHAINCODE_LOGGING_LEVEL=info
          - CORE_PEER_LOCALMSPID=Org1MSP
          - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
          - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
          - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=startFiles_basic
          - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
          - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdbOrg1Peer0:5984
          - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=peer0.Org1
          - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=password
        working_dir: /opt/gopath/src/github.com/hyperledger/fabric
        command: peer node start
        # command: peer node start --peer-chaincodedev=true
        ports:
          - 7051:7051
          - 7053:7053
        volumes:
          - /var/run/:/host/var/run/
          - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer
          - ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
          - ./config:/etc/hyperledger/configtx
        depends_on:
          - orderer.example.com
          - couchdbOrg1Peer0
        networks:
          - basic

      couchdbOrg1Peer0:
        container_name: couchdbOrg1Peer0
        image: hyperledger/fabric-couchdb
        environment:
          - COUCHDB_USER=​peer0.Org1
          - COUCHDB_PASSWORD=​password
        ports:
          - "5984:5984"
        networks:
          - basic


    **From the CLI logs**

    user:~/Desktop/fabric-samples$ curl http://127.0.0.1:5984/
    {"couchdb":"Welcome","version":"2.2.0","git_sha":"2a16ec4","features":["pluggable-storage-engines","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

    user:docker exec -it peer0.org1.example.com bashroot@ba0c7f2796b6:/opt/gopath/src/github.com/hyperledger/fabric# printenv
    CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdbOrg1Peer0:5984
    CORE_PEER_LOCALMSPID=Org1MSP
    CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
    CORE_CHAINCODE_LOGGING_LEVEL=info
    CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=password
    FABRIC_LOGGING_SPEC=info
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    PWD=/opt/gopath/src/github.com/hyperledger/fabric
    CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
    CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=startFiles_basic
    CORE_PEER_ID=peer0.org1.example.com
    SHLVL=1
    HOME=/root
    FABRIC_CFG_PATH=/etc/hyperledger/fabric
    CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=peer0.Org1
    CORE_PEER_ADDRESS=peer0.org1.example.com:7051
    CORE_LEDGER_STATE_STATEDATABASE=CouchDB
    _=/usr/bin/printenv

推荐阅读