简体   繁体   English

找不到沃尔玛备份文件

[英]Can't find wal backup files

I have two servers, a master and a replica that work together in asynchronous replication mode; 我有两个服务器,一个主服务器和一个副本服务器,它们以异步复制模式一起工作; slave server seems to be working fine, since any change in the master is mirrored in the slave right away. 从服务器似乎运行良好,因为主服务器中的任何更改都会立即反映在从服务器中。 Moreover, there is also an archive process that copy the wal files from the master to another filesystem to keep them safety. 此外,还有一个存档过程,可将wal文件从主文件复制到另一个文件系统,以确保它们的安全。 My doubt is, what wal files can I delete by means of pg_archivecleanup ? 我的疑问是,我可以通过pg_archivecleanup删除哪些wal文件? I guess that I need look for wal files with .backup extension in the master and then I could delete wal files older than last backup. 我想我需要在主数据库中查找扩展名为.backup wal文件,然后才能删除比上次备份更早的wal文件。

For instance, if I have these files in the master server 例如,如果我在主服务器中有这些文件

000000010000000000000089
000000010000000000000088.00000028.backup
000000010000000000000088
000000010000000000000087
000000010000000000000086
...

I come to the conclusion that is safe deleting 000000010000000000000088 and older files, and keep the newest ones. 我得出的结论是,可以安全删除000000010000000000000088和较旧的文件,并保留最新的文件。

The problem is that I don't find .backup files anywhere: neither in the master, nor in the replica, nor in the archive location. 问题是我在任何地方都找不到.backup文件:既不在主数据库中,也不在副本数据库中,也没有在存档位置。

The *.backup files are created if you perform an online backup with pg_basebackup or similar and you are archiving WAL files using the archive_command . 如果使用pg_basebackup或类似文件执行在线备份, 并且正在使用archive_command归档WAL文件, pg_basebackup创建*.backup文件。

In that case you can use pg_archivecleanup with such a file as argument to automatically remove all WAL archives that are older than that backup. 在那种情况下,您可以将pg_archivecleanup与这样的文件作为参数一起使用,以自动删除所有早于该备份的WAL存档。

Your either use a different backup method ( pg_dump ?), or you are not using archive_command . 您要么使用其他备份方法( pg_dump ?),要么不使用archive_command

With pg_dump you cannot do archive recovery, so you wouldn't need to archive WALs at all. 使用pg_dump不能进行归档恢复,因此根本不需要归档WAL。 If you are using a different archive method like pg_receivewal , you won't get the *.backup files and you have to think of a different method to remove your old WAL archives. 如果您使用的是pg_receivewal类的其他存档方法,则不会获得*.backup文件,您必须考虑其他方法来删除旧的WAL存档。

One simple method to purge your old WAL archives is to simply remove all those that are older than your retention time. 清除旧的WAL存档的一种简单方法是简单地删除所有比保留时间更旧的存档。

The files are still being generated and archived (unless you turned that off) an the master. 仍在生成和存档文件(除非您将其关闭)作为主文件。 They are also passed by streaming to the replica where they are kept in pg_wal, but the replica automatically cleans them up every restartpoint. 它们也通过流传递到副本,并保存在pg_wal中,但是副本会在每个重新启动点自动清除它们。 You can get the replica to keep them permanently by setting archive_mode=always on the replica, but it sounds like you don't want that. 您可以通过在副本上始终设置archive_mode = always来使副本永久保留,但这听起来像您不想要那样。

If the only purpose of the archive (by the master) is to save files for use by the replica in case it falls to far behind for streaming (not for disaster recovery or PITR) than you can use "pg_archivecleanup" to automatically clean them up. 如果存档的唯一目的(由主数据库保存)是为了保存副本以供副本使用,以防副本滞后于流传输(而不是用于灾难恢复或PITR),则可以使用“ pg_archivecleanup”自动清除它们。 This is invoked on the replica (not the master) but it must have write access to the archive directory. 这是在副本数据库(不是主数据库)上调用的,但是必须具有对存档目录的写访问权。 So you can mount it as a network file share, you can wrap pg_archivecleanup in ssh so it gets run on the master rather than the replica. 因此,您可以将其挂载为网络文件共享,可以将pg_archivecleanup封装在ssh中,以便它可以在主服务器而不是副本服务器上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM