/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