【问题标题】:Hyperledger Iroha not connecting to postgres database?Hyperledger Iroha 没有连接到 postgres 数据库?
【发布时间】:2019-01-09 21:47:01
【问题描述】:

我正在尝试在 Docker 环境中部署 Hyperledger Iroha 以按照

的 5.3.1 部分中给出的指南运行单个实例
https://iroha.readthedocs.io/en/latest/guides/deployment.html#running-single-instance 

但是,我遇到了错误。

NOTE: IROHA_POSTGRES_HOST should match 'host' option in config file
wait-for-it.sh: waiting 30 seconds for 127.0.0.1:5432
wait-for-it.sh: timeout occurred after waiting 30 seconds for 127.0.0.1:5432
[2019-01-02 11:33:20.406202853][th:80][info] MAIN start
[2019-01-02 11:33:20.406373949][th:80][info] MAIN config initialized
[2019-01-02 11:33:20.407157701][th:80][info] IROHAD created
[2019-01-02 11:33:20.407215609][th:80][info] StorageImpl:initConnection Start st
[2019-01-02 11:33:20.407363960][th:80][info] StorageImpl:initConnection block st
terminate called after throwing an instance of 'soci::soci_error'
  what():  Cannot establish connection to the database.
could not connect to server: Connection refused
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port 5432?

但是我使用 psql 命令测试了 postgres 服务器是否在我的系统中运行。我可以使用 psql 命令从命令提示符连接到 postgres 服务器。

iroha配置文件内容如下。

{ 
  "block_storage_path":"/tmp/block_store",
  "torii_port" : 50051,
  "internal_port" : 10001,
  "pg_opt" : "host=127.0.0.1 port=5432 user=postgres password=abc123",
  "max_proposal_size" : 10,
  "proposal_delay" : 5000,
  "vote_delay" : 5000,
  "mst_enable" : false
}

我用来运行iroha守护进程的命令如下。

iroha$ sudo docker run --name iroha2 -p 50051:50051 -v /home/user/iroha/example:/opt/iroha_data -v blockstore:/tmp/block_store -e IROHA_POSTGRES_HOST='127.0.0.1' -e POSTGRES_PORT='5432' -e POSTGRES_PASSWORD='abc123' -e POSTGRES_USER='postgres' -e KEY=node0 --network=iroha-network hyperledger/iroha:latest

【问题讨论】:

    标签: postgresql database-connection hyperledger-iroha


    【解决方案1】:

    请注意,您正在尝试在 docker 容器中运行 Iroha 节点,因此在 docker 网络中。无法从 docker 容器访问在主机上运行的 Postgres 实例。 我建议你运行两个 docker 容器:Postgres 和 Iroha。他们将在同一个网络中,因此他们会看到对方。

    在您上面提供的链接中,有相关说明。

    docker run --name some-postgres \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -p 5432:5432 \
    --network=iroha-network \
    -d postgres:9.5
    
    并且不要忘记在配置文件中更改 postgres 主机

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-14
      • 2017-11-12
      • 1970-01-01
      • 2019-01-10
      相关资源
      最近更新 更多