简体   繁体   English

运行 Chainlink 节点 - 无法连接到数据库

[英]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.

相关问题 Chainlink 节点无法向 Chainlink 外部适配器发出请求(在 localhost 上) - Chainlink node can't make requests to Chainlink external adapter (on localhost) 运行 Chainlink 节点 - 远程 DATABASE_URL 配置 PostgreSQL 问题 - Running a Chainlink Node - Remote DATABASE_URL Config PostgreSQL problem 后端容器无法连接到数据库 - Sequelize、Node、Postgres、Docker - Backend container can't connect to database - Sequelize, Node, Postgres, Docker 无法在 GitHub 操作中将 Node.js 与 Docker MySQL 数据库连接 - Can't connect Node.js with Docker MySQL database in GitHub actions Docker 容器中的 NodeJS MongoDB API 无法连接到在主机上运行的数据库 - NodeJS MongoDB API in Docker Container can't connect to Database running on Host 运行 Chainlink 节点 - 在 MacOS/OSX 中将本地 Docker/DB 连接到 Docker/Node 问题 - Running a Chainlink Node - Connecting local Docker/DB to Docker/Node issue in MacOS/OSX 无法连接到在 docker 中运行的 postgres - Can't connect to postgres running in docker 无法连接到在 docker 上运行的 SQL 服务器 - Can't connect to SQL SERVER running on docker 对于 Windows,无法使用 Docker 连接到正在运行的容器 - Can't connect to running container with Docker for Windows 无法连接到Docker映像中的Node - Can't connect to Node inside Docker image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM