简体   繁体   中英

How to recover the current wal file that was being written in master and not yet archived?

I am new to postgres and was trying to simulate a postgresql cluster so:

I have two nodes installed for postgres latest version and acting as active / hot standby and with master configuration:

archive_mode = on
archive_command = 'test ! -f /data/%f && cp %p /data/%f'

and slave configuration

primary_slot_name = 'standby_db2_slot'
hot_standby = on

and others default and related configuration

my question is if the standby was off for some time and the master crashes how to recover the data from my archived wal files also how to get the last wal file that the master was writing to before crashing?

You could copy the files from the archive (if it is still available) into the replica's pg_wal folder. Or more typically, you would set restore_command to copy each of them from the archive upon request.

how to get the last wal file that the master was writing to before crashing?

If it was a hard crash where the master's storage was irreparably destroyed, you likey can't get it. That is why streaming is great, it copies the data stream in near-real time to minimize loss. And if was a soft crash, why are you trying to promote the replica anyway, rather than just turning the master back on? If the master's storage was only partially destroyed, then just copy this last file to the archive manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM