How to enable Flashback Database In Oracle 19c RAC Database
Flashback Database In Oracle 19c RAC Database
1st Step: Check the status.
SQL> select log_mode,flashback_on from gv$database;
LOG_MODE FLASHBACK_ON
———— ——————
NOARCHIVELOG NO
NOARCHIVELOG NO
2nd Step: Stop the database service.
[oratansid@shsdbdr01 ~]$ srvctl stop database -d tansid
3rd Step: Start the database in mount state.
[oratansid@shsdbdr01 ~]$ srvctl status database -d tansid
Instance tansid1 is running on node shsdbdr01
Instance atnsid2 is running on node shsdbdr02
4th Step: Enable archive log and Flashback database
[oratansid@rac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 – Production
Version 19.14.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 – Production
Version 19.14.0.0.0
Before Enable flashback first we need to enable archivelog dest and archivelog
SQL> alter system set log_archive_dest_1=’LOCATION=+ARCH/’ scope=both sid=’*’;
System altered.
SQL> alter database archivelog;
Database altered.
SQL> alter system set db_recovery_file_dest_size=155G scope=both sid=’*’;
System altered.
SQL> alter system set db_recovery_file_dest=’+ARCH’ scope=both sid=’*’;
System altered.
SQL> alter database flashback on;
Database altered.
5th Step: Stop the database service.
[oratansid@shsdbdr01 ~]$ srvctl stop database -d tansid
6th Step: Start the database
[oratansid@shsdbdr01 ~]$ srvctl status database -d tansid
Instance tansid1 is running on node shsdbdr01
Instance atnsid2 is running on node shsdbdr02
7th Step:- Check flashback Status
SQL> select log_mode,flashback_on from gv$database;
LOG_MODE FLASHBACK_ON
———— ——————
NOARCHIVELOG YES
NOARCHIVELOG YES
Some important commands for the Flashback
FLASHBACK TABLE flashback_table_test TO SCN SCN_****
FLASHBACK TABLE flashback_table_test TO TIMESTAMP TO_TIMESTAMP('2023-02-23 12:00:00', 'YYYY-MM-DD HH:MI:SS');
Flashback Drop
FLASHBACK TABLE flashback_drop_tbl TO BEFORE DROP RENAME TO flashback_drop_tbl_old;
PURGE TABLE tablename; -- Specific table.PURGE INDEX indexname; -- Specific index.PURGE TABLESPACE ts_name; -- All tables in a specific tablespace.PURGE TABLESPACE ts_name USER username; -- All tables in a specific tablespace for a specific user.PURGE RECYCLEBIN; -- The current users entire recycle bin.PURGE DBA_RECYCLEBIN; -- The whole recycle bin.
ALTER SESSION SET recyclebin = OFF;ALTER SESSION SET recyclebin = ON;ALTER SYSTEM SET recyclebin = OFF;ALTER SYSTEM SET recyclebin = ON;
CONN / AS SYSDBASHUTDOWN IMMEDIATESTARTUP MOUNT EXCLUSIVEFLASHBACK DATABASE TO TIMESTAMP SYSDATE-(1/24/12);ALTER DATABASE OPEN RESETLOGS;
FLASHBACK DATABASE TO TIMESTAMP my_table;FLASHBACK DATABASE TO BEFORE TIMESTAMP my_table;FLASHBACK DATABASE TO SCN table_scn;FLASHBACK DATABASE TO BEFORE SCN table_scn;CREATE RESTORE POINT before_changes;CREATE RESTORE POINT before_changes GUARANTEE FLASHBACK DATABASE;
FLASHBACK DATABASE TO RESTORE POINT before_changes;
SQL> SELECT OLDEST_FLASHBACK_SCN, OLDEST_FLASHBACK_TIME2 FROM V$FLASHBACK_DATABASE_LOG;OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK-------------------- ----------------411010 2013/02/14 16:49
RMAN> SHUTDOWN IMMEDIATERMAN> STARTUP MOUNTRMAN> FLASHBACK DATABASE TO SCN 411010;
Starting flashback at 15-FEB-13allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=104 device type=DISKstarting media recoverymedia recovery complete, elapsed time: 00:00:07Finished flashback at 15-FEB-13
RMAN> ALTER DATABASE OPEN RESETLOGS;
SQL> CREATE RESTORE POINT before_update GUARANTEE FLASHBACK DATABASE;
RMAN> LIST RESTORE POINT ALL;SCN RSP Time Type Time Name---------------- --------- ---------- --------- ----412742 GUARANTEED 15-FEB-13 BEFORE_UPDATE
RMAN> SHUTDOWN IMMEDIATERMAN> STARTUP MOUNTRMAN> FLASHBACK DATABASE TO RESTORE POINT 'BEFORE_UPDATE';Starting flashback at 15-FEB-13allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=104 device type=DISKstarting media recoveryarchived log for thread 1 with sequence 34 is already on disk as file /disk2/oracle/oradata/prod/arch/archive1_34_614598462.dbfmedia recovery complete, elapsed time: 00:00:01Finished flashback at 15-FEB-13RMAN> ALTER DATABASE OPEN RESETLOGS;FLASHBACK DATABASE for a PDB to a Guaranteed PDB Restore Point
SQL> CREATE RESTORE POINT hr_pdb_grp_before_upgrade GUARENTEE FLASHBACK DATABASE;
SQL> SELECT name, guarantee_flashback_database, pdb_restore_point, con_idFROM v$restore_point;NAME GUARANTEE_FLASHBACK_DATABASE PDB_RESTORE_POINT CON_ID----------------------------- --------------------------- ----------------- ------CDB_GRP_BEFORE_PATCH YES NO 0HR_PDB_GRP_BEFORE_UPGRADE YES YES 1
RMAN> SHUTDOWN IMMEDIATE;RMAN> STARTUP MOUNT;RMAN> FLASHBACK PLUGGABLE DATABASE hr_pdb TO RESTORE POINT hr_pdb_grp_before_upgradeAUXILIARY DESTINATION '/temp/aux_dest';RMAN> ALTER PLUGGABLE DATABASE hr_pdb OPEN RESETLOGS;
Comments
Post a Comment