postgresql PG 8.3,磁盘已满,服务器无法启动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9127467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-20 23:36:00  来源:igfitidea点击:

PG 8.3, Disk Full, server fails to start

postgresqlpostgresql-8.4

提问by Leonard

This question concerns Postgresql 8.3. I cannot yet create tags so Ichose version 8.4 as tag.

这个问题涉及 Postgresql 8.3。我还不能创建标签,所以我选择了 8.4 版作为标签。

It's a test server, but I cannot connect to it because after some days of intensive use the disk where Postgres resides, is full. Becaues I the RDBMS cannot start, I cannot do a vacuum.

这是一个测试服务器,但我无法连接到它,因为经过几天的密集使用后,Postgres 所在的磁盘已满。因为我 RDBMS 不能启动,我不能做真空。

On rebooting, the system says,

重新启动时,系统说,

Starting PostgreSQL 8.3 database server: mainThe PostgreSQL server failed to sta
rt. Please check the log output: FATAL: could not write lock file "postmaster.pi
d": No space left on device failed!
 failed!

Linux works alright and has enough free disk space. Postgresql has its own partion mounted on /var/lib/ and has zero free bytes.

Linux 工作正常并且有足够的可用磁盘空间。Postgresql 有自己的分区挂载在 /var/lib/ 上,并且有零个空闲字节。

I think I should free some space before I can restart the database server, but I don't know which files to delete. The log files are not on the same partition, so it won't help to empty them. Can anybody help me on this?

我想我应该在重新启动数据库服务器之前释放一些空间,但我不知道要删除哪些文件。日志文件不在同一分区上,因此清空它们无济于事。有人可以帮我吗?

回答by Gary

pg_log can be cleared it is for regular logs for admins Don't delete the pg_xlogor pg_clogdirectories as they are for database internals (treat them as you would the data files in base). Removing them can cause problems restarting even if you have the space.

pg_log 可以被清除,它用于管理员的常规日志 不要删除pg_xlogpg_clog目录,因为它们是用于数据库内部的(像对待 base 中的数据文件一样对待它们)。即使您有空间,删除它们也会导致重新启动问题。

The process I'd try (after taking a backup) is:

我尝试的过程(备份后)是:

Find a directory under the /var/lib/pgsqltree that is quite big, but not so big that it can't be copied to another filesystem. It doesn't have to be the whole basedirectory etc, it could be a subdirectory within there.

/var/lib/pgsql树下找到一个相当大的目录,但不要大到无法复制到另一个文件系统。它不必是整个base目录等,它可以是其中的子目录。

Copy the contents of that directory (including any subdirectories) to another file system.

将该目录(包括任何子目录)的内容复制到另一个文件系统。

Remove the old directory and then create a symbolic link where the old directory was to the new location.

删除旧目录,然后在旧目录到新位置的位置创建符号链接。

Startup the database and VACUUM FULL(or now you have access, or you can just drop a db if you've got a database you can live without).

启动数据库和VACUUM FULL(或者现在你可以访问,或者如果你有一个你可以没有的数据库,你可以删除一个数据库)。

Shutdown the database.

关闭数据库。

Remove the symbolic link, and move the files back onto the var/lib filesystem again.

删除符号链接,并再次将文件移回 var/lib 文件系统。

The fact you can't take a filesystem backup would make me a bit loath to do it in your environment though.

但是,您无法进行文件系统备份这一事实会让我有点不愿意在您的环境中进行备份。

回答by Frank Heikens

Drop the logfiles located in /pg_log to clean up something and get started.

删除位于 /pg_log 中的日志文件以清理内容并开始。

VACUUM won't reclaim diskspace, you need VACUUM FULL. You could also drop some indexes or other stuff you don't need now, just to reclaim space.

VACUUM 不会回收磁盘空间,您需要 VACUUM FULL。你也可以删除一些索引或其他你现在不需要的东西,只是为了回收空间。

==edit==

==编辑==

Copy pg_ident.conf to another disk or delete all comments to make just a little bit of space. You could cleanup postgresql.conf as well, after making a copy.

将 pg_ident.conf 复制到另一个磁盘或删除所有注释以腾出一点空间。您也可以在复制后清理 postgresql.conf。

After that, start PostgreSQL in single user mode(using --single) and connect to the database you want to clean up. After cleaning up, stop PostgreSQL and restart in normal mode.

之后,以单用户模式(使用 --single)启动 PostgreSQL并连接到要清理的数据库。清理完毕后,停止PostgreSQL并以正常模式重新启动。

回答by Spiros Souliotis

You have to move the datafiles to another partition and then start the server, then vacuum, and move the files back. Easy.

您必须将数据文件移动到另一个分区,然后启动服务器,然后清空,然后将文件移回。简单。