pg数据库因年龄过大问题处理

1.故障原因前端无数据更新
排查程序日志发现数据库在收缩
报错信息
ERROR: database is not accepting commands to avoid wraparound data loss in database “testdb”
建议:Stop the postmaster and vacuum that database in single-user mode.
You might also need to commit or roll back old prepared transactions, or drop stale replication slots
在这里插入图片描述
执行sql查看时那个表年龄偏大造成数据量收缩
执行Vacuum freeze 模式名.库名

在这里插入图片描述

如果无法释放
停止数据库
su - postgres
/usr/local/postgresql-10.5/bin/pg_ctl stop -D 数据存放目录

/usr/local/postgresql-10.5/bin/postgres --signal -D 数据存放目录 数据库名 进入单用户模式
vacuum freeze 释放整个库
在这里插入图片描述
在单用户模式下执行sql
在这里插入图片描述

vacuum freeze 模式名.表名

猜你喜欢

转载自blog.csdn.net/weixin_46544841/article/details/140327062