主要问题:
archive_cleanup_command在postgresql.conf文件中不清除归档的wal文件。我怎样才能让它清除存档的wal文件?
相关信息:
当前设置:
/etc/postgresql/13/main/postgresql.conf文件:
wal_level = replica
wal_compression = on
wal_recycle = on
checkpoint_timeout = 5min
max_wal_size = 1GB
min_wal_size = 80MB
archive_mode = on
archive_command = 'pxz --compress --keep --force -6 --to-stdout --quiet %p > /datadrive/postgresql/13/wal_aerchives/%f.xz'
archive_timeout = 10min
restore_command = 'pxz --decompress --keep --force -6 --to-std-out --quiet /datadrive/postgresql/13/wal_archives/%f.xz > %p'
archive_cleanup_command = 'pg_archivecleanup -d -x .xz /datadrive/postgresql/13/wal_archives %r >> /datadrive/postgresql/13/wal_archives/archive_cleanup_command.log 2>&1'
archive_cleanup_command.log拥有777个权限。
我有一个主数据库使用发布执行逻辑复制,而订阅该发布的从数据库执行逻辑复制。这是奴隶,我打算做归档和恢复点。
,我期待发生什么事?
postgresql.conf文件中的检查点超时设置意味着至少每5分钟就会创建一个重新启动点。archive_timeout设置为10分钟意味着postgresql在每10分钟之后强制一个日志文件段切换。因此,至少每10分钟就会创建一个重新启动点。每当创建重新启动点时,都会运行归档清理命令。当运行此命令时,它将清除所有比重新启动点更早的.xz文件。因此,wal_archives目录不应该有超过20分钟甚至2小时的.xz文件.
到底发生了什么?
/datadrive/postgresql/13/wal_archives
目录堆积如山,有许多从未被清除的.xz文件。cat archive_cleanup_command.log
显示一个空文件。没有什么东西是写给它的。--当我通过bash手动运行
示例:
/datadrive/postgresql/13/wal_archives/archive_cleanup_command.log pg_archivecleanup -d -x .xz /datadrive/postgresql/13/wal_archives 000000010000045E0000E5 >> 2>&1
然后运行cat archive_cleanup_command.log
会给出如下结果:
保留WAL文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000E5“和更高版本的pg_archivecleanup:删除文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000DE.xz”pg_archivecleanup:删除文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000DF.xz“pg_archivecleanup:删除文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000E0.xz”pg_archivecleanup:删除文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000E1.xz“pg_archivecleanup:删除文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000E2.xz“pg_archivecleanup:删除文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000E3.xz”pg_archivecleanup:删除文件"/datadrive/postgresql/13/wal_archives/000000010000045E000000E4.xz"
我试过什么?
进行压缩。
systemctl停止postgresql@13-主sudo systemctl启动postgresql@13-main
。
/var/log/postgresql/postgresql-13-main.log
。不幸的是,在这个日志中没有出现相关的错误.发布于 2020-11-17 06:42:14
Restartpoints、restore_command
和archive_cleanup_command
只适用于流复制(“物理”)复制,或一般情况下的恢复,而不适用于逻辑复制。
逻辑复制待机不在恢复中,而是打开以供读取和写入。在这种状态下,像archive_cleanup_command
这样的恢复设置将被忽略。
您将不得不找到另一种机制来删除旧的WAL档案,最好是与备份解决方案相结合。
https://stackoverflow.com/questions/64851938
复制相似问题