Translate into your own language

Showing posts with label Recovery. Show all posts
Showing posts with label Recovery. Show all posts

Tuesday, October 31, 2017

Step by step - What is restore point, how to create and use it with example

Use named points in time to roll your database back by using flashback technology
Jane, the lead DBA at Acme Bank, has three visitors today. The first, Paul, is the head of Quality Assurance. Paul's team creates a variety of test scenarios for the applications. For each scenario, they put together the test data, and after they run each test, they need to modify the data to bring back the pretest values.
The second visitor is Tom, the operations manager. Tom is responsible for processing batch financial transaction files from each branch of the bank. If the file from a branch produces an error, the entire process is aborted and must be started from the beginning.
The third visitor is Harry, a business manager of an application developed by a third-party vendor. Harry gets updates from the vendor to modify the database structure, modify data, and so on, as part of the application upgrade process. Most upgrades go smoothly; however, when an upgrade fails, things get messy. Harry's team spends considerable time devising ways to undo failed changes.
Paul, Tom, and Harry are asking Jane to help make their processes more efficient. Jane assures them that she has a solution. Fortunately, Acme is using Oracle Database 10g Release 2, and it is possible to "rewind" the database to a named point in time.

Setup

Jane sits her visitors down and reminds them all of how it's possible to turn back the hands of time and reinstate the database to a certain point in time using a simple command: flashback database. In Oracle Database 10g Release 2, Jane says, the functionality is now enhanced significantly by the ability to name a specific point in time, called a restore point . Using this, Paul, Tom, or Harry (or a DBA acting on their behalf) can mark and flash back the database to a logical point in time.
Jane starts a demonstration on a test database. She notes that the database must be running in archivelog mode and with flashback logging enabled. She first shuts down the database and then brings it up in mounted mode. 
shutdown immediate;
startup mount;

Then she converts the database to run in archivelog mode. 
alter database archivelog;

To enable flashback, Jane first configures two parameters in the database. 
alter system set db_recovery_file_dest_size = 2G;
alter system set db_recovery_file_dest = '/u02/flashbackarea/acmeprd';

In flashback mode, the database creates flashback log files, which record the old images of the data after a change is made. These files are kept in the location specified by the db_recovery_file_dest parameter, up to the size specified by the db_recovery_file_dest_size parameter, which in this case is set to 2GB.
Jane then enables flashback logging: 
alter database flashback on;

She opens the database: 
alter database open;

She checks the status of the archive log mode and flashback: 
select flashback_on, log_mode
from v$database;

FLASHBACK_ON  LOG_MODE
------------  ----------------
YES           ARCHIVELOG

This confirms that the database is indeed in flashback mode.

Restore Points

Jane proceeds to demonstrate how to use restore points, starting with an example of how Paul's QA team can benefit from this technique. Jane creates a restore point named qa_gold. 
create restore point qa_gold;

This command, Jane reminds them, is new in Oracle Database 10g Release 2. It creates a named restore point, which is an alias to the system change number (SCN) of the database at that time.
Jane runs one of the QA team's tests, altering the test data. To flash back the database to the restore point she created, Jane shuts down the database, restarts it in mounted mode, and issues the flashback database command. 
shutdown immediate;
startup mount;
flashback database to restore point qa_gold;

That's it; the database is now "rewound" to the restore point named qa_gold. There was no need for Jane to back up the database and perform a point-in-time recovery. Paul couldn't be happier.
For Tom, Jane demonstrates a slightly different approach. Since Tom runs the batch process on one file at a time, Jane suggests creating a restore point after processing each file with some predetermined naming convention, for example, after_branch_ n , where n is the BRANCH_ID.
To keep track of the files being processed, Tom has a table—PROC—with only one column—BRANCH_ID, which stores the id of the branch whose file has been processed. Jane runs through the following process as an example of a typical batch run using restore points:
1. She creates a restore point named start_batch to mark the start of the process. 
create restore point start_batch;

2. She updates the PROC table to specify the branch being processed. 
update proc set branch_id = 1;
commit;

3. She processes the file from branch 1.
4. After the branch 1 file is processed, she creates a new restore point. 
create restore point after_branch_1;

