'Why PostgreSQL 12 database server don't active

I want use postgresql but show error so checking status. it's failed.

once I deleted postmaster but same error happen.

This server is worked before [yum install --enablerepo=remi-php72 php-pdo php-pgsql] and some operation but i don't know this is reason or not.

$sudo systemctl start postgresql-12.service

 Job for postgresql-12.service failed because the control process exited with error code. See "systemctl status postgresql-12.service" and "journalctl -xe" for details.
$systemctl status postgresql-12.service

● postgresql-12.service - PostgreSQL 12 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; ver preset: disabled)
   Active: failed (Result: exit-code) since Sun 2020-05-10 05:17:14 UTC; 40s
     Docs: https://www.postgresql.org/docs/12/static/
  Process: 708 ExecStart=/usr/pgsql-12/bin/postmaster -D ${PGDATA} (code=exit status=1/FAILURE)
  Process: 699 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGA} (code=exited, status=0/SUCCESS)
 Main PID: 708 (code=exited, status=1/FAILURE)
-- Unit postgresql-12.service has begun starting up.
May 10 06:30:15 localhost.localdomain postmaster[3481]: 2020-05-10 06:30:15.915 UTC [3481] LOG:  starting PostgreSQL 12.2 on x86_64-pc-linux-gnu, compiled by
May 10 06:30:15 localhost.localdomain postmaster[3481]: 2020-05-10 06:30:15.922 UTC [3481] LOG:  listening on IPv6 address "::1", port 5432
May 10 06:30:15 localhost.localdomain postmaster[3481]: 2020-05-10 06:30:15.922 UTC [3481] LOG:  listening on IPv4 address "127.0.0.1", port 5432
May 10 06:30:15 localhost.localdomain postmaster[3481]: 2020-05-10 06:30:15.925 UTC [3481] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
May 10 06:30:15 localhost.localdomain postmaster[3481]: 2020-05-10 06:30:15.929 UTC [3481] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
May 10 06:30:16 localhost.localdomain postmaster[3481]: 2020-05-10 06:30:16.000 UTC [3481] LOG:  redirecting log output to logging collector process
May 10 06:30:16 localhost.localdomain postmaster[3481]: 2020-05-10 06:30:16.000 UTC [3481] HINT:  Future log output will appear in directory "log".
May 10 06:30:16 localhost.localdomain systemd[1]: postgresql-12.service: main process exited, code=exited, status=1/FAILURE
May 10 06:30:16 localhost.localdomain systemd[1]: Failed to start PostgreSQL 12 database server.
-- Subject: Unit postgresql-12.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql-12.service has failed.
--
-- The result is failed.
May 10 06:30:16 localhost.localdomain systemd[1]: Unit postgresql-12.service entered failed state.
May 10 06:30:16 localhost.localdomain systemd[1]: postgresql-12.service failed.
May 10 06:30:16 localhost.localdomain sudo[3468]: pam_unix(sudo:session): session closed for user root
May 10 06:30:16 localhost.localdomain polkitd[393]: Unregistered Authentication Agent for unix-process:3470:439245 (system bus name :1.64, object path /org/f


when I do this and secure(file) in log directory was updated like this.

but i have no idea what i have to do this detail.

$ systemctl start postgresql-12.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
Job for postgresql-12.service failed because the control process exited with error code. See "systemctl status postgresql-12.service" and "journalctl -xe" for details.
May 10 08:01:06 localhost polkitd[382]: Registered Authentication Agent for unix-process:3289:174171 (system bus name :1.71 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 10 08:01:09 localhost polkitd[382]: Operator of unix-process:3289:174171 successfully authenticated as unix-user:root to gain ONE-SHOT authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.72 [systemctl start postgresql-12.service] (owned by unix-user:vagrant)
May 10 08:01:09 localhost polkitd[382]: Unregistered Authentication Agent for unix-process:3289:174171 (system bus name :1.71, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

postgresql-Sun.log

2020-05-10 05:04:35.435 UTC [3207] LOG:  could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
2020-05-10 05:04:35.435 UTC [3207] FATAL:  Ident authentication failed for user "postgres"
2020-05-10 05:04:35.435 UTC [3207] DETAIL:  Connection matched pg_hba.conf line 82: "host    all             all             127.0.0.1/32       


Solution 1:[1]

I resolved !

I was aninstalled postgresql before post this question but I didn't update /var/lib/pgsql/12 file so I removed that by using

sudo rm -rf /var/lib/pgsql/12

and create by

sudo PGSETUP_INITDB_OPTIONS="-E UTF --locale=C"/usr/pgsql-12/bin/postgresql-12-setup initdb

fine!

Solution 2:[2]

Same error with postgres-14

I solved like this:

  1. sudo rm -rf /var/lib/pgsql/14

  2. sudo /usr/pgsql-14/bin/postgresql-14-setup initdb

  3. sudo systemctl start postgresql-14

  4. sudo systemctl enable postgresql-14 (create symlink)

I hope to help someone,

Bye!!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 trinitrotoluene
Solution 2 Raúl Openred