8

postgresql.service contents is

# 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

I tried to start PostrgeSQL by service postgresql start and was surprised by postgresql.service contents, because it starts /bin/true

uname -a output:

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

So my questions is: Why it happens, and how to fix it?

yagmoth555
  • 16,758
  • 4
  • 29
  • 50
  • 2
    Check out this thread. https://askubuntu.com/questions/810008/after-upgrade-14-04-to-16-04-1-postgresql-server-does-not-start – termcap Jan 29 '18 at 07:38

2 Answers2

5

As indicated on the thread by @termcap, postgresql@{version}-main.service is the new service name.

So use systemctl {start|enable} postgresql@9.6-main.service.

Sensibly the postgresql.service should contain a friendly migration warning rather than /bin/true (work it out yourself).

danblack
  • 1,249
  • 13
  • 15
  • Note that the `postgresql.service` unit also functions as an enable/disable switch for all clusters. If you disable it then all clusters will be disabled, and if you enable any cluster then it will be enabled. – OrangeDog Jan 16 '19 at 10:30
-1

I confirm the issue, OS - xenial, Postgres version - 10 (latest from official repo). frustrating as hell.

Correct file:

[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