我正在尝试按照5.3.1节
中给出的指南在Docker环境中部署Hyperledger Iroha以运行单个实例。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
答案 0 :(得分: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主机