postgresql 安装后不久停止工作

postgresql 安装后不久停止工作

我有一台 ubuntu 20.04 服务器(根服务器位于 hetzner.com,如果这对任何人有帮助的话),我正在尝试运行一个简单的 postgres。安装(按照本指南https://tecadmin.net/how-to-install-postgresql-in-ubuntu-20-04/)工作正常,postgres日志如下所示:

2021-06-22 08:46:03.902 CEST [2840] LOG: starting PostgreSQL 13.3 (Ubuntu 13.3-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
2021-06-22 08:46:03.902 CEST [2840] LOG: listening on IPv4 address "127.0.0.1", port 5432
2021-06-22 08:46:03.908 CEST [2840] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-06-22 08:46:03.926 CEST [2841] LOG: database system was shut down at 2021-06-22 08:46:02 CEST
2021-06-22 08:46:03.935 CEST [2840] LOG: database system is ready to accept connections
2021-06-22 09:03:26.552 CEST [3080] postgres@odc FATAL: password authentication failed for user "postgres"
2021-06-22 09:03:26.552 CEST [3080] postgres@odc DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 96: "host all all 127.0.0.1/32 md5"
2021-06-22 09:03:26.554 CEST [3081] postgres@odc FATAL: password authentication failed for user "postgres"
2021-06-22 09:03:26.554 CEST [3081] postgres@odc DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 96: "host all all 127.0.0.1/32 md5"
2021-06-22 09:06:58.887 CEST [2840] LOG: received fast shutdown request
2021-06-22 09:06:58.921 CEST [2840] LOG: aborting any active transactions
2021-06-22 09:06:58.923 CEST [2840] LOG: background worker "logical replication launcher" (PID 2847) exited with exit code 1
2021-06-22 09:06:58.923 CEST [2842] LOG: shutting down
2021-06-22 09:06:59.001 CEST [2840] LOG: database system is shut down
2021-06-22 09:06:59.169 CEST [3133] LOG: starting PostgreSQL 13.3 (Ubuntu 13.3-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
2021-06-22 09:06:59.169 CEST [3133] LOG: listening on IPv4 address "127.0.0.1", port 5432
2021-06-22 09:06:59.175 CEST [3133] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-06-22 09:06:59.189 CEST [3139] LOG: database system was shut down at 2021-06-22 09:06:58 CEST
2021-06-22 09:06:59.198 CEST [3133] LOG: database system is ready to accept connections
2021-06-22 09:07:16.130 CEST [3181] postgres@odc FATAL: database "odc" does not exist

请注意,我在 psql 中尝试访问上次日志中不存在的数据库时犯了一个错误。

然而过了一段时间后一切都停止了工作,日志中现在有以下几行(这一行和前一个块之间没有任何内容)

2021-06-22 09:50:50.116 CEST [4144] FATAL: could not open file "global/pg_filenode.map": No such file or directory
2021-06-22 09:51:10.111 CEST [3133] LOG: could not open file "postmaster.pid": No such file or directory
2021-06-22 09:51:10.111 CEST [3133] LOG: performing immediate shutdown because data directory lock file is invalid
2021-06-22 09:51:10.112 CEST [3133] LOG: received immediate shutdown request
2021-06-22 09:51:10.112 CEST [3133] LOG: could not open file "postmaster.pid": No such file or directory
2021-06-22 09:51:10.112 CEST [3144] LOG: could not open temporary statistics file "pg_stat/global.tmp": No such file or directory
2021-06-22 09:51:10.112 CEST [3143] WARNING: terminating connection because of crash of another server process
2021-06-22 09:51:10.112 CEST [3143] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2021-06-22 09:51:10.112 CEST [3143] HINT: In a moment you should be able to reconnect to the database and repeat your command.
2021-06-22 09:51:10.112 CEST [4147] WARNING: terminating connection because of crash of another server process
2021-06-22 09:51:10.112 CEST [4147] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2021-06-22 09:51:10.112 CEST [4147] HINT: In a moment you should be able to reconnect to the database and repeat your command.
2021-06-22 09:51:10.116 CEST [3133] LOG: database system is shut down

该文件夹 /var/lib/postgresql/缺少main子文件夹并ps aux | grep post返回:

postgres 4010 0.0 0.0 200 20 ? Ss 09:50 0:00 iihetsbssbatshhn
postgres 4012 0.0 0.0 0 0 ? Z 09:50 0:00 [hrrscshsbhhitia] <defunct>
postgres 4013 0.0 0.0 0 0 ? Z 09:50 0:00 [hrrscshsbhhitia] <defunct>
postgres 4014 0.0 0.0 0 0 ? Z 09:50 0:00 [hrrscshsbhhitia] <defunct>
postgres 4264 9.5 0.0 0 0 ? Z 10:14 0:58 [hrrscshsbhhitia] <defunct>
postgres 4296 39.9 0.0 264 28 ? S 10:20 1:37 iihetsbssbatshhn
postgres 4297 0.0 0.0 200 28 ? S 10:20 0:00 iihetsbssbatshhn
postgres 4303 0.0 0.0 0 0 ? Z 10:21 0:00 [hrrscshsbhhitia] <defunct>

sudo systemctl status 'postgresql*'返回:

- [email protected] - PostgreSQL Cluster 13-main
Loaded: loaded (/lib/systemd/system/[email protected]; enabled-runtime; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-06-22 09:51:10 CEST; 34min ago
Process: 3121 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 13-main start (code=exited, status=0/SUCCESS)
Process: 4148 ExecStop=/usr/bin/pg_ctlcluster --skip-systemctl-redirect -m fast 13-main stop (code=exited, status=1/FAILURE)
Main PID: 3133 (code=exited, status=0/SUCCESS)
Jun 22 09:06:59 Ubuntu-2004-focal-64-minimal systemd[1]: Starting PostgreSQL Cluster 13-main...
Jun 22 09:07:01 Ubuntu-2004-focal-64-minimal systemd[1]: Started PostgreSQL Cluster 13-main.
Jun 22 09:51:10 Ubuntu-2004-focal-64-minimal postgresql@13-main[4148]: Error: /var/lib/postgresql/13/main is not accessible or does not exist
Jun 22 09:51:10 Ubuntu-2004-focal-64-minimal systemd[1]: [email protected]: Control process exited, code=exited, status=1/FAILURE
Jun 22 09:51:10 Ubuntu-2004-focal-64-minimal systemd[1]: [email protected]: Failed with result 'exit-code'.

- postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2021-06-22 09:07:01 CEST; 1h 18min ago
Process: 3156 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 3156 (code=exited, status=0/SUCCESS)
Jun 22 09:07:01 Ubuntu-2004-focal-64-minimal systemd[1]: Starting PostgreSQL RDBMS...
Jun 22 09:07:01 Ubuntu-2004-focal-64-minimal systemd[1]: Finished PostgreSQL RDBMS.

我尝试过两次清除并重新安装 postgresql。每次我都会得到完全相同的结果。

非常感谢您的帮助。谢谢

- - - 编辑 - -

我现在已经使用了 postgresql-12,似乎已经解决了这个问题。我仍然想知道问题出在哪里

相关内容