Monday, October 17, 2016

Oracle Flashback Database 11gR2

Oracle Flashback Database is a technology used to rewind database to past state, by undoing all of the changes made to database without restoring database. In this article, I am going to share how to enable it and how perform flashback database in dataguard environment, 11gr2.

1. Summary Step of How to Enable Flashback Database

  • Primary
    • Shutdown database
    • Startup in mount mode
    • Enable archive log if it disable
    • Enable flashback
    • Open database
  • Physical Standby
    • Cancel Recovery Process
    • Shutdown database
    • Startup in mount mode
    • Enable archive log if it disable
    • Enable flashback
    • Open database
    • Start Recovery Process


2. Detail Step of How to Enable Flashback Database

2.1 Enable Flashback Database on Primary DB

a. Check database whether it was enable or not

SQL> 
select instance_name, status from v$instance;
INSTANCE_NAME    STATUS
---------------- ------------
DC               OPEN
SQL> 
select NAME,FLASHBACK_ON from v$database;
NAME      FLASHBACK_ON
--------- ------------------
DC        NO

b. Set FRA location and size

SQL>
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='+RECO' SCOPE=SPFILE;
ALTER SYSTEM SET db_recovery_file_dest_size=3G SCOPE=SPFILE;

c. Enable flashback

SQL> 
shut immediate
startup mount;
alter database archivelog;
alter database flashback on;
alter database open;

d. Flashback Retention

SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320; # 3 days, in minute


2.2 Enable Flashback Database on Standby DB:

a. Check database whether it was enable or not

SQL> 
select instance_name, status from v$instance;
INSTANCE_NAME    STATUS
---------------- ------------
DC               OPEN
SQL> 
select NAME,FLASHBACK_ON from v$database;
NAME      FLASHBACK_ON
--------- ------------------
DC        NO


b. Set FRA location and size
SQL>
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='+RECO' SCOPE=SPFILE;
ALTER SYSTEM SET db_recovery_file_dest_size=3G SCOPE=SPFILE;

c. Enable flashback
SQL> 
alter database recover managed standby database cancel;
shut immediate
startup mount;
alter database flashback on;
alter database open;
alter database recover managed standby database using current logfile disconnect from session;

d. Flashback Retention

SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320; # 3 days, in minute

3. Verify Flashback on Both Primary and Standby after Enable it

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +RECO
Oldest online log sequence     5
Next log sequence to archive   7
Current log sequence           7

SQL> show parameter LOG_ARCHIVE_DEST_1

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------
log_archive_dest_1                   string      LOCATION=+RECO

SQL> 
select NAME,FLASHBACK_ON from v$database;

NAME      FLASHBACK_ON
--------- ------------------
DC        YES

SQL> 
show parameter DB_FLASHBACK_RETENTION_TARGET

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------
db_flashback_retention_target        integer     4320
SQL>

SQL> 
show parameter db_recovery_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------
db_recovery_file_dest                string      +RECO
db_recovery_file_dest_size           big integer 3G
SQL>


4. Test Case
a. Case 1: Perform Flashback Database ToTime on Both Primary and Standby
i. Primary

SQL> select flashback_on from v$database;

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

#Create test table:

SQL> Create table test(id nvarchar2(1000));
SQL> 
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;

#Select From (Primary):

SQL> select * from test;

ID
-------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48
25-06-2014 11:43:51
25-06-2014 11:43:54
25-06-2014 11:43:57
25-06-2014 11:44:00

10 rows selected.

SQL>

#Select From (Standby):

SQL> select * from test;

ID
-------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48
25-06-2014 11:43:51
25-06-2014 11:43:54
25-06-2014 11:43:57
25-06-2014 11:44:00

10 rows selected.

SQL>

#Perform flashback database with RMAN

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    1235959808 bytes

Fixed Size                     2227904 bytes
Variable Size                939524416 bytes
Database Buffers             285212672 bytes
Redo Buffers                   8994816 bytes

RMAN> FLASHBACK DATABASE TO TIME "TO_DATE('25-06-2014 11:43:48','DD-MM-YYYY HH24:MI:SS')";

Starting flashback at 25-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=26 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=28 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=29 device type=DISK


