簡體   English   中英

docker chainlink 容器未連接到 postgres 數據庫

[英]docker chainlink container not connecting to postgres database

我想在本地 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

問題出在 DATABASE_URL 變量中。 我在我的數據庫密碼中使用了 # 字符。 我刪除了#,現在問題解決了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM