0% found this document useful (0 votes)
37 views

File Based Replication Module2

This document provides an overview of log shipping standby replication in PostgreSQL. It discusses initial setup considerations for the master and slave servers, configuration parameters for enabling log shipping on the master like archive_mode and archive_command, and configuration parameters for the slave like restore_command. It also describes how failover can be performed manually by promoting the slave to become the new master.

Uploaded by

Siri Chandana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

File Based Replication Module2

This document provides an overview of log shipping standby replication in PostgreSQL. It discusses initial setup considerations for the master and slave servers, configuration parameters for enabling log shipping on the master like archive_mode and archive_command, and configuration parameters for the slave like restore_command. It also describes how failover can be performed manually by promoting the slave to become the new master.

Uploaded by

Siri Chandana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Module-2

Log Shipping Standby


Module Objective
 Introduction to Log Shipping
 Initial Setup and Considerations
 Master Configuration Parameters
 Slave Configuration Parameters
 Failover
 Demo
Log Shipping Standby

 WAL files are shipped from the master to the standby servers to keep data
in sync.
 Master can directly copy the logs to standby server storage or can share
storage with the standby servers.
 The primary server operates in continuous archiving mode, while each
standby server operates in continuous recovery mode, reading the WAL
files from the primary.
 File-Based Log Shipping is Asynchronous.
 One WAL log file can contain up to 16MB of data.
 The WAL file is shipped only after it reaches that threshold.
 This will cause a delay in replication and also increase chances of losing
data if the master crashes and logs are not archived
File/Log Shipping Replication

Read-Only

Master Server Slave Server

Unidirectional

Wal Files Archive Recd Logs Restore


Initial Setup and Considerations

 Install PostgreSQL on both the machines preferably same version.


 Minor Version differences are acceptable (ex 12.3 and 12.5).
 Ensure we are able to ping between the servers (Master/Slave).
 Ensure password less file transfer is happening between servers.
 Create a directory to copy archive files in slave servers.
 Ensure postgres user has read/write permission on the directory.
 Ensure contrib module is installed on both the machines.
Master Side Configuration

 Enable Archive Mode on the master server.


Parameter : archive_mode = ON
 Set Archive Command parameter to copy the wal files on the
destination server
Parameter :Archive_command
Example : rsync -a %p postgres@standbyserver:/location (linux)
copy “%p” “\\\\192.168.1.1\\archive\\%f”
 Set archive_timeout to force the server to switch to a new WAL
segment file periodically.
Parameter :archive_timeout = 60
Slave Side Configuration

 Set restore_command parameter to retrieve an archived


segment of the WAL file series.
Ex: restore_command = ‘copy “C:\\archiveDir\\%f” “%p”'
 Set archive_cleanup_command to  cleaning up old archived
WAL files that are no longer needed by the standby server.
Ex: archive_cleanup_command = 'pg_archivecleanup
/mnt/server/archivedir %r‘
 Create standby.signal file in Data directory.
Failover Options

 Failover is the ability of a system to continue functioning even if


Primary fails
 PostgreSQL in itself does not provide an automatic failover solution.
 We can manually failover postgresql from master to server using
below mentioned methods:
./pg_ctl promote -D /var/lib/pgsql/12/data
Create a trigger file with the file name and path specified by the
promote_trigger_file.
SELECT pg_promote();
Thank you. 

You might also like