【问题标题】:docker chainlink container not connecting to postgres databasedocker chainlink 容器未连接到 postgres 数据库
【发布时间】:2021-10-14 21:03:19
【问题描述】:

我想在本地 ubuntu 机器上运行 chainlink 节点。 我使用以下命令安装 postgresql:

sudo apt install postgresql

调整防火墙设置:

sudo ufw allow from any to any port 5432 proto tcp

访问 postgresql.conf 文件:

sudo gedit /etc/postgresql/12/main/postgresql.conf

修改文件

listen_addresses = ‘*’

sudo gedit /etc/postgresql/14/main/pg_hba.conf

修改文件

host all all 172.17.0.0/16     md5

创建的用户和数据库见下图: [![这张图片显示了我在 postgresql 中的数据库和用户][1]][1]

我的 .env 文件的配置是:

ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=42
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0xa36085F69e2889c224210F603D836748e7dC0088
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
GAS_UPDATER_ENABLED=true
ALLOW_ORIGINS=*
ETH_URL=wss://kovan.infura.io/ws/v3/f0d1d3d2fbb649e29922ec37d4ff0b45
DATABASE_URL=postgresql://chainlink:password#123@127.0.0.1:5432/chainlink?ssl=disable
DATABASE_TIMEOUT=0

我在终端中运行以下命令,镜像版本为 0.10.14。

cd ~/.chainlink-kovan && docker run -p 6688:6688 --name chainlink-node --add- 
host=host:127.0.0.1 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env 
smartcontract/chainlink:0.10.14 local n

它没有连接到 postgresql 数据库。有时它会显示 .env 文件中的 DATABASE_URL 行错误。 当前错误日志是:

    {"level":"warn","ts":1634243680.5286717,"caller":"logger/default.go:134","msg":"GAS_UPDATER_ENABLED has been deprecated, to enable the block history estimator, please use GAS_ESTIMATOR_MODE=BlockHistory instead"}
2021-10-14T20:34:40Z [INFO]  Starting Chainlink Node 0.10.14 at commit 8160d7726d778b5c425e4b56af30b76cbc6d222d cmd/local_client.go:63  InstanceUUID=c6169db0-8d75-4902-becc-643bb0672861 SHA=8160d7726d778b5c425e4b56af30b76cbc6d222d Version=0.10.14 id=boot 
2021-10-14T20:34:40Z [ERROR] invalid database url %spostgresql://chainlink:Kashif#143@127.0.0.1:5939/chainlink?ssl=disable config/config.go:372    stacktrace=github.com/smartcontractkit/chainlink/core/store/config.Config.DatabaseURL
    /chainlink/core/store/config/config.go:372
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
    /chainlink/core/cmd/client.go:86
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
    /chainlink/core/cmd/local_client.go:76
github.com/urfave/cli.HandleAction
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:524
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:173
github.com/urfave/cli.(*App).RunAsSubcommand
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:405
github.com/urfave/cli.Command.startApp
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:372
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:102
github.com/urfave/cli.(*App).Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:277
main.Run
    /chainlink/core/main.go:20
main.main
    /chainlink/core/main.go:14
runtime.main
    /usr/local/go/src/runtime/proc.go:225 
2021-10-14T20:34:40Z [ERROR] invalid database url %spostgresql://chainlink:Kashif#143@127.0.0.1:5939/chainlink?ssl=disable config/config.go:372    stacktrace=github.com/smartcontractkit/chainlink/core/store/config.Config.DatabaseURL
    /chainlink/core/store/config/config.go:372
github.com/smartcontractkit/chainlink/core/store.initializeORM
    /chainlink/core/store/store.go:167
github.com/smartcontractkit/chainlink/core/store.newStore
    /chainlink/core/store/store.go:69
github.com/smartcontractkit/chainlink/core/store.NewStore
    /chainlink/core/store/store.go:47
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
    /chainlink/core/services/chainlink/application.go:152
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
    /chainlink/core/cmd/client.go:87
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
    /chainlink/core/cmd/local_client.go:76
github.com/urfave/cli.HandleAction
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:524
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:173
github.com/urfave/cli.(*App).RunAsSubcommand
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:405
github.com/urfave/cli.Command.startApp
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:372
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:102
github.com/urfave/cli.(*App).Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:277
main.Run
    /chainlink/core/main.go:20
main.main
    /chainlink/core/main.go:14
runtime.main
    /usr/local/go/src/runtime/proc.go:225 
2021-10-14T20:34:40Z [ERROR] failed to initialize database, got error failed to connect to `host=/tmp user=root database=`: dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory) orm/orm.go:87           stacktrace=github.com/smartcontractkit/chainlink/core/store/orm.NewORM
    /chainlink/core/store/orm/orm.go:87
github.com/smartcontractkit/chainlink/core/store.initializeORM
    /chainlink/core/store/store.go:168
github.com/smartcontractkit/chainlink/core/store.newStore
    /chainlink/core/store/store.go:69
github.com/smartcontractkit/chainlink/core/store.NewStore
    /chainlink/core/store/store.go:47
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
    /chainlink/core/services/chainlink/application.go:152
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
    /chainlink/core/cmd/client.go:87
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
    /chainlink/core/cmd/local_client.go:76
github.com/urfave/cli.HandleAction
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:524
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:173
github.com/urfave/cli.(*App).RunAsSubcommand
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:405
github.com/urfave/cli.Command.startApp
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:372
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:102
github.com/urfave/cli.(*App).Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:277
main.Run
    /chainlink/core/main.go:20
main.main
    /chainlink/core/main.go:14
runtime.main
    /usr/local/go/src/runtime/proc.go:225 
creating application: failed to initialize ORM: initializeORM#NewORM: unable to init DB: unable to open ?application_name=Chainlink+0.10.14+%7C+ORM+%7C+c6169db0-8d75-4902-becc-643bb0672861 for gorm DB conn &{0 0xc000b46108 0 {0 0} [] map[] 0 0 0xc00045a5a0 false map[] map[] 0 0 0 0 <nil> 0 0 0 0 0x5970a0}: failed to connect to `host=/tmp user=root database=`: dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory)

两天来,我一直陷入这个问题,无法取得任何进展。 感谢您在期待中付出的时间和努力。不要报告这个问题我已经尝试了所有其他可能的方式,观看并阅读了所有在线帮助。 [1]:https://i.stack.imgur.com/rrT8u.png

【问题讨论】:

    标签: postgresql docker chainlink


    【解决方案1】:

    问题出在 DATABASE_URL 变量中。 我在我的数据库密码中使用了 # 字符。我删除了#,现在问题解决了。

    【讨论】:

      猜你喜欢
      • 2023-04-02
      • 1970-01-01
      • 2022-11-12
      • 1970-01-01
      • 2022-01-07
      • 2021-10-31
      • 1970-01-01
      • 2021-09-11
      • 2020-04-10
      相关资源
      最近更新 更多