Postgresql9.6 not starting automaticaly after reboot

Hi.
I have fresh hyper-v (from vhdx img) install. AD integration + some minimal tunning, like redirect nextloud as default page and url cname alias for nextcloud + LE certs for both. All working.

But from begin, after VM reboot, postgresql9.6 does not start automaticaly. If i run it later manually (by uninvention portal) everyting works. Saddly, service show same status, while pg working, or not, only in portal is shown correctly (stoped, autostart):

Dead status:

root@ucs:~# service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Thu 2020-09-24 10:52:10 CEST; 3min 1s ago
Process: 776 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 776 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 19660)
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service

Sep 24 10:52:10 ucs systemd[1]: Starting PostgreSQL RDBMS…
Sep 24 10:52:10 ucs systemd[1]: Started PostgreSQL RDBMS.

Living status:

root@ucs:~# service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Thu 2020-09-24 10:52:10 CEST; 3min 48s ago
Process: 776 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 776 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 19660)
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service

Sep 24 10:52:10 ucs systemd[1]: Starting PostgreSQL RDBMS…
Sep 24 10:52:10 ucs systemd[1]: Started PostgreSQL RDBMS.

May I hope in any sugesstion?

Hello
i have also this problem but in my case also other apache2, networking, postfix and so one) service did not start

systemctl --state=failed

if you do a
systemctl start postgresql.service
or
systemctl start postgresql@9.6-main.service

will it work as expected?

have a nice day
vinc

Thx for help vinc, some progress, non existent user as cluster owner + maybe same error for second service. Now find way to fix and done. If I find, I will post.

root@ucs:~# systemctl status postgresql@9.6-main.service
● postgresql@9.6-main.service - PostgreSQL Cluster 9.6-main
Loaded: loaded (/lib/systemd/system/postgresql@.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-09-25 08:38:59 CEST; 1min 40s ago
Process: 590 ExecStart=postgresql@9.6-main --skip-systemctl-redirect 9.6-main start (code=exited, status=1/FAILURE)

Sep 25 08:38:57 ucs systemd[1]: Starting PostgreSQL Cluster 9.6-main…
Sep 25 08:38:59 ucs postgresql@9.6-main[590]: Error: The cluster is owned by user id 2074 which does not exist
Sep 25 08:38:59 ucs systemd[1]: postgresql@9.6-main.service: Control process exited, code=exited status=1
Sep 25 08:38:59 ucs systemd[1]: Failed to start PostgreSQL Cluster 9.6-main.
Sep 25 08:38:59 ucs systemd[1]: postgresql@9.6-main.service: Unit entered failed state.
Sep 25 08:38:59 ucs systemd[1]: postgresql@9.6-main.service: Failed with result ‘exit-code’.

root@ucs:~# systemctl status systemd-tmpfiles-setup.service
● systemd-tmpfiles-setup.service - Create Volatile Files and Directories
Loaded: loaded (/lib/systemd/system/systemd-tmpfiles-setup.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-09-25 08:38:57 CEST; 6min ago
Docs: man:tmpfiles.d(5)
man:systemd-tmpfiles(8)
Process: 472 ExecStart=/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev (code=exited, status=1/FAILURE)
Main PID: 472 (code=exited, status=1/FAILURE)
CPU: 26ms

Sep 25 08:38:56 ucs systemd-tmpfiles[472]: nss_ldap: reconnecting to LDAP server…
Sep 25 08:38:56 ucs systemd-tmpfiles[472]: nss-ldap: do_open: do_start_tls failed:stat=-1
Sep 25 08:38:56 ucs systemd-tmpfiles[472]: nss_ldap: reconnecting to LDAP server (sleeping 1 seconds)…
Sep 25 08:38:57 ucs systemd-tmpfiles[472]: nss-ldap: do_open: do_start_tls failed:stat=-1
Sep 25 08:38:57 ucs systemd-tmpfiles[472]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 25 08:38:57 ucs systemd-tmpfiles[472]: [/usr/lib/tmpfiles.d/postgresql.conf:2] Unknown user ‘postgres’.
Sep 25 08:38:57 ucs systemd[1]: systemd-tmpfiles-setup.service: Main process exited, code=exited, status=1/FAILURE
Sep 25 08:38:57 ucs systemd[1]: Failed to start Create Volatile Files and Directories.
Sep 25 08:38:57 ucs systemd[1]: systemd-tmpfiles-setup.service: Unit entered failed state.
Sep 25 08:38:57 ucs systemd[1]: systemd-tmpfiles-setup.service: Failed with result ‘exit-code’.

SOLVED? Maybe. All works now after VM reboot.
Really nice error. In /etc/passwd no sign of postgres user, but useradd fail - user already exist. Delete attempt fail - cant remove from passwd.
So manual adding to /etc/passwd seems to solve problem. Group 129 I already find in groups, so I keep it. for home dir I choose PSQL data dir - and have no idea if is it correct + nologin shell:
postgres:x:2074:129::/var/lib/postgresql/9.6/main:/usr/sbin/nologin
After reboot, all working.
May I please, someone without this error, paste here correct record for postgres user in /etc/passwd?

Hi,

I guess you have created a user named “postgres” in your user database through UMC. If so this is a global domain user and therefore with the installation of PostgreSQL the local user was not created.
Therefore no sign in /etc/passwd of this user.
But if you do now after your edit a getent passwd| grep postg I am pretty sure you will now have two users. Which is even worse…

Fix as follows:

  1. Remove your manually added line in /etc/passwd
  2. Delete your global user in UMC (or use udm)
  3. Re-run the PostgreSQL join-script. I should create the user
  4. If the script does not create the user, uninstall and reinstall the PostgreSQL database

/CV

Hi,
true.

root@ucs:~# getent passwd| grep postg
postgres:x:2074:129::/var/lib/postgresql/9.6/main:/usr/sbin/nologin
postgres:x:2074:5001:postgres service:/home/postgres:/bin/bash
root@ucs:~#

So I “solve it” by set it worst :). My problem was, that in early state service not start. Later, after portal starts, I can run it manually from portal, without problems.
OK, I will try yours sugestion and let you known.
regards
JL

OK, you are right. I leave it be, and if i try to upgrade, all fails, because dual passwd record.
So I remove manually added line, and all upgrades works.
But I can not do yours recomendet steps, because I can not find any doc about it.
Not know whitch global user delete and how, and I can not find ppsql join script to run it :(.
I am too lama user. May I please for more detailed advise?
(after I update all, all works, but error with psql start persist).
Regards
JL

Mastodon