显示如下: PSQLException: ERROR: could not write block xxxx of temporary file: No space left on device
Caused by: org.postgresql.util.PSQLException: ERROR: could not write block 31840050 of temporary file: No space left on device
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:304)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:189)
..... 问题比较明显,磁盘空间不够了。检查下磁盘空间
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext3 9.9G 9.9G 0G 100% /
/dev/sda1 ext3 99M 17M 78M 18% /boot
none tmpfs 1.0G 0 1.0G 0% /dev/shm
/dev/sda3 ext3 10G 2G 8G 9% /var
..... 检查下数据库日志,里面已经报了很多的ERROR了,无非是磁盘空间不够了。数据库进程还在,但是访问出错。数据库数据文件是挂在根目录下的,目前已经没有空间了。
解决办法:
停掉数据库,将数据文件迁移到其他地方,为了方便,使用软连接,保持原来的数据文件路径
1.停机迁移
[postgres@localhost ~]$ pg_stop
[postgres@localhost ~]$ mv /database/pg_data/ /opt/pg_data
2.做软连接
[postgres@localhost ~]$ ln -s /opt/pg_data /database/pg_data
3.启动
[postgres@localhost ~]$ pg_start
Server start
[postgres@localhost ~]$ 再进去检查,已经正常。 日常的监控和巡检是可以避免这个问题发生的,生产上发生这样的问题就不应该了。
本文详细介绍了PostgreSQL数据库在运行过程中遇到磁盘空间不足问题时,如何通过停机迁移、创建软链接和重新启动数据库来解决问题。同时强调了日常监控和巡检的重要性以避免此类生产问题发生。

5042

被折叠的 条评论
为什么被折叠?