The process is repeated until the files from all branches are processed.
Jane demonstrates the restore process to use if a file from branch 23 has an error. When the file from branch 23 is picked up for processing, the BRANCH_ID value in the PROC table will be 23. 
SQL> select branch_id from proc;
 
BRANCH_ID
---------
       23

If the processing fails for the file from branch 23, Jane rolls back the changes to the after_branch_22 restore point. 
shutdown immediate;
startup mount;
flashback database to restore point 
after_branch_22;
alter database open;

To confirm that the flashback succeeded, she checks the PROC table again. 
SQL> select branch_id from proc;
 
BRANCH_ID
---------
       22

The value of the column is 22, for the branch file one prior to the creation of the restore point. All changes made to the database after the creation of this restore point are undone.
Sometimes, the file from a branch fails but that is not known until much later. For instance, the branch 23 file processing may have failed, but that is not discovered until the processing of branch 29. Jane assures Tom that whether he's processing the branch 23 file, the branch 29 file, or any file in between, he can easily roll back to the after_branch_22 restore point.
In response to Harry's application update issue, Jane suggests a solution very similar to Paul's. Just prior to the database update, Harry or a DBA would create a restore point named pre_change. If the application update is not successful, all that Harry or the DBA needs to do is to flash back the database to that restore point using the flashback commands she demonstrated earlier.

Guaranteed Restore Point

Paul, Tom, and Harry leave Jane's office and go back to their respective departments to test their restore-point solutions.
A few hours later, Tom returns to Jane's office with an error message. When he tried to flash back to a restore point, he got this error:

ORA-38729: Not enough flashback 
database log data to do FLASHBACK.

As the error shows, there are insufficient flashback logs to flash back the database to the restore point. Jane's explanation is simple—the flashback logs are kept up to the time specified by the db_flashback_retention_target database parameter.
Older logs are not automatically deleted; however, the maximum size of the flash recovery area is determined by the db_recovery_file_dest_size database parameter, which is 2GB in this case. When Tom's flash recovery area fills up to 2GB, Oracle Database must remove some logs older than 1,440 seconds to make room for the new ones. So, when Tom wanted to perform flashback, the logs needed for the selected restore point were aged out, and that caused the error.
Tom asks if— because the flashback logs will age out—there is any guarantee that he would be able to flash back to a particular restore point.
Jane assures him that he can guarantee that the logs he needs for a particular restore point are available by creating a guaranteed restore point. Jane shows Tom how to create a guaranteed restore point: 
create restore point after_branch_22 
guarantee flashback database;

This ensures that it is definitely possible to flash back the database to the after_branch_22 restore point. Oracle Database does not age out the old flashback logs required for this restore point.

Administration

After successfully addressing Tom's question, Jane calls in her DBAs to make sure they understand how to administer the restore points. First she shows them the query to find out how many restore points have been created: 
select * from v$restore_point 
order by scn;

The output is shown in Listing 1. Noting the output, Jane describes the columns. NAME is the name of the restore point; SCN and TIME are the SCN and the time stamp (in extended format) when the restore point was created, respectively; GUARANTEE_FLASHBACK_DATABASE (shown partially as "GUA") indicates whether it's a guaranteed restore point; STORAGE_SIZE indicates the storage used by this restore point (it is non-zero only in case of guaranteed restore point). Finally, DATABASE_INCARNATION# indicates the incarnation of the database when this restore point was created. If the database was flashed back and then opened with resetlogs, it creates a new incarnation of the database.
Code Listing 1: Output of V$RESTORE_POINT 
SCN      DATABASE_INCARNATION# GUA  STORAGE_SIZE TIME                            NAME
-------- --------------------- ---- ------------ ------------------------------- ------------
14390197 6                     NO   0            01-AUG-06 01.12.27.000000000 PM QA_GOLD
24390219 6                     NO   0            01-AUG-06 02.13.16.000000000 PM AFTER_BRANCH_1
34390232 6                     NO   0            01-AUG-06 03.13.34.000000000 PM AFTER_BRANCH_2
44390243 6                     NO   0            01-AUG-06 04.13.49.000000000 PM AFTER_BRANCH_3
54394187 7                     YES  3981312      02-AUG-06 05.35.19.000000000 AM AFTER_BRANCH_4

