Postgresql清理pg_xlog

/etc/init.d/postgresql stop

# 清理前35G
du -sh /var/lib/postgresql/9.6/main/pg_xlog/
35G     /var/lib/postgresql/9.6/main/pg_xlog/

# 查看checkpoint的xid和oid
[postgres@db bin]$ ./pg_controldata /data/pgsql/
...
Latest checkpoint's NextXID:          0:799746
Latest checkpoint's NextOID:          1349035
...
# 指定oid和xid清理xlog
[postgres@db bin]$ ./pg_resetxlog -o 1349035 -x 799746 -f /var/lib/postgresql/9.6/main
Transaction log reset

# 清理后17M
du -sh /var/lib/postgresql/9.6/main/pg_xlog/
17M     /var/lib/postgresql/9.6/main/pg_xlog/

/etc/init.d/postgresql start
posted @ 2020-06-18 10:19  JaminX86  阅读(606)  评论(0编辑  收藏  举报