[英]use of archive_command in PostgreSQL streaming replication
When using streaming replication can someone please explain the purpose of archive_command and restore_command in PostgreSQL? 使用流复制时,是否可以有人解释PostgreSQL中archive_command和restore_command的用途?
As i studied in streaming replication secondary server read and apply the partially filled WAL files.suppose i have my wal segment location in pg_xlog and using archive_command i am copying this to my local archive directory say /arclogs. 正如我在流复制辅助服务器中研究的那样,读取并应用部分填充的WAL文件。假设我在pg_xlog中有wal段位置,并使用archive_command将其复制到本地存档目录中,例如/ arclogs。
So if secondary server is going to read the partially filled archive logs from pg_xlog over the network then what's the use of files kept in /arclogs. 因此,如果辅助服务器要通过网络从pg_xlog读取部分填充的存档日志,那么/ arclogs中保存的文件的用途是什么。 and also the files will be sent to /arclogs only when they will be 16 mb?
而且文件只有在16 MB时才会发送到/ arclogs吗?
I'm new to PostgreSQL & your help will be appericated. 我是PostgreSQL的新手,您的帮助将非常热烈。
The master will normally only retain a limited amount of WAL in pg_xlog
, controlled by the master's wal_keep_segments
setting. 主机通常在
pg_xlog
仅保留有限数量的WAL, pg_xlog
由主机的wal_keep_segments
设置控制。 If the replica is too slow or disconnected for too long, the master will delete those transaction logs to ensure it can continue running without running out of disk space. 如果副本太慢或断开连接的时间太长,则主服务器将删除这些事务日志,以确保副本可以继续运行而不会用完磁盘空间。
If that happens the replica has no way to catch up to the master, since it needs a continuous and gap-free stream of WAL. 如果发生这种情况,副本将无法追上原版,因为它需要连续无间隙的WAL流。
So you can: 所以你可以:
archive_command
and archive_mode
) as a fallback, so the replica can switch to replaying WAL from archives if the master deletes WAL it needs from its pg_xlog
. archive_command
和archive_mode
)作为后备,因此,如果主服务器从pg_xlog
删除所需的WAL,则副本可以切换到从归档重放WAL。 The replica fetches the WAL with its restore_command
. restore_command
获取WAL。 Importantly, the archived WAL does not need to be on the same machine as the master, and usually isn't. or 要么
primary_slot_name
in recovery.conf
) to connect the replica to the master. recovery.conf
primary_slot_name
)将副本连接到主数据库。 If a slot is used, the master knows what WAL the replica requires even when the replica is disconnected. pg_xlog
. pg_xlog
删除副本仍然需要的WAL。 But the downside is that pg_xlog
can fill up if a replica is down for too long, causing the master to fail due to lack of disk space. pg_xlog
可能会填满,从而由于磁盘空间不足而导致主服务器失败。 or 要么
The documentation really needs an overview piece to put all this together. 文档确实需要一个概述,以将所有这些内容放在一起。
WAL archiving has an additional benefit: If you make a base backup of the server you can use it, plus WAL archives, to do a point-in-time restore of the master. WAL归档还有另一个好处:如果对服务器进行基本备份 ,则可以使用它以及WAL存档来对主数据库进行时间点还原 。 This lets you recover data from things like accidental table drops.
这使您可以从意外表丢失之类的事件中恢复数据。
PgBarman
is one of the tools that can help you with this. PgBarman
是可以帮助您解决此问题的工具之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.