When restore points are not needed anymore, Jane continues, you DBAs can delete them. She issues the following command to delete the after_branch_1 restore point: 
drop restore point after_branch_1;

Conclusion

Using restore points, DBAs can mark a location in time, which can then be used to rewind and fast-forward the database to a specific location. Although restore points are very helpful in recovering the database quickly from user errors, they also have other excellent uses. Table 1 summarizes various scenarios and how to resolve them by using restore points.
Table 1: Opportunities for restore points
ScenarioSolution
Batch programs may inadvertently cause issues in the database, which might require point-in-time recovery of the database before other batch programs can run.Create a restore point prior to each batch run. In case of issues, flash the database back to the restore point.
Database schema upgrades and application deployments requiring extensive schema changes might fail, resulting in an inconsistent database which may need point-in-time recovery.Create a restore point prior to the deployment. Flash the database back to that restore point in case the deployment fails.
QA team carefully creates test data, but after the test runs, the data is modified and needs to be recreated before the next test can run.Create a restore point before the first test. Flash the database back to that restore point after each test.

Wednesday, July 13, 2016

Scenario - Recovering from wrongly added datafile in system tablespace to default dbs location in ASM environment

Recently while adding a datafile to system tablespace, one of our dba's made a mistake by inserting a white space in between "quote" and "plus" sign in ASM aware environment. Since it was a production we had to restore this wrongly added datafile to the ASM location as soon as possible.

We reproduced this issue in one of our test environment.


Steps to reproduce the issue:

[oracle@dbstnd ~]$ ps -ef | grep pmon
grid     18985     1  0 00:08 ?        00:00:00 asm_pmon_+ASM
oracle   28511     1  0 01:41 ?        00:00:00 ora_pmon_TEST
oracle   28983 28923  0 01:53 pts/5    00:00:00 grep --color=auto pmon

[oracle@dbstnd ~]$ . oraenv
ORACLE_SID = [TEST] ?
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@dbstnd ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 13 01:53:51 2016

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


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


SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
TEST             OPEN

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2

SQL> select name from v$datafile;

