PostgreSQL systemd 服务是 /bin/true

Евг*_*ков 7 postgresql systemd

postgresql.service 内容是

# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded.

[Unit]
Description=PostgreSQL RDBMS
[Service]
Type=oneshot
ExecStart=/bin/true
ExecReload=/bin/true
RemainAfterExit=on

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

我尝试通过以下方式启动 PostrgeSQLservice postgresql start并且对postgresql.service内容感到惊讶 ,因为它开始/bin/true

uname -a 输出:

Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:为什么会发生,以及如何解决?

dan*_*ack 5

正如 @termcap 在线程上所示,postgresql@{version}-main.service是新的服务名称。

所以使用systemctl {start|enable} postgresql@9.6-main.service.

明智地,postgresql.service应该包含友好的迁移警告,而不是/bin/true(自己解决)。


小智 -1

我确认了这个问题,操作系统 - xenial,Postgres 版本 - 10(来自官方仓库的最新版本)。令人沮丧。

正确的文件:

[Unit]
Description=PostgreSQL database server
Documentation=man:postgres(1)

[Service]
Type=notify
User=postgres
ExecStart=/usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)