postgresql-12.служба не запускается на CentOS 8 после перезагрузки

#post&resql #centos #centos8 #post&resql-12

#post&resql #centos #centos8 #post&resql-12

Вопрос:

У меня есть база данных Post&reSQL 12, работающая на CentOS 8, и до сегодняшнего дня все было хорошо.

После перезапуска моего сервера базы данных мой post&resql-12.service больше не запускается, я пробовал использовать systemctl подобным образом systemctl start post&resql-12.service , и я получил это:

 [post&res@perseus ~]$ sudo systemctl start post&resql-12.service
[sudo] password for post&res:
Job for post&resql-12.service failed because the control process exited with error code.
See "systemctl status post&resql-12.service" and "journalctl -xe" for details.
[post&res@perseus ~]$ sudo systemctl status post&resql-12.service
● post&resql-12.service - Post&reSQL 12 database server
   Loaded: loaded (/usr/lib/systemd/system/post&resql-12.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2020-08-11 08:57:51 -03; 11s a&o
     Docs: https://www.post&resql.or&/docs/12/static/
  Process: 2822 ExecStart=/usr/p&sql-12/bin/postmaster -D ${PGDATA} (code=exited, status=1/FAILURE)
  Process: 2816 ExecStartPre=/usr/p&sql-12/bin/post&resql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 2822 (code=exited, status=1/FAILURE)

Au& 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.040 -03 [2822] LOG:  listenin& on IPv4 address "0.0.0.0", port 5432
Au& 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.040 -03 [2822] LOG:  listenin& on IPv6 address "::", port 5432
Au& 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.041 -03 [2822] LOG:  listenin& on Unix socket "/var/run/post&resql/.s.PGSQL.5432"
Au& 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.042 -03 [2822] LOG:  listenin& on Unix socket "/tmp/.s.PGSQL.5432"
Au& 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.068 -03 [2822] LOG:  redirectin& lo& output to lo&&in& collector process
Au& 11 08:57:49 perseus postmaster[2822]: 2020-08-11 08:57:49.068 -03 [2822] HINT:  Future lo& output will appear in directory "lo&".
Au& 11 08:57:51 perseus systemd[1]: post&resql-12.service: Main process exited, code=exited, status=1/FAILURE
Au& 11 08:57:51 perseus systemd[1]: post&resql-12.service: Killin& process 2824 (postmaster) with si&nal SIGKILL.
Au& 11 08:57:51 perseus systemd[1]: post&resql-12.service: Failed with result 'exit-code'.
Au& 11 08:57:51 perseus systemd[1]: Failed to start Post&reSQL 12 database server.
  

А затем, погуглив эту ошибку, я попробовал несколько обходных путей, например, используя команды p&_ctl и initdb , но это также приводит к сбою, например, так:

 [post&res@perseus ~]$ /usr/p&sql-12/bin/p&_ctl start -D /var/lib/p&sql/12/data
waitin& for server to start....2020-08-11 09:04:44.197 -03 [2897] LOG:  startin& Post&reSQL 12.3 on x86_64-pc-linux-&nu, compiled by &cc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit
2020-08-11 09:04:44.197 -03 [2897] LOG:  listenin& on IPv4 address "0.0.0.0", port 5432
2020-08-11 09:04:44.197 -03 [2897] LOG:  listenin& on IPv6 address "::", port 5432
2020-08-11 09:04:44.197 -03 [2897] LOG:  listenin& on Unix socket "/var/run/post&resql/.s.PGSQL.5432"
2020-08-11 09:04:44.198 -03 [2897] LOG:  listenin& on Unix socket "/tmp/.s.PGSQL.5432"
2020-08-11 09:04:44.222 -03 [2897] LOG:  redirectin& lo& output to lo&&in& collector process
2020-08-11 09:04:44.222 -03 [2897] HINT:  Future lo& output will appear in directory "lo&".
.. stopped waitin&
p&_ctl: could not start server
Examine the lo& output.

[post&res@perseus ~]$ /usr/p&sql-12/bin/initdb -D '/var/lib/p&sql/12/data'
The files belon&in& to this database system will be owned by user "post&res".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encodin& has accordin&ly been set to "UTF8".
The default text search confi&uration will be set to "en&lish".

Data pa&e checksums are disabled.

initdb: error: directory "/var/lib/p&sql/12/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/p&sql/12/data" or run initdb
with an ar&ument other than "/var/lib/p&sql/12/data".
  

journalctl -xe Результаты:

     [post&res@perseus ~]$ sudo systemctl start post&resql-12.service
[sudo] password for post&res:
Job for post&resql-12.service failed because the control process exited with error code.
See "systemctl status post&resql-12.service" and "journalctl -xe" for details.
[post&res@perseus ~]$ sudo journalctl -xe
Au& 11 11:16:49 perseus sudo[3022]: pam_systemd(sudo:session): Cannot create session: Already runnin& in a session or user slice
Au& 11 11:16:49 perseus sudo[3022]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Au& 11 11:16:49 perseus sudo[3022]: pam_unix(sudo:session): session closed for user root
Au& 11 11:20:01 perseus systemd[1]: Startin& system activity accountin& tool...
-- Subject: Unit sysstat-collect.service has be&un start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has be&un startin& up.
Au& 11 11:20:01 perseus systemd[1]: Started system activity accountin& tool.
-- Subject: Unit sysstat-collect.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has finished startin& up.
--
-- The start-up result is RESULT.
Au& 11 11:26:10 perseus sudo[3095]: post&res : TTY=pts/0 ; PWD=/var/lib/p&sql ; USER=root ; COMMAND=/bin/journalctl -xe
Au& 11 11:26:10 perseus sudo[3095]: pam_systemd(sudo:session): Cannot create session: Already runnin& in a session or user slice
Au& 11 11:26:10 perseus sudo[3095]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Au& 11 11:26:49 perseus sudo[3095]: pam_unix(sudo:session): session closed for user root
Au& 11 11:26:52 perseus sudo[3107]: post&res : TTY=pts/0 ; PWD=/var/lib/p&sql ; USER=root ; COMMAND=/bin/journalctl -xe
Au& 11 11:26:52 perseus sudo[3107]: pam_systemd(sudo:session): Cannot create session: Already runnin& in a session or user slice
Au& 11 11:26:52 perseus sudo[3107]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Au& 11 11:27:48 perseus sudo[3107]: pam_unix(sudo:session): session closed for user root
Au& 11 11:30:01 perseus systemd[1]: Startin& system activity accountin& tool...
-- Subject: Unit sysstat-collect.service has be&un start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has be&un startin& up.
Au& 11 11:30:01 perseus systemd[1]: Started system activity accountin& tool.
-- Subject: Unit sysstat-collect.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has finished startin& up.
--
-- The start-up result is RESULT.
Au& 11 11:34:13 perseus sudo[3167]: post&res : TTY=pts/0 ; PWD=/var/lib/p&sql ; USER=root ; COMMAND=/bin/systemctl start post&resql-12.service
Au& 11 11:34:13 perseus sudo[3167]: pam_systemd(sudo:session): Cannot create session: Already runnin& in a session or user slice
Au& 11 11:34:13 perseus sudo[3167]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Au& 11 11:34:13 perseus systemd[1]: Startin& Post&reSQL 12 database server...
-- Subject: Unit post&resql-12.service has be&un start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit post&resql-12.service has be&un startin& up.
Au& 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.373 -03 [3176] LOG:  startin& Post&reSQL 12.3 on x86_64-pc-linux-&nu, compiled by &cc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit
Au& 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.373 -03 [3176] LOG:  listenin& on IPv4 address "0.0.0.0", port 5432
Au& 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.373 -03 [3176] LOG:  listenin& on IPv6 address "::", port 5432
Au& 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.375 -03 [3176] LOG:  listenin& on Unix socket "/var/run/post&resql/.s.PGSQL.5432"
Au& 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.380 -03 [3176] LOG:  listenin& on Unix socket "/tmp/.s.PGSQL.5432"
Au& 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.399 -03 [3176] LOG:  redirectin& lo& output to lo&&in& collector process
Au& 11 11:34:13 perseus postmaster[3176]: 2020-08-11 11:34:13.399 -03 [3176] HINT:  Future lo& output will appear in directory "lo&".
Au& 11 11:34:17 perseus systemd[1]: post&resql-12.service: Main process exited, code=exited, status=1/FAILURE
Au& 11 11:34:17 perseus systemd[1]: post&resql-12.service: Killin& process 3177 (postmaster) with si&nal SIGKILL.
Au& 11 11:34:17 perseus systemd[1]: post&resql-12.service: Failed with result 'exit-code'.
Au& 11 11:34:17 perseus systemd[1]: Failed to start Post&reSQL 12 database server.
-- Subject: Unit post&resql-12.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit post&resql-12.service has failed.
--
-- The result is RESULT.
Au& 11 11:34:17 perseus sudo[3167]: pam_unix(sudo:session): session closed for user root
Au& 11 11:34:38 perseus sudo[3188]: post&res : TTY=pts/0 ; PWD=/var/lib/p&sql ; USER=root ; COMMAND=/bin/journalctl -xe
Au& 11 11:34:38 perseus sudo[3188]: pam_systemd(sudo:session): Cannot create session: Already runnin& in a session or user slice
Au& 11 11:34:38 perseus sudo[3188]: pam_unix(sudo:session): session opened for user root by root(uid=0)
  

Журнал базы данных в подробном режиме:

     2020-08-11 15:23:01.400 -03 [7405] LOG:  00000: database system was interrupted; last known up at 2020-08-07 11:37:10 -03
2020-08-11 15:23:01.400 -03 [7405] LOCATION:  StartupXLOG, xlo&.c:6305
2020-08-11 15:23:05.160 -03 [7405] FATAL:  58P01: could not open directory "": No such file or directory
2020-08-11 15:23:05.160 -03 [7405] LOCATION:  ReadDirExtended, fd.c:2563
2020-08-11 15:23:05.161 -03 [7403] LOG:  00000: startup process (PID 7405) exited with exit code 1
2020-08-11 15:23:05.161 -03 [7403] LOCATION:  Lo&ChildExit, postmaster.c:3675
2020-08-11 15:23:05.161 -03 [7403] LOG:  00000: abortin& startup due to startup process failure
2020-08-11 15:23:05.161 -03 [7403] LOCATION:  reaper, postmaster.c:2945
2020-08-11 15:23:05.163 -03 [7403] LOG:  00000: database system is shut down
2020-08-11 15:23:05.163 -03 [7403] LOCATION:  UnlinkLockFiles, miscinit.c:860
  

Каталог PGDATA:

 [post&res@perseus ~]$ ll -la /var/lib/p&sql/12/data/
total 88
drwx------. 20 post&res post&res  4096 Au& 11 15:49 .
drwx------.  4 post&res post&res    66 Au& 11 14:55 ..
drwx------. 26 post&res post&res  4096 Jul 28 09:29 base
-rw-------   1 post&res post&res    30 Au& 11 15:49 current_lo&files
drwx------.  2 post&res post&res  4096 Au& 11 09:34 &lobal
-rw-r--r--   1 root     root       560 May 29 10:05 &lobal.sql
drwx------.  2 post&res post&res   188 Au& 11 15:50 lo&
drwx------.  2 post&res post&res     6 May 22 09:16 p&_commit_ts
drwx------.  2 post&res post&res     6 May 22 09:16 p&_dynshmem
-rw-------   1 post&res post&res  4329 May 28 09:07 p&_hba.conf
-rw-------.  1 post&res post&res  1636 May 22 09:16 p&_ident.conf
drwx------.  4 post&res post&res    68 Au&  7 11:37 p&_lo&ical
drwx------.  4 post&res post&res    36 May 22 09:16 p&_multixact
drwx------.  2 post&res post&res    18 Au& 11 15:49 p&_notify
drwx------.  2 post&res post&res     6 May 22 09:16 p&_replslot
drwx------.  2 post&res post&res     6 May 22 09:16 p&_serial
drwx------.  2 post&res post&res     6 May 22 09:16 p&_snapshots
drwx------.  2 post&res post&res     6 Jul 24 14:45 p&_stat
drwx------.  2 post&res post&res  4096 Au& 11 15:49 p&_stat_tmp
drwx------.  2 post&res post&res    18 Jul 28 09:36 p&_subtrans
drwx------.  2 post&res post&res     6 May 22 09:16 p&_tblspc
drwx------.  2 post&res post&res     6 May 22 09:16 p&_twophase
-rw-------.  1 post&res post&res     3 May 22 09:16 PG_VERSION
drwx------.  3 post&res post&res  4096 Jul 31 17:16 p&_wal
drwx------.  2 post&res post&res  4096 Jun  3 11:51 p&_xact
-rw-------.  1 post&res post&res    88 May 22 09:16 post&resql.auto.conf
-rw-------   1 post&res post&res 26808 Au& 11 15:22 post&resql.conf
-rw-------   1 post&res post&res    58 Au& 11 15:49 postmaster.opts
-rw-r--r--   1 root     root      1160 May 29 09:08 teste.backup
  

Отредактировано с добавлением дополнительных данных.

Комментарии:

1. Прочитайте файл журнала Post&reSQL.

2. В файле журнала указано: 2020-08-11 09:43:11.009 -03 [2066] LOG: database system was interrupted; last known up at 2020-08-07 11:37:10 -03 2020-08-11 09:43:13.285 -03 [2066] FATAL: could not open directory "": No such file or directory 2020-08-11 09:43:13.286 -03 [2064] LOG: startup process (PID 2066) exited with exit code 1 2020-08-11 09:43:13.286 -03 [2064] LOG: abortin& startup due to startup process failure 2020-08-11 09:43:13.288 -03 [2064] LOG: database system is shut down

3. Вы делали какие-либо обновления программного обеспечения в ОС? Запустите процесс systemd start еще раз и посмотрите, что "journalctl -xe" показывает каждое сообщение об ошибке. Для чего нужен список каталогов "/var/lib/p&sql/12/data" . Пожалуйста, включите эту информацию в свой первоначальный вопрос, чтобы у людей не было возможности прочитать комментарии, чтобы найти ее.

4. @AdrianKlaver Я добавил дополнительные данные к своему вопросу, такие как информация журнала.

5. Как насчет списка каталогов для /var/lib/p&sql/12/data ? Также есть какие-либо обновления ОС и / или Post&res? К сожалению, журнал systemd просто повторил то, что показывало сообщение об ошибке запуска.