NAME
----------------------------------------------------------------------
+DATA/test/system01.dbf
+DATA/test/sysaux01.dbf
+DATA/test/undotbs01.dbf
+DATA/test/users01.dbf

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
[oracle@dbstnd ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jul 13 01:56:19 2016

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

connected to target database: TEST (DBID=2215202024)

RMAN>  backup database plus archivelog;


Starting backup at 13-JUL-16
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=46 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=917056597
channel ORA_DISK_1: starting piece 1 at 13-JUL-16
channel ORA_DISK_1: finished piece 1 at 13-JUL-16
piece handle=+DATA/test/backupset/2016_07_13/annnf0_tag20160713t015637_0.268.917056599 tag=TAG20160713T015637 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-JUL-16

Starting backup at 13-JUL-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/test/system01.dbf
input datafile file number=00002 name=+DATA/test/sysaux01.dbf
input datafile file number=00003 name=+DATA/test/undotbs01.dbf
input datafile file number=00004 name=+DATA/test/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-JUL-16
channel ORA_DISK_1: finished piece 1 at 13-JUL-16
piece handle=+DATA/test/backupset/2016_07_13/nnndf0_tag20160713t015639_0.269.917056599 tag=TAG20160713T015639 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 13-JUL-16
channel ORA_DISK_1: finished piece 1 at 13-JUL-16
piece handle=+DATA/test/backupset/2016_07_13/ncsnf0_tag20160713t015639_0.270.917056625 tag=TAG20160713T015639 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-JUL-16

Starting backup at 13-JUL-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=3 RECID=2 STAMP=917056626
channel ORA_DISK_1: starting piece 1 at 13-JUL-16
channel ORA_DISK_1: finished piece 1 at 13-JUL-16
piece handle=+DATA/test/backupset/2016_07_13/annnf0_tag20160713t015706_0.272.917056627 tag=TAG20160713T015706 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-JUL-16

RMAN> restore database preview;

Starting restore at 13-JUL-16
using channel ORA_DISK_1


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    1014.30M   DISK        00:00:16     13-JUL-16
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20160713T015639
        Piece Name: +DATA/test/backupset/2016_07_13/nnndf0_tag20160713t015639_0.269.917056599
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 931310     13-JUL-16 +DATA/test/system01.dbf
  2       Full 931310     13-JUL-16 +DATA/test/sysaux01.dbf
  3       Full 931310     13-JUL-16 +DATA/test/undotbs01.dbf
  4       Full 931310     13-JUL-16 +DATA/test/users01.dbf

List of Archived Log Copies for database with db_unique_name TEST
=====================================================================

Key     Thrd Seq     S Low Time
------- ---- ------- - ---------
2       1    3       A 13-JUL-16
        Name: +DATA/test/archivelog/2016_07_13/thread_1_seq_3.271.917056627

Media recovery start SCN is 931310
Recovery must be done beyond SCN 931310 to clear datafile fuzziness
Finished restore at 13-JUL-16

[oracle@dbstnd ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 13 02:00:02 2016

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


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

SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS


Here we added a datafile with white space.

SQL> ALTER TABLESPACE "SYSTEM" ADD DATAFILE ' +DATA' SIZE 100M;

Tablespace altered.


Now we can see it has been added to the default location of Oracle_home/dbs. Since everything that will use this datafile have to throw an error and our backps were also regurlay failing because of this.

SQL> select name from v$datafile;

NAME
----------------------------------------------------------------------
+DATA/test/system01.dbf
+DATA/test/sysaux01.dbf
+DATA/test/undotbs01.dbf
+DATA/test/users01.dbf
/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/ +DATA

SQL> select file_name,file_id from dba_data_files where tablespace_name='SYSTEM';

FILE_NAME FILE_ID
----------------------------------------------------------------------
+DATA/test/system01.dbf        1
/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/ +DATA  5


SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options


[oracle@dbstnd ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 13 02:09:44 2016

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

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area  730714112 bytes
Fixed Size                  2256832 bytes
Variable Size             482345024 bytes
Database Buffers          243269632 bytes
Redo Buffers                2842624 bytes
Database mounted.
SQL>

++ Open a new session:
---------------------
[oracle@dbstnd ~]$ . oraenv
ORACLE_SID = [oracle] ? TEST
The Oracle base has been set to /u01/app/oracle
[oracle@dbstnd ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jul 13 02:11:09 2016

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

connected to target database: TEST (DBID=2215202024, not open)


RMAN> copy datafile 5 to '+DATA';

Starting backup at 13-JUL-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/product/11.2.0.4/dbhome_1/                                                                                        dbs/ +DATA
output file name=+DATA/test/datafile/system.273.917057511 tag=TAG20160713T021150                                                                                         RECID=1 STAMP=917057510
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 13-JUL-16


RMAN> switch datafile 5 to copy;

datafile 5 switched to datafile copy "+DATA/test/datafile/system.273.917057511"

Then open the database which is mounted:
---------------------------------------
SQL> alter database open;

Database altered.


SQL> select file_name,file_id from dba_data_files where tablespace_name='SYSTEM';

FILE_NAME FILE_ID
----------------------------------------------------------------------
+DATA/test/system01.dbf 1
+DATA/test/datafile/system.273.917057511 5

Thursday, June 23, 2016

Recovering from loss of all online redolog files in Oracle

According to standard practice, we should consider multiplexing of online redo log files to avoid such a scenarios, Each log file group should have more than/at least 2 log file members & location of all group on different physical disk. ( In case of worst situation with disk 1 then database would be recovery with the help of disk 2 – Online redo log file ) Single current online redo log file is sufficient to restore the entire database & do an incomplete recovery.

Please consider following hands-on to demonstrate recovery of loss of online redolog files by deleting all the online redo log files at the OS level:

At SQL prompt, Ensure the online redo log members by issuing the following query:
SQL> select member from v$Logfile;

MEMBER
——————————————————————————–
/home/oracle/app/oracle/oradata/orcl/redo03.log
/home/oracle/app/oracle/oradata/orcl/redo02.log
/home/oracle/app/oracle/oradata/orcl/redo01.log


Let’s Delete/Remove all online redo log file to simulate mentioned scenario:
[root@oracle orcl]# pwd
/home/oracle/app/oracle/oradata/orcl
[root@oracle orcl]# mv redo01.log redo01.log.back
[root@oracle orcl]# mv redo02.log redo02.log.back
[root@oracle orcl]# mv redo03.log redo03.log.back

In case of current online redo log file is lost, the database will be no more in use & aleartlog file shows oracle error: ORA-00313, ORA-00312, ORA-27037 as below:

Note: We are monitoring alert log message with the help of ADRCI Prompt.

[oracle@oracle ~]$ adrci
ADRCI: Release 11.2.0.1.0 – Production on Mon Jan 20 07:30:12 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

ADR base = “/home/oracle/app/oracle”
adrci> show home
ADR Homes:
diag/rdbms/orcl/orcl
diag/rdbms/catalogdb/catalogdb
diag/tnslsnr/centos/listener
diag/tnslsnr/oracle/listener
adrci> set home diag/rdbms/orcl/orcl
adrci> show alert -tail -f

2014-01-20 07:35:21.744000 +00:00
Thread 1 advanced to log sequence 44 (LGWR switch)
Current log# 2 seq# 44 mem# 0: /home/oracle/app/oracle/oradata/orcl/redo02.log
2014-01-20 07:35:22.847000 +00:00
Errors in file /home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_arc3_10148.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: ‘/home/oracle/app/oracle/oradata/orcl/redo01.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
-X-

With the help of RMAN, we can recover from this situation by restoring the database from the RMAN backup. ( Up-to last available archived redo logfile )
Ensure current sequence of online redolog file by issuing the following sql command:

SQL> select * from v$Log;

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
———- ———- ———- ———- ———- ———- — —————- ————- ——— ———— ———
1 1 43 52428800 512 1 NO INACTIVE 1877247 20-JAN-14 1881537 20-JAN-14
2 1 44 52428800 512 1 NO CURRENT 1881537 20-JAN-14 2.8147E+14
3 1 42 52428800 512 1 YES INACTIVE 1863081 19-JAN-14 1877247 20-JAN-14

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch
Oldest online log sequence 42
Next log sequence to archive 43
Current log sequence 44

Shutdown target database:
SQL> shutdown immediate;

Startup database in mount mode.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 308981760 bytes
Fixed Size 2212896 bytes
Variable Size 197135328 bytes
Database Buffers 104857600 bytes
Redo Buffers 4775936 bytes
Database mounted.


Connect to the target database using RMAN with the help of recovery owner as below:

Use following RMAN commands to recover all online redo log file members:

[oracle@oracle ~]$ rman target / catalog recoveryman/recoveryman@catalogdb

RMAN> run { set until sequence 43; restore database; recover database; alter database open resetlogs; }

executing command: SET until clause

Starting restore at 20-JAN-14
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/data/user1.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2014_01_13/o1_mf_nnndf_TAG20140113T101908_9f7hdwz0_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2014_01_13/o1_mf_nnndf_TAG20140113T101908_9f7hdwz0_.bkp tag=TAG20140113T101908
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:06
Finished restore at 20-JAN-14

Starting recover at 20-JAN-14
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 27 is already on disk as file /home/oracle/arch/1_27_835799980.dbf
archived log for thread 1 with sequence 28 is already on disk as file /home/oracle/arch/1_28_835799980.dbf
archived log for thread 1 with sequence 29 is already on disk as file /home/oracle/arch/1_29_835799980.dbf
archived log for thread 1 with sequence 30 is already on disk as file /home/oracle/arch/1_30_835799980.dbf
archived log for thread 1 with sequence 31 is already on disk as file /home/oracle/arch/1_31_835799980.dbf
archived log for thread 1 with sequence 32 is already on disk as file /home/oracle/arch/1_32_835799980.dbf
archived log for thread 1 with sequence 33 is already on disk as file /home/oracle/arch/1_33_835799980.dbf
archived log for thread 1 with sequence 34 is already on disk as file /home/oracle/arch/1_34_835799980.dbf
archived log for thread 1 with sequence 35 is already on disk as file /home/oracle/arch/1_35_835799980.dbf
archived log for thread 1 with sequence 36 is already on disk as file /home/oracle/arch/1_36_835799980.dbf
archived log for thread 1 with sequence 37 is already on disk as file /home/oracle/arch/1_37_835799980.dbf
archived log for thread 1 with sequence 38 is already on disk as file /home/oracle/arch/1_38_835799980.dbf
archived log for thread 1 with sequence 39 is already on disk as file /home/oracle/arch/1_39_835799980.dbf
archived log for thread 1 with sequence 40 is already on disk as file /home/oracle/arch/1_40_835799980.dbf
archived log for thread 1 with sequence 41 is already on disk as file /home/oracle/arch/1_41_835799980.dbf
archived log for thread 1 with sequence 42 is already on disk as file /home/oracle/arch/1_42_835799980.dbf
archived log file name=/home/oracle/arch/1_27_835799980.dbf thread=1 sequence=27
archived log file name=/home/oracle/arch/1_28_835799980.dbf thread=1 sequence=28
archived log file name=/home/oracle/arch/1_29_835799980.dbf thread=1 sequence=29
archived log file name=/home/oracle/arch/1_30_835799980.dbf thread=1 sequence=30
archived log file name=/home/oracle/arch/1_31_835799980.dbf thread=1 sequence=31
archived log file name=/home/oracle/arch/1_32_835799980.dbf thread=1 sequence=32
archived log file name=/home/oracle/arch/1_33_835799980.dbf thread=1 sequence=33
archived log file name=/home/oracle/arch/1_34_835799980.dbf thread=1 sequence=34
archived log file name=/home/oracle/arch/1_35_835799980.dbf thread=1 sequence=35
archived log file name=/home/oracle/arch/1_36_835799980.dbf thread=1 sequence=36
archived log file name=/home/oracle/arch/1_37_835799980.dbf thread=1 sequence=37
archived log file name=/home/oracle/arch/1_38_835799980.dbf thread=1 sequence=38
archived log file name=/home/oracle/arch/1_39_835799980.dbf thread=1 sequence=39
archived log file name=/home/oracle/arch/1_40_835799980.dbf thread=1 sequence=40
archived log file name=/home/oracle/arch/1_41_835799980.dbf thread=1 sequence=41
archived log file name=/home/oracle/arch/1_42_835799980.dbf thread=1 sequence=42
media recovery complete, elapsed time: 00:02:17
Finished recover at 20-JAN-14

database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>

Database has been open successfully with creation of all online redo log file members.

Ensure online redo log-files has been generated through RMAN recovery at OS level.
Since we did incomplete recovery, we should consider new/fresh backup after this activity.

Recovering from loss of Control file scenario's in Oracle

A Control file is a small binary file that is part of an Oracle database. The control file is used to keep       track of the database's status and physical structure. The control file is absolutely crucial to database operation . Here , we will discuss the various scenario's when control file(s) get lost or corrupt.


CASE 1 : If one of the controlfile get lost or corrupted 

when the database is shut down and on  startup we get the following error due to loss of controlfile.


C:\>sqlplus sys/xxxx@noida as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Apr 18 15:41:33 2011

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

Connected to an idle instance.


SQL> startup

ORACLE instance started.

Total System Global Area  318046208 bytes

Fixed Size                  1332920 bytes

Variable Size             239077704 bytes

Database Buffers           71303168 bytes

Redo Buffers                6332416 bytes

ORA-00205: error in identifying control file, check alert log for more info 


Checked the Alert log file and the following information are in  the alert log file.

ALTER DATABASE   MOUNT

Mon Apr 18 15:42:12 2011

ORA-00210: cannot open the specified control file

ORA-00202: control file: 'D:\ORACLE\ORADATA\NOIDA\CONTROL02.CTL'

ORA-27041: unable to open file

OSD-04002: unable to open file

O/S-Error: (OS 2) The system cannot find the file specified.

Mon Apr 18 15:42:14 2011

Checker run found 1 new persistent data failures

ORA-205 signalled during: ALTER DATABASE   MOUNT


To solve this issue, copy one of the existing control file (say control01.ctl or control03.ctl ) and paste it where the missing  control file was earlier residing and rename the controlfile which one is missing, as in above example, control file (CONTROL02.CTL) is missing and then following the below steps:


SQL> alter database mount;

Database altered.


SQL> alter database open;

Database altered.


SQL> select name,open_mode from v$database ;

NAME          OPEN_MODE

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

NOIDA          READ WRITE


CASE  2:  When all the controlfile are lost 

If  we  have  valid  backup and  if  all  the  control files  are  lost  then  we  can  recover  the control  files from autobackup of controlfile or by specifying the location of autobackup control file.


C:\>sqlplus sys/xxxx@noida as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Apr 18 16:21:55 2011

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> startup nomount

ORACLE instance started.

Total System Global Area  318046208 bytes

Fixed Size                  1332920 bytes

Variable Size             272632136 bytes

Database Buffers           37748736 bytes

Redo Buffers                6332416 bytes


SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


C:\>rman target sys/xxxx@noida


Recovery Manager: Release 11.1.0.6.0 - Production on Mon Apr 18 16:33:34 2011

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

connected to target database: NOIDA (not mounted)


RMAN> restore controlfile from 'D:\orcl_bkp\cf\C-1502483083-20110418-01';  (location of controlfile)

Starting restore at 18-APR-11

using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

output file name=D:\ORACLE\ORADATA\NOIDA\CONTROL01.CTL

output file name=D:\ORACLE\ORADATA\NOIDA\CONTROL02.CTL

output file name=D:\ORACLE\ORADATA\NOIDA\CONTROL03.CTL

Finished restore at 18-APR-11


RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1


RMAN> recover database;

Starting recover at 18-APR-11

Starting implicit crosscheck backup at 18-APR-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=153 device type=DISK

Crosschecked 7 objects

Finished implicit crosscheck backup at 18-APR-11

Starting implicit crosscheck copy at 18-APR-11

using channel ORA_DISK_1

Finished implicit crosscheck copy at 18-APR-11

searching for all files in the recovery area

cataloging files...

no files cataloged

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 19 is already on disk as file D:\ORACLE\ORADATA\NOIDA\RE

archived log file name=D:\ORACLE\ORADATA\NOIDA\REDO01.LOG thread=1 sequence=19

media recovery complete, elapsed time: 00:00:05

Finished recover at 18-APR-11


RMAN> alter database open resetlogs;

database opened


CASE 3 :   When we donot have any backup and and all control files are lost or corrupted


SQL> startup nomount

ORACLE instance started.

Total System Global Area  318046208 bytes

Fixed Size                  1332920 bytes

Variable Size             281020744 bytes

Database Buffers           29360128 bytes

Redo Buffers                6332416 bytes


Now we create the controlfile manually on command prompt 


SQL> CREATE CONTROLFILE REUSE DATABASE  "NOIDA"   NORESETLOGS archivelog

MAXLOGFILES 5

MAXLOGMEMBERS 3

MAXDATAFILES 10

MAXINSTANCES 1

MAXLOGHISTORY 113

LOGFILE

GROUP 1 'D:\oracle\oradata\noida\REDO01.LOG' SIZE 50M,

GROUP 2 'D:\oracle\oradata\noida\REDO02.LOG' SIZE 50M,

GROUP 3 'D:\oracle\oradata\noida\REDO03.LOG' SIZE 50M

DATAFILE

'D:\oracle\oradata\noida\SYSTEM01.DBF' ,

'D:\oracle\oradata\noida\USERS01.DBF' ,

'D:\oracle\oradata\noida\EXAMPLE01.DBF' ,

'D:\oracle\oradata\noida\SYSAUX01.DBF' ,

'D:\oracle\oradata\noida\TRANS.DBF' ,

'D:\oracle\oradata\noida\UNDOTBS01.DBF'   ;

Control file created.


SQL> archive log list

Database log mode                              Archive Mode

Automatic archival                               Disabled

Archive destination                              D:\archive\

Oldest online log sequence                  1

Next log sequence to archive              1

Current log sequence                          1


SQL> select first_change# ,group# from v$log;

FIRST_CHANGE#     GROUP#

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

      1313491          1

            0                3

            0               2


SQL> alter database open;


SQL> select name,open_mode from v$database;

NAME      OPEN_MODE

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

NOIDA     READ WRITE