starting media recovery

archived log for thread 1 with sequence 19 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_19.565.851118079
archived log for thread 1 with sequence 20 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_20.566.851118081
archived log for thread 1 with sequence 21 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_21.567.851118219
archived log for thread 1 with sequence 22 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_22.568.851118221
archived log for thread 1 with sequence 23 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_23.569.851118225
archived log for thread 1 with sequence 24 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_24.570.851118225
archived log for thread 1 with sequence 25 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_25.571.851118229
media recovery complete, elapsed time: 00:00:08
Finished flashback at 25-JUN-14

RMAN> alter database open resetlogs;

database opened

RMAN> alter database open resetlogs;

database opened

RMAN> exit

sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 25 12:05:40 2014

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> select * from test;

ID
-------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48

6 rows selected.

#Note: At standby alert log will show message as below after primary finish open db with resetlogs. This mean that recovery process will stop by itself.

2014-06-25 11:53:35.598000 +07:00
MRP0: Background Media Recovery process shutdown (DGDB)

ii. Standby


SQL> alter database recover managed standby database cancel;
alter database recover managed standby database cancel
*
ERROR at line 1:
ORA-16136: Managed Standby Recovery not active

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 
rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jun 25 12:02:19 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup mount;

Oracle instance started
database mounted

Total System Global Area     835104768 bytes

Fixed Size                     2232960 bytes
Variable Size                301993344 bytes
Database Buffers             528482304 bytes
Redo Buffers                   2396160 bytes

RMAN> 
RMAN> 

RMAN> FLASHBACK DATABASE TO TIME "TO_DATE('25-06-2014 11:43:48','DD-MM-YYYY HH24:MI:SS')";

Starting flashback at 25-JUN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=88 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=89 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=90 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=91 device type=DISK


starting media recovery

archived log for thread 1 with sequence 19 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_19.582.851118075
archived log for thread 1 with sequence 20 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_20.581.851118079
archived log for thread 1 with sequence 21 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_21.358.851118217
archived log for thread 1 with sequence 22 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_22.480.851118221
archived log for thread 1 with sequence 23 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_23.271.851118221
archived log for thread 1 with sequence 24 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_24.478.851118223
archived log for thread 1 with sequence 25 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_25.419.851118225
media recovery complete, elapsed time: 00:00:14
Finished flashback at 25-JUN-14

RMAN> 
RMAN> 

RMAN> alter database open;

database opened

RMAN> exit


