Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

If the primary database deletes data by mistake, the secondary database can flash back to the deletion point, retrieve the lost data, and then automatically synchronize the data back.

Note: it is not recommended to enable flashback in the master library. Firstly, it affects the performance. Secondly, the master library cannot do flashback for some data, so it is very weak.

How does the standby DataGuard enable database flashback?

  • Sufficient disk space is required

1. Close the synchronization process for the standby DataGuard

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; 
Copy the code

2. Step 2: Enable the flashback function

ALTER DATABASE FLASHBACK ON; 
alter system set db_recovery_file_dest='/oradata/fast_recovery_area' scope=spfile;
alter system set db_recovery_file_dest_size=100G scope=spfile;
Copy the code

Note: The /oradata/fast_recovery_area directory must be physically present. The specified size of the flashback area is the upper limit of the disk space occupied by the flashback log.

3. Restart the standby database to take effect. Restart the standby database synchronization process

shutdown immediate
startup mount
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Copy the code

4. Step 4: Check the status of the flashback

select FLASHBACK_ON from v$database;
show parameter db_recovery_file_dest
show parameter db_recovery_file_dest_size
show parameter db_flashback_retention_target
Copy the code

After enabling the flashback function, observe 🔎 for a period of time to determine how long the 100 GB space can store the flashback logs, roughly calculate the space for storing the flashback logs at a fixed time, and modify the space according to the actual situation!


This is the end of sharing ~

If you think the article is helpful to you, please like it, favorites it, pay attention to it, comment on it, and support it four times with one button. Your support is the biggest motivation for my creation.

❤️ technical exchange can follow the public number: Lucifer think twice before you do ❤️