Tuesday, August 27, 2019

Where is my recovery.conf file in PostgreSQL v12 ?

Well the short answer is - it has gone.
From PostgreSQL v12 - 'recovery.conf' is no more valid and even if someone create a recovery.conf file manually and keep under  data  directory -Server is not going to start - will throw this below error


Parameter  'standby_mode =on' is also removed from PG v12 which used to be #1 parameter of recovery.conf file also trigger_file parameter name is changed to promote_trigger_file.
Other parameters which we usually  mention in the recovery.conf is valid and can be write in the postgresql.conf file of SLAVE cluster.  

It is actually make more sense if all the  required information is mentioned in one file i.e  postgresql.conf rather than creating/managing separate files.

standby.signal which is a empty file has replace recovery.conf file and presence of this file will signal the cluster to run in standby mode.

Step by Step guide to setup SR in PG v12 and Failover
=======================================
1)PG v12 server is up and running -  only modified 2 parameters in the postgresql.conf file of master cluster


archive_mode  = Whether to send  WAL files for archive storage or not
archive_command = Where to send i.e location

2)Create Standby/Slave using pg_basebackup  with option -R 



pg_basebackup utility  is for to take the backup online.There is an another method as well where we can fire - select pg_start_backup('My backup..'); in master cluster to start the online backup and then using cp command take the backup and later fire - select pg_stop_backup(); to signal the master server that online backup is finish but again manual intervention is required i.e remove postmaster.pid /create recovery.conf file (or from PG v12 - create standby.signal) in slave directory  so better to use pg_basebackup only which take care of everything.

-R option will create a empty file with the name- standby.signal .


3)Old recovery.conf file ( taken from PG v10)
   
                     

if we just copy all these above parameters in the postgresql.conf file of slave cluster . Server is going to throw this below error - 






As standby_mode parameter is no more supported and trigger_file is rename to promote_trigger_file -server is failed to start . just Correct both these - Server will start. 





4)Verify SR setup is properly working


















Perform - Failover - 
There are multiple ways -
a)shut down the master and promote standby.
b)Shut down the master and touch the file which we mentioned in postgresql.conf in promote_trigger_file parameter.

In this case - using option b) 







standby.signal file has gone from slave/ data directory. Slave is now new Master and able to perform DDL operations.



No comments:

Post a Comment