Contents
Why are there replication slots in PostgreSQL streaming?
Back in the days when “Replication Slots” were not yet introduced, managing the WAL segments were a challenge. In standard streaming replication, the master has no knowledge of the slave status.
What to do if a PostgreSQL slave is missing?
If the slave comes to a situation where the next WAL segment it needs is missing from both the master and the archive, there will be no way to consistently recover the database. The only reasonable option then is to scrub the server and start again from a fresh pg_basebackup.
When to discard a Wal file in PostgreSQL?
If you don’t have any standbys or other streaming replication clients, then basically the server can discard the WAL file once the archive script is done or responds OK. But you’ll still need some recent WAL files for crash recovery (data from recent WAL files get replayed during crash recovery.
How many PostgreSQL replication segments do I Need?
Remember that segments are generated about every 5 minutes, so if the backup takes an hour, you need at least 12 segments saved. At 2 hours, you need 24, etc. I would set the value to about 12.2 segments/hour of backup.
How to setup streaming replication with replication slots on?
The solution is replication slots, a feature provided by Postgres that ensures the primary server only discards WAL records after they have been received by the standby node. We will be setting up streaming replication with replication slots on two Debian 10 nodes.
Why do we need slots in PostgreSQL 9.4?
Replication requires all WAL files created after backup and up until the current time. Previously, it was necessary to keep a huge archive directory (usually mounted by NFS to all slave servers). The slots feature introduced in 9.4 allows Postgres to track the latest segment downloaded by a slave server.
How to create physical replication with PostgreSQL?
Allow connections from the remote host, and create a replication user and slot on master: To apply system variables changes and hba.conf, restart the Postgres server: Create a table with lots of padding on the master: master$ psql psql (10.6) Type “help” for help.