Today we will look into the requested WAL segment 000000020000000000000006 has already been removed error.
I will share the following error with its solution, after switchover between primary and standby in PostgreSQL. (Database version : PostgreSQL 13)
Error :
LOG: started streaming WAL from primary at 0/6000000 on timeline 2
FATAL: could not receive data from WAL stream: ERROR: requested WAL segment 000000020000000000000006 has already been removed
Solution :
We copy the missing archives from the primary database to the pg_wal directory in the standby database.
1 |
<span id="30af" class="gi ll kd ih lm b dn ln lo l lp" data-selectable-paragraph=""><strong class="lm ii">$ scp -r 000000020000000000000006 postgres@<standby_server_ip>:/var/lib/pgsql/13/data/pg_wal</strong></span> |
After copying the missing archives, we restart the backup database.
1 |
<span id="3a3d" class="gi ll kd ih lm b dn ln lo l lp" data-selectable-paragraph=""><strong class="lm ii">$ pg_ctl -D /var/lib/pgsql/13/data stop</strong></span><span id="70bc" class="gi ll kd ih lm b dn lq lr ls lt lu lo l lp" data-selectable-paragraph=""><strong class="lm ii">$ pg_ctl -D /var/lib/pgsql/13/data start</strong></span> |