Recovery Manager complete.
[oracle@ol6211gr2dr ~]$ 
[oracle@ol6211gr2dr ~]$ 
[oracle@ol6211gr2dr ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 25 12:04:42 2014

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> @start_recover

Database altered.

SQL> ;
  1* alter database recover managed standby database using current logfile disconnect from session
SQL> 

SQL> select * from test;

ID
--------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48

6 rows selected.

b. Case 2: Perform Flashback Database on Both Primary and Standby
By Using Guaranteed Restore Points
i. Create Guaranteed Restore Points  on Standby

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES
SQL> CREATE RESTORE POINT before_flashback2 GUARANTEE FLASHBACK DATABASE;
SQL> SELECT NAME, SCN, TIME, DATABASE_INCARNATION#,
GUARANTEE_FLASHBACK_DATABASE,STORAGE_SIZE
FROM V$RESTORE_POINT;

NAME
--------------------------------------------------------------------------------
       SCN
----------
TIME
---------------------------------------------------------------------------
DATABASE_INCARNATION# GUA STORAGE_SIZE
--------------------- --- ------------
BEFORE_FLASHBACK2
   1073762
25-JUN-14 05.28.03.000000000 PM
                    4 YES     52428800


SQL>

ii. Create Guaranteed Restore Points  on Primary

SQL> CREATE RESTORE POINT before_flashback2 GUARANTEE FLASHBACK DATABASE;

Restore point created.

SQL> SELECT NAME, SCN, TIME, DATABASE_INCARNATION#,
  2  GUARANTEE_FLASHBACK_DATABASE,STORAGE_SIZE
  3  FROM V$RESTORE_POINT;

NAME
--------------------------------------------------------------------------------
       SCN
----------
TIME
---------------------------------------------------------------------------
DATABASE_INCARNATION# GUA STORAGE_SIZE
--------------------- --- ------------
BEFORE_FLASHBACK2
   1073790
25-JUN-14 05.28.29.000000000 PM
                    4 YES     52428800


SQL> 
insert into test values('BEFORE_FLASHBACK2');
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;
insert into test values(TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS'));
commit;
alter system switch logfile;



Primary:
SQL> select * from test;

ID
--------------------------------------------------------------------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48
25-06-2014 12:59:34
25-06-2014 12:59:34
25-06-2014 12:59:35
25-06-2014 12:59:37
25-06-2014 12:59:38

ID
--------------------------------------------------------------------------------
25-06-2014 12:59:41
25-06-2014 12:59:44
25-06-2014 12:59:47
25-06-2014 12:59:50
25-06-2014 12:59:53
after flash
after flash 1
BEFORE_FLASHBACK2
25-06-2014 17:31:06
25-06-2014 17:31:07
25-06-2014 17:31:11

ID
--------------------------------------------------------------------------------
25-06-2014 17:31:14
25-06-2014 17:31:17
25-06-2014 17:31:20
25-06-2014 17:31:23
25-06-2014 17:31:26
25-06-2014 17:31:29
25-06-2014 17:31:32

29 rows selected.

SQL>

iii. Check data on Standby
SQL>
SQL> select * from test;

ID
--------------------------------------------------------------------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48
25-06-2014 12:59:34
25-06-2014 12:59:34
25-06-2014 12:59:35
25-06-2014 12:59:37
25-06-2014 12:59:38

ID
--------------------------------------------------------------------------------
25-06-2014 12:59:41
25-06-2014 12:59:44
25-06-2014 12:59:47
25-06-2014 12:59:50
25-06-2014 12:59:53
after flash
after flash 1
BEFORE_FLASHBACK2
25-06-2014 17:31:06
25-06-2014 17:31:07
25-06-2014 17:31:11

ID
--------------------------------------------------------------------------------
25-06-2014 17:31:14
25-06-2014 17:31:17
25-06-2014 17:31:20
25-06-2014 17:31:23
25-06-2014 17:31:26
25-06-2014 17:31:29
25-06-2014 17:31:32

29 rows selected.

SQL>

iv. Flashback on Primary

SQL>
rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jun 25 17:35:02 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DB (DBID=1614976585)

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    1235959808 bytes

Fixed Size                     2227904 bytes
Variable Size               1023410496 bytes
Database Buffers             201326592 bytes
Redo Buffers                   8994816 bytes

RMAN> FLASHBACK DATABASE TO RESTORE POINT 'BEFORE_FLASHBACK2';

Starting flashback at 25-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=27 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=28 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=29 device type=DISK


starting media recovery

archived log for thread 1 with sequence 3 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_3.329.851136987
archived log for thread 1 with sequence 4 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_4.328.851137423
archived log for thread 1 with sequence 5 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_5.327.851137433
archived log for thread 1 with sequence 6 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_6.326.851137937
archived log for thread 1 with sequence 7 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_7.323.851138079
archived log for thread 1 with sequence 8 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_8.320.851138087
archived log for thread 1 with sequence 9 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_9.319.851138539
archived log for thread 1 with sequence 10 is already on disk as file +RECO/db/archivelog/2014_06_25/thread_1_seq_10.322.851139067
media recovery complete, elapsed time: 00:00:12
Finished flashback at 25-JUN-14

RMAN> alter database open resetlogs;

database opened

RMAN> 
sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 25 17:37:05 2014

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> select * from test;

ID
--------------------------------------------------------------------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48
25-06-2014 12:59:34
25-06-2014 12:59:34
25-06-2014 12:59:35
25-06-2014 12:59:37
25-06-2014 12:59:38

ID
--------------------------------------------------------------------------------
25-06-2014 12:59:41
25-06-2014 12:59:44
25-06-2014 12:59:47
25-06-2014 12:59:50
25-06-2014 12:59:53
after flash
after flash 1

18 rows selected.

SQL>

v. Flashback on Standby

SQL>
rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jun 25 17:37:51 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DB (DBID=1614976585)

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area     835104768 bytes

Fixed Size                     2232960 bytes
Variable Size                301993344 bytes
Database Buffers             528482304 bytes
Redo Buffers                   2396160 bytes

RMAN> FLASHBACK DATABASE TO RESTORE POINT 'BEFORE_FLASHBACK2';

Starting flashback at 25-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=91 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=92 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=95 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=96 device type=DISK


starting media recovery

archived log for thread 1 with sequence 5 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_5.472.851137423
archived log for thread 1 with sequence 6 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_6.470.851137929
archived log for thread 1 with sequence 7 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_7.477.851138069
archived log for thread 1 with sequence 8 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_8.452.851138077
archived log for thread 1 with sequence 9 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_9.469.851138529
archived log for thread 1 with sequence 10 is already on disk as file +RECO/dgdb/archivelog/2014_06_25/thread_1_seq_10.474.851139057
media recovery complete, elapsed time: 00:00:08
Finished flashback at 25-JUN-14

RMAN> 

sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 25 17:39:17 2014

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> @start_recover;

Database altered.

SQL> ;
  1* alter database recover managed standby database using current logfile disconnect from session
SQL> 
SQL> select * from test;

ID
--------------------------------------------------------------------------------
25-06-2014 11:43:38
25-06-2014 11:43:39
25-06-2014 11:43:39
25-06-2014 11:43:44
25-06-2014 11:43:45
25-06-2014 11:43:48
25-06-2014 12:59:34
25-06-2014 12:59:34
25-06-2014 12:59:35
25-06-2014 12:59:37
25-06-2014 12:59:38

ID
--------------------------------------------------------------------------------
25-06-2014 12:59:41
25-06-2014 12:59:44
25-06-2014 12:59:47
25-06-2014 12:59:50
25-06-2014 12:59:53
after flash
after flash 1

18 ows selected.


5. Maintenance
a. Sizing FRA

SQL> ALTER SYSTEM SET db_recovery_file_dest_size=2G SCOPE=SPFILE;

b. Flashback Retention

SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320; # 3 days, in minute
SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=15; # 15 minute

c. Check FRA usage

SQL>
SELECT Sum(PERCENT_SPACE_USED) FROM V$FLASH_RECOVERY_AREA_USAGE;
SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE;
SELECT * FROM V$RECOVERY_FILE_DEST;


d. Estimating Disk Space Requirements for Flashback Database Logs(After Enable Flashback)

SQL> 
SELECT ESTIMATED_FLASHBACK_SIZE FROM V$FLASHBACK_DATABASE_LOG;



Good Luck !!!





Monday, October 10, 2016

Adding and Deleting Cluster Nodes Step By Step

Adding and Deleting Cluster NodesStep By Step

The following are the step of deleting and adding cluster node in Oracle RAC 11gR2. It was happen in my company and fixed it successfully without down the system; I mean I can do online during customer do transaction and there is no one complain any issue during this.

 Let me introduce my real case of this issue:
1. I have two node RAC, dbnode1 and dbnode2 working properly
2. Then There is a problem happen with OS on dbnode1, and file system /oracle was missed from OS  and everything- grid and rdbms software- did not appear
3. Our system still running with dbnode2.

Now we are a DBA we need to fix it as soon as posible.
1. We need clean/remove/delete dbnode1 configuration from cluster(do it from dbnode2)
2. Run script post delete node and Pre add node.(do it from dbnode2)
3. Create nessary folder on dbnode1
4.Transfer binary of grid from dbnode2(do it from dbnode2)
5. Transfer binary of rdbms from dbnode2(do it from dbnode2)
6. Prepare db parameter on dbnode1

============

*******************************************************************
*Note: dbnode1 is new node which need to add to existing cluster.*
*******************************************************************

dbnode1:
mkdir -p /oracle/oraInventory
mkdir -p /oracle/11.2.0.3/grid
mkdir -p /oracle/product/11.2.0.3/dbhome_1
chown -R pitraib:oinstall /oracle
# cd /dev
# ls -l rhdisk*
# chown pitraib:oinstall rhdisk3 rhdisk4 rhdisk5 rhdisk6 rhdisk7 rhdisk8 rhdisk9 rhdisk10 rhdisk11

==========
dbnode2:=
==========
To delete a node from a cluster:
# olsnodes -s -t
#
if it pin then unpin
# crsctl unpin css -n node_to_be_deleted

# crsctl delete node -n dbnode1
CRS-4661: Node dbnode1 successfully deleted.
#
$ cd /oracle/11.2.0.3/grid/oui/bin
$ ./runInstaller -updateNodeList ORACLE_HOME=/oracle/11.2.0.3/grid "CLUSTER_NODES=dbnode2" CRS=TRUE
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4095 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /oracle/oraInventory
'UpdateNodeList' was successful.
$

---------------------------------------------------------------------------------

$ cluvfy stage -post nodedel -n dbnode1 -verbose

Performing post-checks for node removal

Checking CRS integrity...

Clusterware version consistency passed
The Oracle Clusterware is healthy on node "dbnode2"

CRS integrity check passed
Result:
Node removal check passed

Post-check for node removal was successful.
$
==============================
$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       dbnode2                                    
ora.LISTENER.lsnr
               ONLINE  ONLINE       dbnode2                                    
ora.OCRV.dg
               ONLINE  ONLINE       dbnode2                                    
ora.RECO.dg
               ONLINE  ONLINE       dbnode2                                    
ora.asm
               ONLINE  ONLINE       dbnode2                 Started            
ora.gsd
               OFFLINE OFFLINE      dbnode2                                    
ora.net1.network
               ONLINE  ONLINE       dbnode2                                    
ora.ons
               ONLINE  ONLINE       dbnode2                                    
ora.registry.acfs
               ONLINE  ONLINE       dbnode2                                    
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       dbnode2                                    
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       dbnode2                                    
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       dbnode2                                    
ora.orcldb.db
      1        ONLINE  OFFLINE                                                  
      2        ONLINE  ONLINE       dbnode2                 Open               
ora.cvu
      1        ONLINE  ONLINE       dbnode2                                    
ora.dbnode1.vip
      1        ONLINE  INTERMEDIATE dbnode2                 FAILED OVER        
ora.dbnode2.vip
      1        ONLINE  ONLINE       dbnode2                                    
ora.oc4j
      1        ONLINE  ONLINE       dbnode2                                    
ora.scan1.vip
      1        ONLINE  ONLINE       dbnode2                                    
ora.scan2.vip
      1        ONLINE  ONLINE       dbnode2                                    
ora.scan3.vip
      1        ONLINE  ONLINE       dbnode2                                    
$

$ cluvfy stage -post nodedel -n dbnode1 -verbose
$ cluvfy stage -pre nodeadd -n dbnode1 -verbose

----YOU HAVE TO BECAREFULL MAKE SURE WHAT U NEED TO IGNORE

$ export IGNORE_PREADDNODE_CHECKS=Y
$ cd /oracle/11.2.0.3/grid/oui/bin
$ ./addNode.sh -silent "CLUSTER_NEW_NODES={dbnode1}" "CLUSTER_NEW_VIRTUAL_HOSTNAMES={dbnode1-vip}"

$ export IGNORE_PREADDNODE_CHECKS=Y
$ ./addNode.sh -silent CLUSTER_NEW_NODES={dbnode1}
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 3969 MB    Passed
Oracle Universal Installer, Version 11.2.0.3.0 Production
Copyright (C) 1999, 2011, Oracle. All rights reserved.


Performing tests to see whether nodes dbnode1,dbnode1 are available
............................................................... 100% Done.

SEVERE:The new nodes 'dbnode1' are already part of the cluster.
$ echo $ORACLE_HOME
/oracle/product/11.2.0.3/dbhome_1

$ cd $ORACLE_HOME/oui/bin
$ ./runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={dbnode2}"
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 3963 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /oracle/oraInventory
'UpdateNodeList' was successful.
$

$ export IGNORE_PREADDNODE_CHECKS=Y
$ cd /oracle/product/11.2.0.3/dbhome_1/oui/bin

$ ./addNode.sh -silent CLUSTER_NEW_NODES={dbnode1}
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 32768 MB    Passed
Oracle Universal Installer, Version 11.2.0.3.0 Production
Copyright (C) 1999, 2011, Oracle. All rights reserved.


Performing tests to see whether nodes dbnode1 are available
............................................................... 100% Done.

..
-----------------------------------------------------------------------------
Cluster Node Addition Summary
Global Settings
   Source: /oracle/product/11.2.0.3/dbhome_1
   New Nodes
Space Requirements
   New Nodes
      dbnode1
         /oracle: Required 7.47GB : Available 86.38GB
Installed Products
   Product Names
      Oracle Database 11g 11.2.0.3.0
      Sun JDK 1.5.0.12.4
      Installer SDK Component 11.2.0.3.0
      Oracle One-Off Patch Installer 11.2.0.1.7
      Oracle Universal Installer 11.2.0.3.0
      Oracle USM Deconfiguration 11.2.0.3.0
      Oracle Configuration Manager Deconfiguration 10.3.1.0.0
      Oracle DBCA Deconfiguration 11.2.0.3.0
      Oracle RAC Deconfiguration 11.2.0.3.0
      Oracle Database Deconfiguration 11.2.0.3.0
      Oracle Configuration Manager Client 10.3.2.1.0
      Oracle Configuration Manager 10.3.5.0.1
      Oracle ODBC Driverfor Instant Client 11.2.0.3.0
      LDAP Required Support Files 11.2.0.3.0
      SSL Required Support Files for InstantClient 11.2.0.3.0
      Bali Share 1.1.18.0.0
      Oracle Extended Windowing Toolkit 3.4.47.0.0
      Oracle JFC Extended Windowing Toolkit 4.2.36.0.0
      Oracle Real Application Testing 11.2.0.3.0
      Oracle Database Vault J2EE Application 11.2.0.3.0
      Oracle Label Security 11.2.0.3.0
      Oracle Data Mining RDBMS Files 11.2.0.3.0
      Oracle OLAP RDBMS Files 11.2.0.3.0
      Oracle OLAP API 11.2.0.3.0
      Platform Required Support Files 11.2.0.3.0
      Oracle Database Vault option 11.2.0.3.0
      Oracle RAC Required Support Files-HAS 11.2.0.3.0
      SQL*Plus Required Support Files 11.2.0.3.0
      Oracle Display Fonts 9.0.2.0.0
      Oracle Ice Browser 5.2.3.6.0
      Oracle JDBC Server Support Package 11.2.0.3.0
      Oracle SQL Developer 11.2.0.3.0
      Oracle Application Express 11.2.0.3.0
      XDK Required Support Files 11.2.0.3.0
      RDBMS Required Support Files for Instant Client 11.2.0.3.0
      SQLJ Runtime 11.2.0.3.0
      Database Workspace Manager 11.2.0.3.0
      RDBMS Required Support Files Runtime 11.2.0.3.0
      Oracle Globalization Support 11.2.0.3.0
      Exadata Storage Server 11.2.0.1.0
      Provisioning Advisor Framework 10.2.0.4.3
      Enterprise Manager Database Plugin -- Repository Support 11.2.0.3.0
      Enterprise Manager Repository Core Files 10.2.0.4.4
      Enterprise Manager Database Plugin -- Agent Support 11.2.0.3.0
      Enterprise Manager Grid Control Core Files 10.2.0.4.4
      Enterprise Manager Common Core Files 10.2.0.4.4
      Enterprise Manager Agent Core Files 10.2.0.4.4
      RDBMS Required Support Files 11.2.0.3.0
      regexp 2.1.9.0.0
      Agent Required Support Files 10.2.0.4.3
      Oracle 11g Warehouse Builder Required Files 11.2.0.3.0
      Oracle Notification Service (eONS) 11.2.0.3.0
      Oracle Text Required Support Files 11.2.0.3.0
      Parser Generator Required Support Files 11.2.0.3.0
      Oracle Database 11g Multimedia Files 11.2.0.3.0
      Oracle Multimedia Java Advanced Imaging 11.2.0.3.0
      Oracle Multimedia Annotator 11.2.0.3.0
      Oracle JDBC/OCI Instant Client 11.2.0.3.0
      Oracle Multimedia Locator RDBMS Files 11.2.0.3.0
      Precompiler Required Support Files 11.2.0.3.0
      Oracle Core Required Support Files 11.2.0.3.0
      Sample Schema Data 11.2.0.3.0
      Oracle Starter Database 11.2.0.3.0
      Oracle Message Gateway Common Files 11.2.0.3.0
      Oracle XML Query 11.2.0.3.0
      XML Parser for Oracle JVM 11.2.0.3.0
      Oracle Help For Java 4.2.9.0.0
      Installation Plugin Files 11.2.0.3.0
      Enterprise Manager Common Files 10.2.0.4.3
      Expat libraries 2.0.1.0.1
      Deinstallation Tool 11.2.0.3.0
      Oracle Quality of Service Management (Client) 11.2.0.3.0
      Perl Modules 5.10.0.0.1
      JAccelerator (COMPANION) 11.2.0.3.0
      Oracle Containers for Java 11.2.0.3.0
      Perl Interpreter 5.10.0.0.2
      Oracle Net Required Support Files 11.2.0.3.0
      Secure Socket Layer 11.2.0.3.0
      Oracle Universal Connection Pool 11.2.0.3.0
      Oracle JDBC/THIN Interfaces 11.2.0.3.0
      Oracle Multimedia Client Option 11.2.0.3.0
      Oracle Java Client 11.2.0.3.0
      Character Set Migration Utility 11.2.0.3.0
      Oracle Code Editor 1.2.1.0.0I
      PL/SQL Embedded Gateway 11.2.0.3.0
      OLAP SQL Scripts 11.2.0.3.0
      Database SQL Scripts 11.2.0.3.0
      Oracle Locale Builder 11.2.0.3.0
      Oracle Globalization Support 11.2.0.3.0
      SQL*Plus Files for Instant Client 11.2.0.3.0
      Required Support Files 11.2.0.3.0
      Oracle Database User Interface 2.2.13.0.0
      Oracle ODBC Driver 11.2.0.3.0
      Oracle Notification Service 11.2.0.3.0
      XML Parser for Java 11.2.0.3.0
      Oracle Security Developer Tools 11.2.0.3.0
      Oracle Wallet Manager 11.2.0.3.0
      Cluster Verification Utility Common Files 11.2.0.3.0
      Oracle Clusterware RDBMS Files 11.2.0.3.0
      Oracle UIX 2.2.24.6.0
      Enterprise Manager plugin Common Files 11.2.0.3.0
      HAS Common Files 11.2.0.3.0
      Precompiler Common Files 11.2.0.3.0
      Installation Common Files 11.2.0.3.0
      Oracle Help for the  Web 2.0.14.0.0
      Oracle LDAP administration 11.2.0.3.0
      Buildtools Common Files 11.2.0.3.0
      Assistant Common Files 11.2.0.3.0
      Oracle Recovery Manager 11.2.0.3.0
      PL/SQL 11.2.0.3.0
      Generic Connectivity Common Files 11.2.0.3.0
      Oracle Database Gateway for ODBC 11.2.0.3.0
      Oracle Programmer 11.2.0.3.0
      Oracle Database Utilities 11.2.0.3.0
      Enterprise Manager Agent 10.2.0.4.3
      SQL*Plus 11.2.0.3.0
      Oracle Netca Client 11.2.0.3.0
      Oracle Multimedia Locator 11.2.0.3.0
      Oracle Call Interface (OCI) 11.2.0.3.0
      Oracle Multimedia 11.2.0.3.0
      Oracle Net 11.2.0.3.0
      Oracle XML Development Kit 11.2.0.3.0
      Database Configuration and Upgrade Assistants 11.2.0.3.0
      Oracle JVM 11.2.0.3.0
      Oracle Advanced Security 11.2.0.3.0
      Oracle Internet Directory Client 11.2.0.3.0
      Oracle Enterprise Manager Console DB 11.2.0.3.0
      HAS Files for DB 11.2.0.3.0
      Oracle Net Listener 11.2.0.3.0
      Oracle Text 11.2.0.3.0
      Oracle Net Services 11.2.0.3.0
      Oracle Database 11g 11.2.0.3.0
      Oracle OLAP 11.2.0.3.0
      Oracle Spatial 11.2.0.3.0
      Oracle Partitioning 11.2.0.3.0
      Enterprise Edition Options 11.2.0.3.0
-----------------------------------------------------------------------------


Instantiating scripts for add node (Tuesday, October 4, 2016 1:07:48 PM ICT)
.                                                                 1% Done.
Instantiation of add node scripts complete

Copying to remote nodes (Tuesday, October 4, 2016 1:07:55 PM ICT)
...............................................................................................                                 96% Done.
Home copied to new nodes

Saving inventory on nodes (Tuesday, October 4, 2016 1:31:16 PM ICT)
.                                                               100% Done.
Save inventory complete
WARNING:
The following configuration scripts need to be executed as the "root" user in each new cluster node. Each script in the list below is followed by a list of nodes.
/oracle/product/11.2.0.3/dbhome_1/root.sh #On nodes dbnode1
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts in each cluster node
   
The Cluster Node Addition of /oracle/product/11.2.0.3/dbhome_1 was successful.
Please check '/tmp/silentInstall.log' for more details.

=========
dbnode1=
=========
# /oracle/product/11.2.0.3/dbhome_1/root.sh
Performing root user operation for Oracle 11g

The following environment variables are set as:
    ORACLE_OWNER= pitraib
    ORACLE_HOME=  /oracle/product/11.2.0.3/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

=========
dbnode1=
=========
$ ps -ef|grep smon
root     20143     1  0 11:19 ?        00:02:38 /oracle/11.2.0.3/grid/bin/osysmond.bin
oracle   20277     1  0 11:19 ?        00:00:00 asm_smon_+ASM1
oracle   32192 32003  0 16:19 pts/0    00:00:00 grep smon
$ echo $ORACLE_SID
orcldb1
$ cd $ORACLE_HOME
$ cd dbs
$ ls -l
total 16
-rw-rw----    1 pitraib  oinstall       1544 Oct 04 08:31 hc_orcldb2.dat
-rw-rw----    1 pitraib  oinstall       1544 May 28 2014  hc_ROTEST12.dat
-rw-rw----    1 pitraib  oinstall       1544 May 28 2014  hc_ROTEST22.dat
-rw-r--r--    1 pitraib  oinstall       2851 Dec 12 2013  init.ora
-rw-r--r--    1 pitraib  oinstall         37 Dec 01 2015  initorcldb2.ora
-rw-r-----    1 pitraib  oinstall       5120 Aug 16 16:00 orapworcldb2
-rw-r-----    1 pitraib  oinstall       5120 Aug 16 15:59 orapworcldb2.16082016
-rw-r-----    1 pitraib  oinstall       5120 Apr 04 2016  orapworcldb2.20160404
-rw-r-----    1 pitraib  oinstall       2560 Aug 20 2014  orapworcldb2.bk
-rw-r-----    1 pitraib  oinstall       5120 Jun 10 14:46 orapworcldb210062016
-rw-r-----    1 pitraib  oinstall   14663680 May 20 00:02 snapcf_orcldb2.f
-rw-r-----    1 pitraib  oinstall    7716864 May 28 2014  snapcf_ROTEST22.f
$ mv orapworcldb2 orapworcldb1
$ mv initorcldb2.ora initorcldb1.ora
$
$ rm hc_orcldb2.dat hc_ROTEST12.dat hc_ROTEST22.dat orapworcldb2.16082016
$ rm orapworcldb2.20160404 orapworcldb2.bk orapworcldb210062016 snapcf_orcldb2.f snapcf_ROTEST22.f
$
$ mkdir -p /oracle/product/admin/orcldb/adump
orapki wallet create -wallet "/oracle/product/admin/orcldb1/wallet" -auto_login_local
$ sqlplus / as sysdba
SQL> startup
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size                  2228904 bytes
Variable Size            1107299672 bytes
Database Buffers          536870912 bytes
Redo Buffers                7118848 bytes
Database mounted.
Database opened.
SQL>

$ crsctl stat res -t



Good Luck !!!!


Followers