PostgreSQL V13 Master-Slave Replication on Window Server 2016 Not Replicating

postgresql

I have installed and configured PostgreSQL V13 on window server 2016 but replication is not working. I don't know where the error is because we are not facing any error regarding replication and replication also not working.

Below are the Configuration steps performed on Master Server

Master Server postgresql.conf file changes made

listen_addresses = '*'  
wal_level = replica
wal_writer_delay = 500ms
archive_mode = on
archive_command ='copy %p \\\\server IP\\wal_archive\\%f"'
archive_timeout = 3600
max_wal_senders = 3
max_replication_slots = 6

pg_hba Master Server File

host    replication     username    slave_ip/32     md5
host    replication     username    master_ip/32    md5

Below are the Configuration steps performed on Slave Server

Note: I have copied Data directory from master server and paste it on Slave server

Slave Server postgresql.conf file changes made

listen_addresses = '*'  
wal_level = replica
wal_writer_delay = 500ms
#archive_mode = off
max_wal_senders = 3 
hot_standby = on

Slave pg_hba.conf file

host    replication     username    slave_ip/32     md5
host    replication     username    master_ip/32    md5

recovery.conf file

standby_mode = 'on'
restore_command= 'copy "C:\\wal_archive\\%f" %p'
<primary_conninfo> = 'host=<master server> port=5432 user=username password=*****'

After all these changes made when I restart the master and slave server and run the following command on master server to check whether replication is working or not the below mention query return 0 row

Master Server

select * from pg_stat_replication" (return 0 row)

Would highly appreciated, if someone could tell me what exactly the issue is or what I am missing in the configuration on both the servers (master- slave). Why replication is not working?

Best Answer

Replication cannot work while the standby server is shut down. Your standby server is definitely not running because of error on startup

FATAL: using recovery command file "recovery.conf" is not supported

I moved all recovery settings to regular postgresql.conf infrastructure since PostgreSQL 12. recovery.conf is no longer supported. PostgreSQL will only check for the existence of such a file and will refuse to start in this case.

In order to start standby server it is neccesary to move all replication settings to regular configuration files and place special signal file standby.signal into PGDATA (file content does not matter, usually it is empty file).

Also, pg_basebackup option --write-recovery-conf (-R) will works correctly. Usually standby is copied from primary with pg_basebackup tool. With option -R the tool will prepare standby.signal and streaming configuration (primary_conninfo and primary_slot_name) on standby to start streaming replication.