Showing posts with label Step by step enable Archive log and Flashback in Oracle 12c R2 RAC Database. Show all posts
Showing posts with label Step by step enable Archive log and Flashback in Oracle 12c R2 RAC Database. Show all posts

Friday, 24 April 2020

Step by step enable Archive log and Flashback in Oracle 12c R2 RAC Database

---Check Archive log is enabled or not--------

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /d01/app/oracle/product/12.2.0.1/db_1/dbs/arch
Oldest online log sequence     16
Current log sequence           17
SQL>

------Check Database Configuration------------

-bash-4.4$ srvctl config database -d cdbpr
Database unique name: cdbpr
Database name: cdbpr
Oracle home: /d01/app/oracle/product/12.2.0.1/db_1
Oracle user: oracle
Spfile: +CDATA/CDBPR/PARAMETERFILE/spfile.269.1037317075
Password file: +CDATA/CDBPR/PASSWORD/pwdcdbpr.260.1037316549
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: CDATA,ADATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: cdbpr1,cdbpr2
Configured nodes: badc-cdbpr01,badc-cdbpr02
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed
-bash-4.4$

SQL> show parameter recovery

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string
db_recovery_file_dest_size           big integer 0
recovery_parallelism                 integer     0
remote_recovery_file_dest            string
SQL>

----Change Flashback retention period--------

SQL> show parameter db_flashback_retention_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target        integer     1440     -----------> (Minutes)
SQL>

SQL> alter system set db_flashback_retention_target=2880 scope=both sid='*';

System altered.

SQL> show parameter db_flashback_retention_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target        integer     2880      -------------> (Minutes ---48 Hours)
SQL>

----Set db_recovery_file_dest_size and db_recovery_file_dest system parameter for total size limit for flashback recovery.

SQL> alter system set db_recovery_file_dest_size=900G scope=both sid='*';

System altered.

SQL> alter system set db_recovery_file_dest='+FRA' scope=both sid='*';

System altered.

SQL>
SQL> show parameter recovery

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      +FRA
db_recovery_file_dest_size           big integer 900G
recovery_parallelism                 integer     0
remote_recovery_file_dest            string
SQL>

-----Shutdown Database for both instance---

-bash-4.4$ srvctl stop database -d cdbpr
-bash-4.4$


-bash-4.4$ sqlplus

SQL*Plus: Release 12.2.0.1.0 Production on Fri Apr 24 14:40:08 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Enter user-name: /as sysdba
Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 5.3687E+11 bytes
Fixed Size                 30051944 bytes
Variable Size            5.0251E+11 bytes
Database Buffers         3.3286E+10 bytes
Redo Buffers             1043685376 bytes
Database mounted.
SQL>

-------------Enable Archive log first then enable Flashback--------

SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38707: Media recovery is not enabled.


SQL> alter database archivelog;

Database altered.

SQL> alter database flashback on;

Database altered.

SQL>

SQL> select flashback_on  from v$database;

FLASHBACK_ON
------------------
YES

SQL>

SQL> alter database open;

Database altered.

SQL>

-------Shutdown Instance------

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

-------Start Database with both instance simultaneously-------

-bash-4.4$ srvctl start database -d cdbpr
-bash-4.4$

----Check Archive Log and Flashback enable from both instance -------


SQL> select INST_ID,FLASHBACK_ON,NAME from GV$DATABASE;

   INST_ID FLASHBACK_ON       NAME
---------- ------------------ ---------
         1 YES                CDBPR
         2 YES                CDBPR

SQL>