我的环境:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
# rpm -q postgresql
postgresql-9.2.18-1.el7.x86_64
#
我使用以下Streaming Replication - PostgreSQL wiki来设置主/从之间的复制,现在过了一段时间我最终得到以下结果:
-bash-4.2$ du -h ~/archive/
19G /var/lib/pgsql/archive/
-bash-4.2$ ls -la ~/archive/ | head
total 19169360
drwxr-xr-x. 2 postgres postgres 61440 Jun 6 12:10 .
drwx------. 11 postgres postgres 4096 Jun 6 11:21 ..
-rw-------. 1 postgres postgres 16777216 Feb 6 10:19 0000000100000008000000AE
-rw-------. 1 postgres postgres 16777216 Feb 14 20:30 0000000100000008000000AF
-rw-------. 1 postgres postgres 16777216 Feb 14 20:30 0000000100000008000000B0
-rw-------. 1 postgres postgres 16777216 Feb 14 20:30 0000000100000008000000B1
-rw-------. 1 postgres postgres 16777216 Feb 14 20:30 0000000100000008000000B2
-rw-------. 1 postgres postgres 16777216 Feb 14 20:30 0000000100000008000000B3
-rw-------. 1 postgres postgres 16777216 Feb 6 10:33 0000000100000008000000B4
-bash-4.2$
我应该设置一个 cron 作业来杀死旧档案吗?或者有这样做的postgres方式?
你可以使用
pg_archivecleanup
。您将在此处找到文档:https ://www.postgresql.org/docs/current/static/pgarchivecleanup.html