[英]Running a Chainlink Node - Can't connect to database
Using docker-desktop on macOS.在 macOS 上使用 docker-desktop。
I'm trying to run a node following the instructions on this page .我正在尝试按照此页面上的说明运行节点。
The database name is node
, which is the same as the username: node
.数据库名称是
node
,它与用户名相同: node
。 The user has access to the database and can log in using psql
client.用户可以访问数据库并且可以使用
psql
客户端登录。
Connection strings I've tried in the .env file:我在 .env 文件中尝试过的连接字符串:
postgresql://node@localhost/node
postgresql://node:password@localhost/node
postgresql://node:password@localhost:5432/node
postgresql://node:password@127.0.0.1:5432/node
postgresql://node:password@127.0.0.1/node
When I run the start command : cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink local n
, using docker-desktop on macOS, I get the following stack trace:当我运行启动命令时:
cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink local n
,使用docker-desktop 在 macOS 上,我得到以下堆栈跟踪:
2020-09-15T14:24:41Z [INFO] Starting Chainlink Node 0.8.15 at commit a904730bd62c7174b80a2c4ccf885de3e78e3971 cmd/local_client.go:50
2020-09-15T14:24:41Z [INFO] SGX enclave *NOT* loaded cmd/enclave.go:11
2020-09-15T14:24:41Z [INFO] This version of chainlink was not built with support for SGX tasks cmd/enclave.go:12
2020-09-15T14:24:41Z [INFO] Locking postgres for exclusive access with 500ms timeout orm/orm.go:69
2020-09-15T14:24:41Z [ERROR] unable to lock ORM: dial tcp 127.0.0.1:5432: connect: connection refused logger/default.go:139 stacktrace=github.com/smartcontractkit/chainlink/core/logger.Error
/chainlink/core/logger/default.go:117
...
Does anyone know how I can resolve this?有谁知道我该如何解决这个问题?
The problem probably caused by the fact that your chainlink database has been locked with Exclusive Lock
and before stopping node that locks never removed.该问题可能是由于您的 chainlink 数据库已被
Exclusive Lock
并且在停止未删除锁的节点之前引起的。
What you do in this situation (as what works for me) is use PgAdmin Ui or similar way to find all Locks then find the Exclusive Lock that is held on the chainlink database and note down its Process id or ids (if multiple exclusive locks there are on chainlink DB)在这种情况下你所做的(因为对我有用)是使用 PgAdmin Ui 或类似的方式来查找所有锁,然后找到链链接数据库上的排他锁并记下它的进程 ID(如果有多个排他锁)在 chainlink DB 上)
Log in to your pg client and run SELECT pg_terminate_backend(<pid>)
or SELECT pg_cancel_backend(<pid>);
登录到您的 pg 客户端并运行
SELECT pg_terminate_backend(<pid>)
或SELECT pg_cancel_backend(<pid>);
Enter PID of those locks here without quotes and meanwhile keep refreshing on pg admin URL to see if those processes stopped If stopped then rerun your chainlink node.在此处输入这些锁的 PID(不带引号),同时不断刷新 pg admin URL 以查看这些进程是否停止。如果停止,则重新运行您的 chainlink 节点。
The problem is with docker networking.问题出在 docker 网络上。
Add --network host
to the docker run command so that it is:将
--network host
添加到--network host
run 命令,使其为:
cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink --network host local n
This fixes the issue.这解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.