Chainlink
Chainlink 節點未初始化,無法初始化 ORM:initializeORM#NewORM:無法初始化 DB:無法打開 postgresql
我正在嘗試在我的機器上設置一個 chainlink 節點。設置完所有
.env
變數後,我正在執行 docker 命令來啟動節點,cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.10.3 local n
但我收到此錯誤:
pam@g3:~/.chainlink-kovan$ cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.10.3 local n 2021-04-07T09:36:21Z [INFO] Starting Chainlink Node 0.10.3 at commit 5dbbc21f13fa00ee724c439273156834c45ab93e cmd/local_client.go:56 InstanceUUID=f51952e7-d4c9-45f5-b0ae-6e1ed5617bbb SHA=5dbbc21f13fa00ee724c439273156834c45ab93e Version=0.10.3 id=boot 2021-04-07T09:36:21Z [ERROR] failed to initialize database, got error failed to connect to `host=localhost user=postgres database=postgres`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address) orm/orm.go:82 stacktrace=github.com/smartcontractkit/chainlink/core/store/orm.NewORM /chainlink/core/store/orm/orm.go:82 github.com/smartcontractkit/chainlink/core/store.initializeORM /chainlink/core/store/store.go:250 github.com/smartcontractkit/chainlink/core/store.newStoreWithKeyStore /chainlink/core/store/store.go:87 github.com/smartcontractkit/chainlink/core/store.NewStore /chainlink/core/store/store.go:66 github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication /chainlink/core/services/chainlink/application.go:135 github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication /chainlink/core/cmd/client.go:85 github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode /chainlink/core/cmd/local_client.go:58 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:204 creating application: failed to initialize ORM: initializeORM#NewORM: unable to init DB: unable to open postgresql://postgres:12345678@localhost:5432/postgres?application_name=Chainlink+0.10.3+%7C+ORM+%7C+f51952e7-d4c9-45f5-b0ae-6e1ed5617bbb for gorm DB: failed to connect to `host=localhost user=postgres database=postgres`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)
我認為這個錯誤來自
postgres
,所以我嘗試通過 連接postgres
,nodejs
這有效。const { Client } = require("pg"); const client = new Client({ user: "postgres", host: "localhost", database: "postgres", password: "12345678", port: 5432, }); async function main() { await client.connect(); console.log("Connection Successful."); return process.exit(0); } main();
錯誤出現是因為我
postgres
在我的本地機器上執行,我必須--network host
在最後添加。更新命令
docker run --name chainlink-kovan --network host -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.10.3 local n