簡體   English   中英

帶有 Postgres 的無人機 - psql:無法連接到服務器:沒有這樣的文件或目錄

[英]Drone with Postgres - psql: could not connect to server: No such file or directory

我嘗試使用 postgres 插件設置無人機服務器,但我完全無法讓它工作。

我所做的是從文檔中復制默認的無人機設置:

---
  kind: pipeline
  type: docker
  name: default

  steps:
    - name: test
      image: postgres:9-alpine
      commands:
        - sleep 5 #give the service some time to start
        - psql -U postgres -d test

  services:
    - name: database
      image: postgres:9-alpine
      environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: password
        POSTGRES_DB: test

但是在嘗試啟動它時出現以下錯誤

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我的猜測是 postgres 由於某種原因沒有啟動,但很難說。

這是 Postgres 日志:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
sh: locale: not found
performing post-bootstrap initialization ... No usable system locales were found.
Use the option "--debug" to see details.
ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....LOG:  database system was shut down at 2020-05-27 08:49:09 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
 done
server started
CREATE DATABASE


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

LOG:  received fast shutdown request
LOG:  aborting any active transactions
LOG:  autovacuum launcher shutting down
LOG:  shutting down
waiting for server to shut down....LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

LOG:  database system was shut down at 2020-05-27 08:49:11 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

無論是那個還是 Postgres 都可以正常啟動,但是在其他進程有機會進行通信之前,某些東西會殺死它。 不過我不完全確定。

任何幫助,將不勝感激。

Drone 在自己的容器中提供服務,這些服務具有自己的主機名。
在您的情況下,您命名了您的服務database ,因此在與psql連接時,您需要傳遞主機名,以便psql通過 TCP 建立與容器的連接:

psql -U postgres -d test -h database

暫無
暫無

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

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