简体   繁体   English

postgres归档目录中wal文件的使用

[英]Use of wal files in archive directory of postgres

I have a 2 node PostgreSQL 13.4 HA setup.我有一个 2 节点 PostgreSQL 13.4 HA 设置。 I have kept the archive_mode=on .我保留了archive_mode=on With this configuration the wal files are moved from pg_wal dir to archive directory.使用此配置,wal 文件从 pg_wal 目录移动到存档目录。 Also, I am using streaming replication for syncing the master and standby nodes.此外,我正在使用流复制来同步主节点和备用节点。

I want to understand if a wal file is moved from pg_wal directory to the archive directory, without being replicated to the slave server (maybe due to the high creation rate of the wal files by postgres), would postgres be still able to replicate them to standby or I need to tweak my postgresql.conf to accommodate sufficient wal files in the pg_wal before shipping them to the archive directory.我想了解如果 wal 文件从 pg_wal 目录移动到存档目录,而不被复制到从服务器(可能是由于 postgres wal 文件的高创建率),postgres 是否仍然能够将它们复制到备用,或者我需要调整我的 postgresql.conf 以在 pg_wal 中容纳足够的 wal 文件,然后再将它们传送到存档目录。

Once the master has sent the WAL file to the archive and removed it from pg_wal, it will not try to bring it back again so that it can deliver it to the replica.一旦 master 将 WAL 文件发送到存档并将其从 pg_wal 中删除,它就不会尝试再次将其带回来以便可以将其交付给副本。

But what you can do is configure the replica to have a restore_command which goes and fetches the file from the archive itself.但是您可以做的是将副本配置为具有restore_command ,该命令会从存档本身中获取文件。 That way if the replica gets denied by the master (because the file was already removed for example), it can fall back to the archive.这样,如果副本被主服务器拒绝(例如,因为文件已被删除),它可以回退到存档。 Then once it has exhausted the archive, it will switch back to streaming.然后,一旦它用尽了存档,它将切换回流式传输。

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

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