如果数据库服务器上的磁盘空间已满,Postgres 不会启动吗?



我的Postgresql数据库停止工作,这已经关闭了我所有使用它的Django应用程序。我尝试使用"service postgresql restart"重新启动,但它给了我这个响应

* Starting PostgreSQL 9.3 database server                                                                                                                                                                                                     
* The PostgreSQL server failed to start. Please check the log output.

我检查了/var/log/postgresql 上的日志,但最新的日志文件中没有任何内容。我在那之前检查了那个,除了很多说没有磁盘空间的错误之外,我没有特别的想法。

/var/log/postgresql/postgresql-9.3-main.log.1

2018-03-15 08:46:09 CDT LOG:  could not write temporary statistics file "pg_stat_tmp/db_12061.tmp": No space left on device
2018-03-15 08:46:09 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/db_0.tmp": No space left on device
2018-03-15 08:46:09 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/global.tmp": No space left on device
2018-03-15 08:46:10 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/db_0.tmp": No space left on device
2018-03-15 08:46:10 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/global.tmp": No space left on device
2018-03-15 08:46:15 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-15 08:46:15 CDT HINT:  Check free disk space.
2018-03-15 08:46:15 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1606764, 'https://content.homenetiol.com/2001722/2120878/640x480/43d0a25930554cdbbbd0834c9803e5ad.jpg', 1) RET$
2018-03-15 08:46:19 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-15 08:46:20 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-16 08:45:49 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/db_0.tmp": No space left on device
2018-03-16 08:45:49 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/global.tmp": No space left on device
2018-03-16 08:45:53 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-16 08:45:53 CDT HINT:  Check free disk space.
2018-03-16 08:45:53 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1587463, 'https://content.homenetiol.com/2001722/2120878/640x480/c80fb80f8dc04c2581872ad2cf221cbc.jpg', 1) RET$
2018-03-16 08:45:59 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-17 08:45:48 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-17 08:45:48 CDT HINT:  Check free disk space.
2018-03-17 08:45:48 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1144699, 'https://content.homenetiol.com/2001722/2120878/640x480/4e7711dd0d5148eeaadd1e8a7f00b0eb.jpg', 1) RET$
2018-03-18 08:45:44 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/db_0.tmp": No space left on device
2018-03-18 08:45:44 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/global.tmp": No space left on device
2018-03-18 08:45:47 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-18 08:45:47 CDT HINT:  Check free disk space.
2018-03-18 08:45:47 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1144694, 'https://content.homenetiol.com/2001722/2120878/640x480/3dee837dd31942c5a26bc73775f07dba.jpg', 0) RET$
2018-03-18 08:45:54 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-18 10:21:40 CDT FATAL:  password authentication failed for user "socialauto"
2018-03-18 10:21:40 CDT DETAIL:  Connection matched pg_hba.conf line 17: "local   all             all                                     md5"
2018-03-15 08:46:15 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-15 08:46:15 CDT HINT:  Check free disk space.
2018-03-15 08:46:15 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1606764, 'https://content.homenetiol.com/2001722/2120878/640x480/43d0a25930554cdbbbd0834c9803e5ad.jpg', 1) RET$
2018-03-15 08:46:19 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-15 08:46:20 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-16 08:45:49 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/db_0.tmp": No space left on device
2018-03-16 08:45:49 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/global.tmp": No space left on device
2018-03-16 08:45:53 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-16 08:45:53 CDT HINT:  Check free disk space.
2018-03-16 08:45:53 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1587463, 'https://content.homenetiol.com/2001722/2120878/640x480/c80fb80f8dc04c2581872ad2cf221cbc.jpg', 1) RET$
2018-03-16 08:45:59 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-17 08:45:48 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-17 08:45:48 CDT HINT:  Check free disk space.
2018-03-17 08:45:48 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1144699, 'https://content.homenetiol.com/2001722/2120878/640x480/4e7711dd0d5148eeaadd1e8a7f00b0eb.jpg', 1) RET$
2018-03-18 08:45:44 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/db_0.tmp": No space left on device
2018-03-18 08:45:44 CDT LOG:  could not close temporary statistics file "pg_stat_tmp/global.tmp": No space left on device
2018-03-18 08:45:47 CDT ERROR:  could not extend file "base/16385/616778.1": No space left on device
2018-03-18 08:45:47 CDT HINT:  Check free disk space.
2018-03-18 08:45:47 CDT STATEMENT:  INSERT INTO "vehicle_vehicleimage" ("vehicle_id", "image_url", "display_sequence") VALUES (1144694, 'https://content.homenetiol.com/2001722/2120878/640x480/3dee837dd31942c5a26bc73775f07dba.jpg', 0) RET$
2018-03-18 08:45:54 CDT LOG:  using stale statistics instead of current ones because stats collector is not responding
2018-03-18 10:21:40 CDT FATAL:  password authentication failed for user "socialauto"

我使用"df"命令检查了托管数据库的虚拟机上的磁盘空间,看起来确实所有空间都已用完

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/root       49300032 49283648         0 100% /
devtmpfs         2014088        4   2014084   1% /dev
none                   4        0         4   0% /sys/fs/cgroup
none              403388      340    403048   1% /run
none                5120        0      5120   0% /run/lock
none             2016924        0   2016924   0% /run/shm
none              102400        0    102400   0% /run/user

每当我尝试使用选项卡自动完成路径时,我也会收到这条奇怪的消息

-bash: cannot create temp file for here-document: No space left on device

是启动并运行 Postgres 以增加机器上的磁盘空间的唯一方法。有没有办法使用带有一些调试标志的"服务postgresql重启">来查看其面临的错误,而无需进入日志文件?

您可以strace服务器进程...

但说真的——如果你没有空间,那就是原因。如果 PostgreSQL 无法分配新的事务日志,它将拒绝启动。

最简单的方法是启动 postgres 并跟踪日志,就像

tail -f ${PGDATA}/postgresql-$(date --iso-8601)* | grep "ERROR|FATAL" 

或任何您的日志的外观。

当然,如果没有可用空间,您将无法运行数据库。正如你自己提到的,你甚至不能使用bash自动完成。

如果磁盘已满,您期望数据库如何运行?新数据、日志或事务日志存储在哪里?

为什么不从清理磁盘空间开始。找出占用磁盘空间的内容,并删除不必要的内容。卸载不需要的软件包,清理/var/log 中的旧日志文件,或/tmp 或/var/tmp 中的临时文件。

请不要删除PostgreSQL WAL文件!

最新更新