Oracle Technologies Blog

By ASKM

Archive for the ‘RMAN’ Category

How To Restore Database From Different Incarnation

Posted by Srikrishna Murthy Annam on April 4, 2013

What is incarnation?
When we open database with RESETLOGS option, the database starts a new incarnation. This new incarnation resets the log sequence number to 1, and then gives the online redo logs a new time stamp and SCN.

When the database starts a new incarnation, are we able to use the old backups taken in previous incarnation for restore and recovery purpose as the present log sequence number is reset to 1.

The present article discusses about the details of how to use the backups in old incarnation for restore and recovery purpose after the database has been opened with resetlogs for many times.

I will explain the details considering a practical approach in our training environment. First i will explain the existing environment and available backups.
Then i will take you to details of how these backups are used to restore and recover to the same server (or to different server) considering that the database has been opened many times with resetlogs option.

Environment Details :
Let us assume that we have a training environment where we have some gold backups for the database. Whenever we do any modification to the database, we will take a new goldbackup and we will keep restoring this latest new backup every week twice( Thursday night and Saturday night).

Following Details shows the different goldbackups available for the training environment.

RMAN> list backup summary;List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
——- — — – ———– ————— ——- ——- ———- —
327559  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327560  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327561  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327562  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327785  B  F  A SBT_TAPE    04-AUG-12       1       1       NO         NOEXPIRE
351357  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351358  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351359  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351360  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351583  B  F  A SBT_TAPE    13-OCT-12       1       1       NO         NOEXPIRE
355951  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
355952  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
355953  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
355954  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
356177  B  F  A SBT_TAPE    27-OCT-12       1       1       NO         NOEXPIRE
386046  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386047  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386048  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386049  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386275  B  F  A SBT_TAPE    26-JAN-13       1       1       NO         NOEXPIRE
387232  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387233  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387234  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387235  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387462  B  F  A SBT_TAPE    29-JAN-13       1       1       NO         NOEXPIRE
392057  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392058  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392059  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392060  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392286  B  F  A SBT_TAPE    09-FEB-13       1       1       NO         NOEXPIRE
392347  B  F  A SBT_TAPE    09-FEB-13       1       1       NO         TAG20130209T021024

RMAN>

So everytime when we restore the database from the latest gold backup, we will open the database with resetlogs option and it starts a new incarnation.
These details are shown below ..

RMAN> list incarnation of database TRNGDB;List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
——- ——- ——– —————- — ———- ———-
……
…….
158938  325435  TRNGDB   3679252776       ORPHAN  88080533256 29-JUL-12
158938  326880  TRNGDB   3679252776       PARENT  88080533256 02-AUG-12
158938  323440  TRNGDB   3679252776       ORPHAN  88080533256 26-JUL-12
158938  330059  TRNGDB   3679252776       ORPHAN  88080774587 09-AUG-12
158938  332058  TRNGDB   3679252776       ORPHAN  88080774587 12-AUG-12
158938  335023  TRNGDB   3679252776       ORPHAN  88080774587 23-AUG-12
158938  334177  TRNGDB   3679252776       ORPHAN  88080774587 19-AUG-12
158938  350823  TRNGDB   3679252776       PARENT  88080774587 11-OCT-12
158938  350133  TRNGDB   3679252776       ORPHAN  88080774587 07-OCT-12
158938  337328  TRNGDB   3679252776       ORPHAN  88080774587 26-AUG-12
158938  338003  TRNGDB   3679252776       ORPHAN  88080774587 30-AUG-12
158938  339685  TRNGDB   3679252776       ORPHAN  88080774587 02-SEP-12
158938  340363  TRNGDB   3679252776       ORPHAN  88080774587 06-SEP-12
158938  342063  TRNGDB   3679252776       ORPHAN  88080774587 09-SEP-12
158938  342743  TRNGDB   3679252776       ORPHAN  88080774587 13-SEP-12
158938  344429  TRNGDB   3679252776       ORPHAN  88080774587 16-SEP-12
158938  346103  TRNGDB   3679252776       ORPHAN  88080774587 23-SEP-12
158938  347243  TRNGDB   3679252776       ORPHAN  88080774587 27-SEP-12
158938  348499  TRNGDB   3679252776       ORPHAN  88080774587 30-SEP-12
158938  349183  TRNGDB   3679252776       ORPHAN  88080774587 04-OCT-12
158938  352901  TRNGDB   3679252776       ORPHAN  88081045250 18-OCT-12
158938  354443  TRNGDB   3679252776       ORPHAN  88081045250 21-OCT-12
158938  355286  TRNGDB   3679252776       PARENT  88081045250 25-OCT-12
158938  364387  TRNGDB   3679252776       ORPHAN  88081234176 22-NOV-12
158938  363526  TRNGDB   3679252776       ORPHAN  88081234176 18-NOV-12
158938  362107  TRNGDB   3679252776       ORPHAN  88081234176 15-NOV-12
158938  361247  TRNGDB   3679252776       ORPHAN  88081234176 11-NOV-12
158938  359827  TRNGDB   3679252776       ORPHAN  88081234176 08-NOV-12
158938  358965  TRNGDB   3679252776       ORPHAN  88081234176 04-NOV-12
158938  357545  TRNGDB   3679252776       ORPHAN  88081234176 01-NOV-12
158938  365807  TRNGDB   3679252776       ORPHAN  88081234176 25-NOV-12
158938  384807  TRNGDB   3679252776       PARENT  88081234176 24-JAN-13
158938  383953  TRNGDB   3679252776       ORPHAN  88081234176 20-JAN-13
158938  382547  TRNGDB   3679252776       ORPHAN  88081234176 17-JAN-13
158938  381687  TRNGDB   3679252776       ORPHAN  88081234176 13-JAN-13
158938  380267  TRNGDB   3679252776       ORPHAN  88081234176 10-JAN-13
158938  379411  TRNGDB   3679252776       ORPHAN  88081234176 06-JAN-13
158938  378007  TRNGDB   3679252776       ORPHAN  88081234176 03-JAN-13
158938  377152  TRNGDB   3679252776       ORPHAN  88081234176 30-DEC-12
158938  375747  TRNGDB   3679252776       ORPHAN  88081234176 27-DEC-12
158938  374892  TRNGDB   3679252776       ORPHAN  88081234176 23-DEC-12
158938  373487  TRNGDB   3679252776       ORPHAN  88081234176 20-DEC-12
158938  372631  TRNGDB   3679252776       ORPHAN  88081234176 16-DEC-12
158938  371227  TRNGDB   3679252776       ORPHAN  88081234176 13-DEC-12
158938  366667  TRNGDB   3679252776       ORPHAN  88081234176 29-NOV-12
158938  368086  TRNGDB   3679252776       ORPHAN  88081234176 02-DEC-12
158938  368947  TRNGDB   3679252776       ORPHAN  88081234176 06-DEC-12
158938  370366  TRNGDB   3679252776       ORPHAN  88081234176 09-DEC-12
158938  391514  TRNGDB   3679252776       PARENT  88082816786 07-FEB-13
158938  387719  TRNGDB   3679252776       ORPHAN  88082816786 01-FEB-13
158938  390618  TRNGDB   3679252776       ORPHAN  88082816786 03-FEB-13
158938  404336  TRNGDB   3679252776       ORPHAN  88082894636 21-FEB-13
158938  403425  TRNGDB   3679252776       ORPHAN  88082894636 17-FEB-13
158938  401240  TRNGDB   3679252776       ORPHAN  88082894636 14-FEB-13
158938  416836  TRNGDB   3679252776       CURRENT 88082894636 21-MAR-13
158938  412180  TRNGDB   3679252776       ORPHAN  88082894636 10-MAR-13
158938  409274  TRNGDB   3679252776       ORPHAN  88082894636 03-MAR-13
158938  415096  TRNGDB   3679252776       ORPHAN  88082894636 17-MAR-13
158938  413356  TRNGDB   3679252776       ORPHAN  88082894636 14-MAR-13
158938  406349  TRNGDB   3679252776       ORPHAN  88082894636 24-FEB-13
158938  407256  TRNGDB   3679252776       ORPHAN  88082894636 28-FEB-13
158938  410176  TRNGDB   3679252776       ORPHAN  88082894636 07-MAR-13

RMAN>

As long as i am restoring the latest goldbackups to the training environment, it uses the current incarnation and able to restore the latest backups and able to open the database with resetlogs option.

But if i want to restore any previous backups(backups taken at a different incarnation) to the training environment,i may not be able to restore the backups to the current incarnation.

Let us assume that i have my latest backups available on 09-OCT-2013 as per the above details and my current incarnation is 416836 (on 21-MAR-2013).
Now i have a requirement where i need to restore the backups available on 27-OCT-2012 to the same server. So as long as my current incarnation is 416836, i will not be able to use these backups on 27-OCT-2012 to restore the database.
So i need to first change the incarnation to be able to restore the backups on 27-OCT-2012.

For your easy understanding to identify to which incarnation to change, i have mixed backup details and incarnation details and orderded the details date wise below ….

158938  349183  TRNGDB   3679252776       ORPHAN  88080774587 04-OCT-12
13-OCT-12  <<<== Date on which we have Backups
158938  350133  TRNGDB   3679252776       ORPHAN  88080774587 07-OCT-12
158938  350823  TRNGDB   3679252776       PARENT  88080774587 11-OCT-12
158938  352901  TRNGDB   3679252776       ORPHAN  88081045250 18-OCT-12
158938  354443  TRNGDB   3679252776       ORPHAN  88081045250 21-OCT-12
158938  355286  TRNGDB   3679252776       PARENT  88081045250 25-OCT-12
27-OCT-12 <<<== Date on which we have  Backups
158938  357545  TRNGDB   3679252776       ORPHAN  88081234176 01-NOV-12
158938  358965  TRNGDB   3679252776       ORPHAN  88081234176 04-NOV-12
158938  359827  TRNGDB   3679252776       ORPHAN  88081234176 08-NOV-12
158938  361247  TRNGDB   3679252776       ORPHAN  88081234176 11-NOV-12
158938  362107  TRNGDB   3679252776       ORPHAN  88081234176 15-NOV-12
158938  363526  TRNGDB   3679252776       ORPHAN  88081234176 18-NOV-12
158938  364387  TRNGDB   3679252776       ORPHAN  88081234176 22-NOV-12
158938  365807  TRNGDB   3679252776       ORPHAN  88081234176 25-NOV-12
158938  366667  TRNGDB   3679252776       ORPHAN  88081234176 29-NOV-12

When a database goes through multiple incarnations, some backups can become orphaned. The simple way to find non-orphaned backups and orphaned backups are to form a table to list the incarnation number and orphaned and non-orphaned backups to each incarnation.
In our case, in simple words, we need to restore backups from 27-OCT-12. So identify the incarnation number for which this backup is non-orphaned.

I am considering the incarnation before and after the 27-OCT-12 to identify orphaned and non-orphaned backups. We have incarnations 357545(on 01-NOV-12)  and 355286 (25-OCT-12).

For incarnation 357545(on 01-NOV-12) : All the backups taken after the date 01-NOV-2012 are non-orphaned and all the backups before this incarnation are orphaned backups assuming that there is no other incarnation after the incarnation 357545. So in our case the backups on 27-OCT-2012 are orphaned backups if i set incarnation 357545.
For incarnation 355286(on 25-OCT-12) : All the backups taken after the date 25-OCT-2012 are non-orphaned and all the backups before this incarnation are orphaned backups assuming that there is no other incarnation after the incarnation 355286. So in our case the backups on 27-OCT-2012 are non-orphaned backups if i set incarnation 355286.

Now we have the details, which incarnation we need to set for restoring the 27-OCT-2012 backups.

Also get the controlfile information from the 27-OCT-2012 backups using

RMAN> list backup of controlfile;

NOTE : In our case the controlfile details are ‘4vnoosbv_1_1’

Then use the following syntax to restore and recover the database…

RMAN> set dbid=3679252776executing command: SET DBID
database name is “TRNGDB” and DBID is 3679252776

RMAN> RESET DATABASE TO INCARNATION 355286;

database reset to incarnation 355286

RMAN>  run {
2> allocate channel t1 type ‘SBT_TAPE’ parms=”ENV=(TDPO_OPTFILE=/tmp/askm/TRNGDB_tdpo.opt)”;
3> restore controlfile from ‘4vnoosbv_1_1’;
4> }

allocated channel: t1
channel t1: SID=396 device type=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.5.2.0

Starting restore at 22-MAR-13

channel t1: restoring control file
channel t1: restore complete, elapsed time: 00:00:01
output file name=/u01/oradata/TRNGDB/control01.ctl
output file name=/u01/oradata/TRNGDB/control02.ctl
output file name=/u01/oradata/TRNGDB/control03.ctl
Finished restore at 22-MAR-13
released channel: t1

RMAN> run {
2> allocate channel t1 type ‘SBT_TAPE’ parms=”ENV=(TDPO_OPTFILE=/tmp/askm/TRNGDB_tdpo.opt)”;
3> restore controlfile from ‘4vnoosbv_1_1’;
4> alter database mount;
5> restore database;
6> recover database noredo;
7> release channel t1;
8> }

allocated channel: t1
channel t1: SID=396 device type=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.5.2.0

Starting restore at 22-MAR-13

channel t1: restoring control file
channel t1: restore complete, elapsed time: 00:00:01
output file name=/u01/oradata/TRNGDB/control01.ctl
output file name=/u01/oradata/TRNGDB/control02.ctl
output file name=/u01/oradata/TRNGDB/control03.ctl
Finished restore at 22-MAR-13

database mounted

Starting restore at 22-MAR-13

channel t1: starting datafile backup set restore
channel t1: specifying datafile(s) to restore from backup set
channel t1: restoring datafile 00003 to /u01/oradata/TRNGDB/sysaux01.dbf
channel t1: restoring datafile 00004 to /u01/oradata/TRNGDB/psdefault.dbf
channel t1: restoring datafile 00009 to /u01/oradata/TRNGDB/aalarge.dbf
channel t1: restoring datafile 00011 to /u01/oradata/TRNGDB/adapp.dbf
channel t1: restoring datafile 00012 to /u01/oradata/TRNGDB/adapp001002.dbf
channel t1: restoring datafile 00014 to /u01/oradata/TRNGDB/avapp.dbf
channel t1: restoring datafile 00015 to /u01/oradata/TRNGDB/avapp001002.dbf
channel t1: restoring datafile 00017 to /u01/oradata/TRNGDB/avapp001004.dbf
channel t1: restoring datafile 00022 to /u01/oradata/TRNGDB/ccapp.dbf
channel t1: restoring datafile 00030 to /u01/oradata/TRNGDB/cularg3.dbf
channel t1: restoring datafile 00031 to /u01/oradata/TRNGDB/diapp.dbf
channel t1: restoring datafile 00036 to /u01/oradata/TRNGDB/faapp001002.dbf
channel t1: restoring datafile 00038 to /u01/oradata/TRNGDB/fgapp.dbf
channel t1: restoring datafile 00041 to /u01/oradata/TRNGDB/giapp.dbf
channel t1: restoring datafile 00043 to /u01/oradata/TRNGDB/glapp.dbf
channel t1: restoring datafile 00047 to /u01/oradata/TRNGDB/hpapp001002.dbf
channel t1: restoring datafile 00054 to /u01/oradata/TRNGDB/hrapp4001002.dbf
channel t1: restoring datafile 00063 to /u01/oradata/TRNGDB/hrwork001002.dbf
channel t1: restoring datafile 00065 to /u01/oradata/TRNGDB/htapp001002.dbf
channel t1: restoring datafile 00067 to /u01/oradata/TRNGDB/inlarge.dbf
channel t1: restoring datafile 00068 to /u01/oradata/TRNGDB/paapp.dbf
channel t1: restoring datafile 00069 to /u01/oradata/TRNGDB/paapp001001.dbf
channel t1: restoring datafile 00070 to /u01/oradata/TRNGDB/palarge.dbf
channel t1: restoring datafile 00077 to /u01/oradata/TRNGDB/piwork001002.dbf
channel t1: restoring datafile 00081 to /u01/oradata/TRNGDB/psindx001002.dbf
channel t1: restoring datafile 00085 to /u01/oradata/TRNGDB/psindx001006.dbf
channel t1: restoring datafile 00086 to /u01/oradata/TRNGDB/psindx001007.dbf
channel t1: restoring datafile 00089 to /u01/oradata/TRNGDB/psindx001010.dbf
channel t1: restoring datafile 00098 to /u01/oradata/TRNGDB/ptcmstar.dbf
channel t1: restoring datafile 00100 to /u01/oradata/TRNGDB/ptprc.dbf
channel t1: restoring datafile 00107 to /u01/oradata/TRNGDB/pttlrg001002.dbf
channel t1: restoring datafile 00115 to /u01/oradata/TRNGDB/pywork.dbf
channel t1: restoring datafile 00121 to /u01/oradata/TRNGDB/saapp001005.dbf
channel t1: restoring datafile 00125 to /u01/oradata/TRNGDB/salarge.dbf
channel t1: restoring datafile 00136 to /u01/oradata/TRNGDB/tlapp001002.dbf
channel t1: restoring datafile 00140 to /u01/oradata/TRNGDB/tlwork001001.dbf
channel t1: restoring datafile 00142 to /u01/oradata/TRNGDB/waapp.dbf
channel t1: restoring datafile 00147 to /u01/oradata/TRNGDB/rbks001002.dbf
channel t1: restoring datafile 00149 to /u01/oradata/TRNGDB/epapp001001.dbf
channel t1: restoring datafile 00161 to /u01/oradata/TRNGDB/eoeiapp001001.dbf
channel t1: restoring datafile 00162 to /u01/oradata/TRNGDB/eodsapp001001.dbf
channel t1: restoring datafile 00166 to /u01/oradata/TRNGDB/hrslarge001001.dbf
channel t1: restoring datafile 00170 to /u01/oradata/TRNGDB/eopplrg001001.dbf
channel t1: restoring datafile 00174 to /u01/oradata/TRNGDB/eocuapp001001.dbf
channel t1: restoring datafile 00178 to /u01/oradata/TRNGDB/eoeilrg001001.dbf
channel t1: restoring datafile 00182 to /u01/oradata/TRNGDB/eoiuwrk001001.dbf
channel t1: restoring datafile 00186 to /u01/oradata/TRNGDB/erwork001001.dbf
channel t1: restoring datafile 00190 to /u01/oradata/TRNGDB/hrlarg1001001.dbf
channel t1: restoring datafile 00192 to /u01/oradata/TRNGDB/psimgr001001.dbf
channel t1: restoring datafile 00196 to /u01/oradata/TRNGDB/pswork001001.dbf
channel t1: restoring datafile 00200 to /u01/oradata/TRNGDB/hrapp001004.dbf
channel t1: restoring datafile 00203 to /u01/oradata/TRNGDB/clnd001001.dbf
channel t1: restoring datafile 00205 to /u01/oradata/TRNGDB/clnd001002
channel t1: reading from backup piece backup_TRNGDB_3679252776_set155_piece1_copy1_20121027_4rnoorig_1_1
channel t1: piece handle=backup_TRNGDB_3679252776_set155_piece1_copy1_20121027_4rnoorig_1_1 tag=NOEXPIRE

..
….
RMAN> alter database open resetlogs;

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

RMAN> exit

So we are able to successfully restore the backups from a different incarnation. The same procedure can be applied if you plan to restore the database to a different server as long as the tsm configuration is properly done.

Hope It Helps

SRI

Posted in RMAN | Tagged: , , , | Leave a Comment »

RMAN recovery scenarios

Posted by Srikrishna Murthy Annam on March 27, 2013

Recently i took RMAN sessions to some group of people and as a part of it i explained various scenarios of rman restore and recovery operation. I tried to record the video for the purpose of the people who follow my blog.

In this present session we will see various recovery scenarios mentioned below.

  1. Complete database restore and recovery
  2. Loss of System Datafile
  3. Non-System datafile ( closed and Open )
  4. Restoring a tablespace ( closed and Open )
  5. Restoring a datafile if no backups
  6. Restoring a datafile to different location
  7. Restoring controlfile
  8. restoring spfile
  9. Restoring online redologs
  10. Restoring temporary datafiles
  11. Incomplete Recovery ( time based , Change based and SCN based )
  12. Recovering archived logs

The following video demo gives you detailed explanation of each scenario and how to restore and recover under different scenarios.

Setup:
Let me explain you the environment used for this practice. I am using a database with ORACLE_SID=orcl as my database for testing all the different scenarios mentioned above. I am using a recovery catalog for my rman configuration and its details are ORACLE_SID=rmandb and schema used for rman catalog data is rman and the tns alias to connect to catalog database is rmandb.

I have both my databases orcl and rmandb in archive log mode and i also have backup for my database orcl.

For all my restore and recover operations i am using the following syntax to connect to target database and catalog database.

rman target / catalog rman/*******@rmandb

Complete database restore

SQL> select name,user from v$database;NAME USER
——— ——————————
ORCL SYSSQL> select open_mode from v$database;OPEN_MODE
——————–
READ WRITESQL> select username,default_tablespace from dba_users where username=’SH’;

USERNAME DEFAULT_TABLESPACE
—————————— ——————————
SH USERS

SQL> conn scott/oracle
Connected.
SQL> select count(1) from emp;

COUNT(1)
———-
14

SQL> select * from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> select * from dept;

DEPTNO DNAME LOC
———- ————– ————-
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> cl scr

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ cd /home/oracle/app/oracle/oradata/orcl/
[oracle@localhost orcl]$ ls -lrt
total 2754360
-rw-r—– 1 oracle oracle 239869952 Mar 23 21:40 users01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 23 21:40 redo03.log
-rw-r—– 1 oracle oracle 52429312 Mar 23 21:40 redo02.log
-rw-r—– 1 oracle oracle 85991424 Mar 23 21:40 example01.dbf
-rw-rw—- 1 oracle oracle 8396800 Mar 23 21:40 APEX_1265209995679366.dbf
-rw-rw—- 1 oracle oracle 2105344 Mar 23 21:40 APEX_1246426611663638.dbf
-rw-r—– 1 oracle oracle 165683200 Mar 23 22:40 temp01.dbf
-rw-r—– 1 oracle oracle 845160448 Mar 23 23:05 system01.dbf
-rw-r—– 1 oracle oracle 1158684672 Mar 23 23:07 sysaux01.dbf
-rw-r—– 1 oracle oracle 144711680 Mar 23 23:08 undotbs01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:08 redo01.log
-rw-r—– 1 oracle oracle 9748480 Mar 23 23:08 control01.ctl
[oracle@localhost orcl]$ rm *.dbf
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sat Mar 23 23:09:18 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> conn scoot/tiger
ERROR:
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
SQL> conn scott/oracle
Connected.
SQL> select * from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> alter system flush sga;
alter system flush sga
*
ERROR at line 1:
ORA-02000: missing SHARED_POOL/BUFFER_CACHE/GLOBAL CONTEXT keyword

SQL> alter system flush shared pool;
alter system flush shared pool
*
ERROR at line 1:
ORA-02000: missing SHARED_POOL/BUFFER_CACHE/GLOBAL CONTEXT keyword

SQL> conn /as sysdba
Connected.
SQL> alter system flush shared pool;
alter system flush shared pool
*
ERROR at line 1:
ORA-02000: missing SHARED_POOL/BUFFER_CACHE/GLOBAL CONTEXT keyword

SQL> alter system flush shared_pool;

System altered.

SQL> conn scott/oracle
ERROR:
ORA-01116: error in opening database file 1
ORA-01110: data file 1: ‘/home/oracle/app/oracle/oradata/orcl/system01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

Warning: You are no longer connected to ORACLE.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> exit
Disconnected
[oracle@localhost orcl]$ ps -ef | grep -i pmon
oracle 2309 1 0 21:39 ? 00:00:11 ora_pmon_orcl
oracle 3513 3193 0 23:12 pts/1 00:00:00 grep -i pmon
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sat Mar 23 23:12:55 2013

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

Connected.
SQL> shut immediate
ORA-01116: error in opening database file 1
ORA-01110: data file 1: ‘/home/oracle/app/oracle/oradata/orcl/system01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> startup
ORA-01081: cannot start already-running ORACLE – shut it down first
SQL> shut abort
ORACLE instance shut down.

========================== break =================================================
[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 – Production on Sat Mar 23 23:13:11 2013

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

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-01116: error in opening database file 1
ORA-01110: data file 1: ‘/home/oracle/app/oracle/oradata/orcl/system01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
[oracle@localhost ~]$

========================= break ==============================

SQL> startup nomount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
SQL>

============================= Break ===========================================

RMAN> run {
2> alter database mount;
3> restore database;
4> recover database;
5> }

database mounted
released channel: ORA_DISK_1

Starting restore at 23-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
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 00005 to /home/oracle/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf
channel ORA_DISK_1: restoring datafile 00007 to /home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp tag=FULL_WEEKLY_HOT
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:26
Finished restore at 23-MAR-13

Starting recover at 23-MAR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /home/oracle/app/oracle/oradata/orcl/system01.dbf
destination for restore of datafile 00002: /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
destination for restore of datafile 00003: /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
destination for restore of datafile 00005: /home/oracle/app/oracle/oradata/orcl/example01.dbf
destination for restore of datafile 00006: /home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf
destination for restore of datafile 00007: /home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp tag=LVL1C_FULL_DB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=360
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=361
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=362
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=363
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp tag=TAG20130224T034327
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx712yq_.arc thread=1 sequence=360
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx712yq_.arc RECID=17 STAMP=810861876
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx7131f_.arc thread=1 sequence=361
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx7131f_.arc RECID=14 STAMP=810861875
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx713x6_.arc thread=1 sequence=362
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx713x6_.arc RECID=15 STAMP=810861876
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx714b8_.arc thread=1 sequence=363
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx714b8_.arc RECID=16 STAMP=810861876
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
media recovery complete, elapsed time: 00:00:14
Finished recover at 23-MAR-13
starting full resync of recovery catalog
full resync complete

RMAN> alter database open;

database opened

RMAN>

============================ Break =============================

SQL> select name,user,open_mode from v$database;

NAME USER OPEN_MODE
——— —————————— ——————–
ORCL SYS READ WRITE

SQL> select count(1) from scott.emp;

COUNT(1)
———-
14

SQL> select count(1) from scott.dept;

COUNT(1)
———-
4

SQL>

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

System Datafile

[oracle@localhost orcl]$ ls -lrt
total 2593432
-rw-rw—- 1 oracle oracle 239869952 Mar 23 23:25 users01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:25 redo03.log
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:25 redo01.log
-rw-rw—- 1 oracle oracle 85991424 Mar 23 23:25 example01.dbf
-rw-rw—- 1 oracle oracle 8396800 Mar 23 23:25 APEX_1265209995679366.dbf
-rw-rw—- 1 oracle oracle 2105344 Mar 23 23:25 APEX_1246426611663638.dbf
-rw-rw—- 1 oracle oracle 20979712 Mar 23 23:25 temp01.dbf
-rw-rw—- 1 oracle oracle 144711680 Mar 23 23:31 undotbs01.dbf
-rw-rw—- 1 oracle oracle 845160448 Mar 23 23:32 system01.dbf
-rw-rw—- 1 oracle oracle 1158684672 Mar 23 23:34 sysaux01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:35 redo02.log
-rw-r—– 1 oracle oracle 9748480 Mar 23 23:35 control01.ctl
[oracle@localhost orcl]$ rm system01.dbf
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’SQL*Plus: Release 11.1.0.7.0 – Production on Sat Mar 23 23:35:12 2013Copyright (c) 1982, 2008, Oracle. All rights reserved.ERROR:
ORA-01075: you are currently logged onEnter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied

Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied

SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[oracle@localhost orcl]$ sqlplus /nolog

SQL*Plus: Release 11.1.0.7.0 – Production on Sat Mar 23 23:35:22 2013

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

SQL> conn /as sysdba
ERROR:
ORA-01075: you are currently logged on

SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORA-00000: normal, successful completion
SQL> select open_mode from v$database;
SP2-0640: Not connected
SQL> SELECT file#, name FROM v$datafile;
SP2-0640: Not connected
SQL> conn ‘/as sysdba’
Enter password:
ERROR:
ORA-01005: null password given; logon denied

SQL> shut abort
ORA-01031: insufficient privileges
SQL> conn /as sysdba
Connected.
SQL> SELECT file#, name FROM v$datafile;
SELECT file#, name FROM v$datafile
*
ERROR at line 1:
ORA-01507: database not mounted

SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL> SELECT file#, name FROM v$datafile;

FILE#
———-
NAME
——————————————————————————–
1
/home/oracle/app/oracle/oradata/orcl/system01.dbf

2
/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf

3
/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf

FILE#
———-
NAME
——————————————————————————–
4
/home/oracle/app/oracle/oradata/orcl/users01.dbf

5
/home/oracle/app/oracle/oradata/orcl/example01.dbf

6
/home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf

FILE#
———-
NAME
——————————————————————————–
7
/home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf

7 rows selected.

SQL> desc v$datafile
Name Null? Type
—————————————– ——– —————————-
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
CHECKPOINT_CHANGE# NUMBER
CHECKPOINT_TIME DATE
UNRECOVERABLE_CHANGE# NUMBER
UNRECOVERABLE_TIME DATE
LAST_CHANGE# NUMBER
LAST_TIME DATE
OFFLINE_CHANGE# NUMBER
ONLINE_CHANGE# NUMBER
ONLINE_TIME DATE
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
PLUGGED_IN NUMBER
BLOCK1_OFFSET NUMBER
AUX_NAME VARCHAR2(513)
FIRST_NONLOGGED_SCN NUMBER
FIRST_NONLOGGED_TIME DATE
FOREIGN_DBID NUMBER
FOREIGN_CREATION_CHANGE# NUMBER
FOREIGN_CREATION_TIME DATE
PLUGGED_READONLY VARCHAR2(3)
PLUGIN_CHANGE# NUMBER
PLUGIN_RESETLOGS_CHANGE# NUMBER
PLUGIN_RESETLOGS_TIME DATE

SQL> select file#,name,status from v$datafile;

FILE#
———-
NAME
——————————————————————————–
STATUS
——-
1
/home/oracle/app/oracle/oradata/orcl/system01.dbf
SYSTEM

2
/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
ONLINE

FILE#
———-
NAME
——————————————————————————–
STATUS
——-

3
/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
ONLINE

4
/home/oracle/app/oracle/oradata/orcl/users01.dbf

FILE#
———-
NAME
——————————————————————————–
STATUS
——-
ONLINE

5
/home/oracle/app/oracle/oradata/orcl/example01.dbf
ONLINE

6

FILE#
———-
NAME
——————————————————————————–
STATUS
——-
/home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf
ONLINE

7
/home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf
ONLINE

7 rows selected.

SQL>

====================== break ===============================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 – Production on Sat Mar 23 23:39:06 2013

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

connected to target database: ORCL (DBID=1229390655, not open)
connected to recovery catalog database

RMAN> run {
2> restore datafile 1;
3> recover datafile 1;
4> alter database open;
5> }

Starting restore at 23-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

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: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp tag=FULL_WEEKLY_HOT
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:06
Finished restore at 23-MAR-13

Starting recover at 23-MAR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp tag=LVL1C_FULL_DB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=360
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=361
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=362
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=363
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp tag=TAG20130224T034327
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx83bfk_.arc thread=1 sequence=360
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx83bfk_.arc RECID=22 STAMP=810862973
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx83bjo_.arc thread=1 sequence=361
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx83bjo_.arc RECID=19 STAMP=810862971
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx83cvw_.arc thread=1 sequence=362
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx83cvw_.arc RECID=20 STAMP=810862972
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx83d7w_.arc thread=1 sequence=363
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx83d7w_.arc RECID=21 STAMP=810862972
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
media recovery complete, elapsed time: 00:00:04
Finished recover at 23-MAR-13

database opened

RMAN>

============================= break ===========================

SQL> SELECT file#, name,status FROM v$datafile;

FILE# NAME STATUS
—– ———————————————————— ———-
1 /home/oracle/app/oracle/oradata/orcl/system01.dbf SYSTEM
2 /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf ONLINE
3 /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf ONLINE
4 /home/oracle/app/oracle/oradata/orcl/users01.dbf ONLINE
5 /home/oracle/app/oracle/oradata/orcl/example01.dbf ONLINE
6 /home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.d ONLINE
bf

7 /home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.d ONLINE
bf

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name=’SYSTEM’;

TABLESPACE_NAME STATUS
—————————— ———-
SYSTEM ONLINE

Non-System datafile ( closed and Open )

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ ls -lrt
total 2593432
-rw-rw—- 1 oracle oracle 20979712 Mar 23 23:25 temp01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:43 redo01.log
-rw-rw—- 1 oracle oracle 239869952 Mar 23 23:43 users01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:43 redo02.log
-rw-rw—- 1 oracle oracle 85991424 Mar 23 23:43 example01.dbf
-rw-rw—- 1 oracle oracle 8396800 Mar 23 23:43 APEX_1265209995679366.dbf
-rw-rw—- 1 oracle oracle 2105344 Mar 23 23:43 APEX_1246426611663638.dbf
-rw-rw—- 1 oracle oracle 845160448 Mar 23 23:49 system01.dbf
-rw-rw—- 1 oracle oracle 144711680 Mar 23 23:49 undotbs01.dbf
-rw-rw—- 1 oracle oracle 1158684672 Mar 23 23:49 sysaux01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:49 redo03.log
-rw-r—– 1 oracle oracle 9748480 Mar 23 23:49 control01.ctl
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’SQL*Plus: Release 11.1.0.7.0 – Production on Sat Mar 23 23:50:30 2013Copyright (c) 1982, 2008, Oracle. All rights reserved.Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> col file# for 999
SQL> col name for a60
SQL> col status for a10
SQL> set linesize 120
SQL> SELECT file#, name,status FROM v$datafile where tablespace_name=’USERS’;
SELECT file#, name,status FROM v$datafile where tablespace_name=’USERS’
*
ERROR at line 1:
ORA-00904: “TABLESPACE_NAME”: invalid identifier

SQL> DESC V$DATAFILE
Name Null? Type
—————————————————————– ——– ——————————————–
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
CHECKPOINT_CHANGE# NUMBER
CHECKPOINT_TIME DATE
UNRECOVERABLE_CHANGE# NUMBER
UNRECOVERABLE_TIME DATE
LAST_CHANGE# NUMBER
LAST_TIME DATE
OFFLINE_CHANGE# NUMBER
ONLINE_CHANGE# NUMBER
ONLINE_TIME DATE
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
PLUGGED_IN NUMBER
BLOCK1_OFFSET NUMBER
AUX_NAME VARCHAR2(513)
FIRST_NONLOGGED_SCN NUMBER
FIRST_NONLOGGED_TIME DATE
FOREIGN_DBID NUMBER
FOREIGN_CREATION_CHANGE# NUMBER
FOREIGN_CREATION_TIME DATE
PLUGGED_READONLY VARCHAR2(3)
PLUGIN_CHANGE# NUMBER
PLUGIN_RESETLOGS_CHANGE# NUMBER
PLUGIN_RESETLOGS_TIME DATE

SQL> desc dba_data_files
Name Null? Type
—————————————————————– ——– ——————————————–
FILE_NAME VARCHAR2(513)
FILE_ID NUMBER
TABLESPACE_NAME VARCHAR2(30)
BYTES NUMBER
BLOCKS NUMBER
STATUS VARCHAR2(9)
RELATIVE_FNO NUMBER
AUTOEXTENSIBLE VARCHAR2(3)
MAXBYTES NUMBER
MAXBLOCKS NUMBER
INCREMENT_BY NUMBER
USER_BYTES NUMBER
USER_BLOCKS NUMBER
ONLINE_STATUS VARCHAR2(7)

SQL> select file_name,file_id,tablespace_name from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
————————————————————————————————————————
FILE_ID TABLESPACE_NAME
———- ——————————
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
————————————————————————————————————————
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———-
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status fro v$datafile where file#=4;
select file#,TS#,status fro v$datafile where file#=4
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL> alter system flush shared_pool;

System altered.

SQL> select count(1) from scott.emp;
select count(1) from scott.emp
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: ‘/home/oracle/app/oracle/oradata/orcl/users01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL>
SQL> select name,user ,open_mode from v$database;

NAME USER OPEN_MODE
———————————————————— —————————— ——————–
ORCL SYS READ WRITE

SQL>

======================== break =============================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 – Production on Sat Mar 23 23:55:32 2013

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

connected to target database: ORCL (DBID=1229390655)
connected to recovery catalog database

RMAN> run {
2> restore datafile 4;
3> recover datafile 4;
4> }

Starting restore at 23-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 03/23/2013 23:56:44
ORA-19573: cannot obtain exclusive enqueue for datafile 4
ORA-19600: input file is datafile-copy 2 (/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf)
ORA-19601: output file is datafile 4 (/home/oracle/app/oracle/oradata/orcl/users01.dbf)

RMAN>

=========================== break =============================

SQL> ALTER DATABASE DATAFILE 4 OFFLINE;

Database altered.

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
————————————————————————————————————————
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———-
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 RECOVER

SQL> select name,user ,open_mode from v$database;

NAME USER OPEN_MODE
———————————————————— —————————— ——————–
ORCL SYS READ WRITE

SQL>

============================== break =========================================

RMAN> run {
2> restore datafile 4;
3> recover datafile 4;
4> sql ‘atler database datafile 4 online’;
5> }

Starting restore at 24-MAR-13
using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
media recovery complete, elapsed time: 00:00:03
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: atler database datafile 4 online
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 03/24/2013 00:01:08
RMAN-11003: failure during parse/execution of SQL statement: atler database datafile 4 online
ORA-00900: invalid SQL statement

RMAN>

RMAN> run {
2> sql ‘alter database datafile 4 online’;
3> }

sql statement: alter database datafile 4 online

RMAN>

========================== break =============================

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
————————————————————————————————————————
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———-
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL> select count(1) from scott.emp;

COUNT(1)
———-
14

SQL> create table test (sno number) tablespace users;

Table created.

SQL>

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

Lost non system datafile 😦 Online method )

[oracle@localhost orcl]$ ls -lrt
total 2593488
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:43 redo01.log
-rw-r—– 1 oracle oracle 52429312 Mar 23 23:43 redo02.log
-rw-rw—- 1 oracle oracle 85991424 Mar 23 23:43 example01.dbf
-rw-rw—- 1 oracle oracle 8396800 Mar 23 23:43 APEX_1265209995679366.dbf
-rw-rw—- 1 oracle oracle 2105344 Mar 23 23:43 APEX_1246426611663638.dbf
-rw-rw—- 1 oracle oracle 20979712 Mar 24 00:00 temp01.dbf
-rw-rw—- 1 oracle oracle 239869952 Mar 24 00:06 users01.dbf
-rw-rw—- 1 oracle oracle 1158684672 Mar 24 00:10 sysaux01.dbf
-rw-rw—- 1 oracle oracle 144711680 Mar 24 00:11 undotbs01.dbf
-rw-rw—- 1 oracle oracle 845160448 Mar 24 00:11 system01.dbf
-rw-r—– 1 oracle oracle 52429312 Mar 24 00:11 redo03.log
-rw-r—– 1 oracle oracle 9748480 Mar 24 00:12 control01.ctl
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 00:12:39 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> col file# for 999
col name for a60
col status for a10
set linesize 120
select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;SQL> SQL> SQL> SQL>

FILE_NAME
————————————————————————————————————————
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———-
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL> alter system flush shared_pool;

System altered.

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL> select count(1) from scott.emp;

COUNT(1)
———-
14

SQL> alter system flush shared_pool;

System altered.

SQL> select count(1) from scott.emp;

COUNT(1)
———-
14

SQL> drop table test;

Table dropped.

SQL> create table test (sno number) tablespace users;
create table test (sno number) tablespace users
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: ‘/home/oracle/app/oracle/oradata/orcl/users01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> select name,user ,open_mode from v$database;

NAME USER OPEN_MODE
———————————————————— —————————— ——————–
ORCL SYS READ WRITE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL> shut immediate
ORA-01116: error in opening database file 4
ORA-01110: data file 4: ‘/home/oracle/app/oracle/oradata/orcl/users01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> startup mount
ORA-01081: cannot start already-running ORACLE – shut it down first
SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;
select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL>

====================== break ==============================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 – Production on Sun Mar 24 00:18:11 2013

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

connected to target database: ORCL (DBID=1229390655, not open)
connected to recovery catalog database

RMAN> run {
2> restore datafile 4;
3> recover datafile 4;
4> sql ‘alter database datafile 4 online’;
5> }

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
media recovery complete, elapsed time: 00:00:01
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: alter database datafile 4 online

RMAN>

========================================== break ===================================================

SQL> alter database open;

Database altered.

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
————————————————————————————————————————
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———-
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
—– ———- ———-
4 4 ONLINE

SQL> select count(1) from scott.emp;

COUNT(1)
———-
14

SQL> create table test (sno number) tablespace users;

Table created.

SQL> drop table test;

Table dropped.

SQL> sho parameter recycle

NAME TYPE VALUE
———————————— ———– ——————————
buffer_pool_recycle string
db_recycle_cache_size big integer 0
recyclebin string on
SQL> purge recyclebin;

Recyclebin purged.

SQL>

Restoring a tablespace ( closed and Open )

Restoring a tablespace : (open mode)[oracle@localhost orcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 00:32:07 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name=’USERS’;

TABLESPACE_NAME STATUS
—————————— ———
USERS ONLINE

SQL> desc dba_tablespaces
Name Null? Type
—————————————– ——– —————————-
TABLESPACE_NAME NOT NULL VARCHAR2(30)
BLOCK_SIZE NOT NULL NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NOT NULL NUMBER
MAX_EXTENTS NUMBER
MAX_SIZE NUMBER
PCT_INCREASE NUMBER
MIN_EXTLEN NUMBER
STATUS VARCHAR2(9)
CONTENTS VARCHAR2(9)
LOGGING VARCHAR2(9)
FORCE_LOGGING VARCHAR2(3)
EXTENT_MANAGEMENT VARCHAR2(10)
ALLOCATION_TYPE VARCHAR2(9)
PLUGGED_IN VARCHAR2(3)
SEGMENT_SPACE_MANAGEMENT VARCHAR2(6)
DEF_TAB_COMPRESSION VARCHAR2(8)
RETENTION VARCHAR2(11)
BIGFILE VARCHAR2(3)
PREDICATE_EVALUATION VARCHAR2(7)
ENCRYPTED VARCHAR2(3)
COMPRESS_FOR VARCHAR2(12)

SQL> desc v$tablespace
Name Null? Type
—————————————– ——– —————————-
TS# NUMBER
NAME VARCHAR2(30)
INCLUDED_IN_DATABASE_BACKUP VARCHAR2(3)
BIGFILE VARCHAR2(3)
FLASHBACK_ON VARCHAR2(3)
ENCRYPT_IN_BACKUP VARCHAR2(3)

SQL> select ts#,name from v$tablespace where name=’USERS’;

TS# NAME
———- ——————————
4 USERS

SQL> desc dba_data_files
Name Null? Type
—————————————– ——– —————————-
FILE_NAME VARCHAR2(513)
FILE_ID NUMBER
TABLESPACE_NAME VARCHAR2(30)
BYTES NUMBER
BLOCKS NUMBER
STATUS VARCHAR2(9)
RELATIVE_FNO NUMBER
AUTOEXTENSIBLE VARCHAR2(3)
MAXBYTES NUMBER
MAXBLOCKS NUMBER
INCREMENT_BY NUMBER
USER_BYTES NUMBER
USER_BLOCKS NUMBER
ONLINE_STATUS VARCHAR2(7)

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
——————————————————————————–
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> desc v$datafile
Name Null? Type
—————————————– ——– —————————-
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
CHECKPOINT_CHANGE# NUMBER
CHECKPOINT_TIME DATE
UNRECOVERABLE_CHANGE# NUMBER
UNRECOVERABLE_TIME DATE
LAST_CHANGE# NUMBER
LAST_TIME DATE
OFFLINE_CHANGE# NUMBER
ONLINE_CHANGE# NUMBER
ONLINE_TIME DATE
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
PLUGGED_IN NUMBER
BLOCK1_OFFSET NUMBER
AUX_NAME VARCHAR2(513)
FIRST_NONLOGGED_SCN NUMBER
FIRST_NONLOGGED_TIME DATE
FOREIGN_DBID NUMBER
FOREIGN_CREATION_CHANGE# NUMBER
FOREIGN_CREATION_TIME DATE
PLUGGED_READONLY VARCHAR2(3)
PLUGIN_CHANGE# NUMBER
PLUGIN_RESETLOGS_CHANGE# NUMBER
PLUGIN_RESETLOGS_TIME DATE

SQL> select file#,ts#,status from v$datafile where ts#=4;

FILE# TS# STATUS
———- ———- ——-
4 4 ONLINE

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 00:35:42 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name=’USERS’;

TABLESPACE_NAME STATUS
—————————— ———
USERS ONLINE

SQL> select ts#,name from v$tablespace where name=’USERS’;

TS# NAME
———- ——————————
4 USERS

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
——————————————————————————–
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,ts#,status from v$datafile where ts#=4;

FILE# TS# STATUS
———- ———- ——-
4 4 ONLINE

SQL> create table test (sno number) tablespace users;
create table test (sno number) tablespace users
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: ‘/home/oracle/app/oracle/oradata/orcl/users01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> alter tablespace users offline;
alter tablespace users offline
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: ‘/home/oracle/app/oracle/oradata/orcl/users01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> alter tablespace users offline force;
alter tablespace users offline force
*
ERROR at line 1:
ORA-02141: invalid OFFLINE option

SQL> alter tablespace users force offline;
alter tablespace users force offline
*
ERROR at line 1:
ORA-02142: missing or invalid ALTER TABLESPACE option

SQL> alter tablespace users offline;
alter tablespace users offline
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: ‘/home/oracle/app/oracle/oradata/orcl/users01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL> alter tablespace users offline;
alter tablespace users offline
*
ERROR at line 1:
ORA-01109: database not open

SQL>

================================= break ===========================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 – Production on Sun Mar 24 00:41:20 2013

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

connected to target database: ORCL (DBID=1229390655, not open)
connected to recovery catalog database

RMAN> run {
2> restore tablespace users;
3> recover tablespace users;
4> sql ‘alter database open’;
5> }

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log for thread 1 with sequence 369 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc thread=1 sequence=367
media recovery complete, elapsed time: 00:00:03
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: alter database open

RMAN>

=================================== Break ==============================================

SQL> select name,user ,open_mode from v$database;

NAME USER OPEN_MODE
——— —————————— ——————–
ORCL SYS READ WRITE

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name=’USERS’;

TABLESPACE_NAME STATUS
—————————— ———
USERS ONLINE

SQL> select ts#,name from v$tablespace where name=’USERS’;

TS# NAME
———- ——————————
4 USERS

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
——————————————————————————–
FILE_ID TABLESPACE_NAME STATUS
———- —————————— ———
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,ts#,status from v$datafile where ts#=4;

FILE# TS# STATUS
———- ———- ——-
4 4 ONLINE

SQL> create table test (sno number) tablespace users;

Table created.

SQL> drop table test;

Table dropped.

SQL> purge recyclebin;

Recyclebin purged.

SQL>

Restoring a datafile if no backups

Restoring a datafile if no backups[oracle@localhost orcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 01:52:39 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create tablespace test_ts datafile ‘/home/oracle/app/oracle/oradata/orcl/test_ts01.dbf’ size 5m;

Tablespace created.

SQL> create table test tablespace test_ts as select * from scott.emp;

Table created.

SQL> select * from test;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ rm test_ts01.dbf
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 01:54:06 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select count(1) from test;

COUNT(1)
———-
14

SQL> select * from test;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> alter system flush shared_pool;

System altered.

SQL> select * from test;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
———- ———- ——— ———- ——— ———- ———-
DEPTNO
———-
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> select segment_name,tablespace_name from dba_segments where segment_name=’TEST’;

SEGMENT_NAME
——————————————————————————–
TABLESPACE_NAME
——————————
TEST
TEST_TS

SQL> shut immediate
ORA-01116: error in opening database file 8
ORA-01110: data file 8: ‘/home/oracle/app/oracle/oradata/orcl/test_ts01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL>

=============================================== Break =========================================================

RMAN> run {
2> sql ‘alter database datafile 8 offline’;
3> restore datafile 8;
4> recover datafile 8;
5> sql ‘alter database datafile 8 online’;
6> }

starting full resync of recovery catalog
full resync complete
sql statement: alter database datafile 8 offline

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK

creating datafile file number=8 name=/home/oracle/app/oracle/oradata/orcl/test_ts01.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

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

Finished recover at 24-MAR-13

sql statement: alter database datafile 8 online

RMAN>

============================================== Break ==========================================

SQL> alter database open;

Database altered.

SQL> create table test tablespace test_ts as select * from scott.emp;
create table test tablespace test_ts as select * from scott.emp
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> create table test1 tablespace test_ts as select * from scott.emp;

Table created.

SQL>
SQL> drop table test;

Table dropped.

SQL> drop table test1;

Table dropped.

SQL>

SQL> drop tablespace test_ts including contents and datafiles;

Tablespace dropped.

SQL>

Restoring a datafile to different location

Restoring a datafile to different location[oracle@localhost orcl]$ clear
[oracle@localhost orcl]$ ls -lrt user*
-rw-rw—- 1 oracle oracle 239869952 Mar 24 02:01 users01.dbf
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus ‘/as sysdba’SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 02:10:36 2013Copyright (c) 1982, 2008, Oracle. All rights reserved.Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table scott.test tablespace uses as select * from scott.emp;
create table scott.test tablespace uses as select * from scott.emp
*
ERROR at line 1:
ORA-00959: tablespace ‘USES’ does not exist

SQL> create table scott.test tablespace users as select * from scott.emp;
create table scott.test tablespace users as select * from scott.emp
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: ‘/home/oracle/app/oracle/oradata/orcl/users01.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> alter database datafile 4 offline;

Database altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ mkdir askm
[oracle@localhost orcl]$ cd askm
[oracle@localhost askm]$ pwd
/home/oracle/app/oracle/oradata/orcl/askm
[oracle@localhost askm]$ ls
[oracle@localhost askm]$

=============================================== Break ==========================================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 – Production on Sun Mar 24 02:12:20 2013

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

connected to target database: ORCL (DBID=1229390655)
connected to recovery catalog database

RMAN> run {
2> set newname for datafile 4 to ‘/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf’;
3> restore datafile 4;
4> switch datafile 4;
5> recover datafile 4;
6> sql ‘alter database datafile 4 online’;
7> }

executing command: SET NEWNAME
starting full resync of recovery catalog
full resync complete

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/askm/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf RECID=10 STAMP=810872051
Finished restore at 24-MAR-13

datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=810872055 file name=/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf
starting full resync of recovery catalog
full resync complete

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log for thread 1 with sequence 369 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
archived log for thread 1 with sequence 370 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc
archived log for thread 1 with sequence 371 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc thread=1 sequence=367
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc thread=1 sequence=368
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc thread=1 sequence=369
media recovery complete, elapsed time: 00:00:04
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: alter database datafile 4 online

RMAN>

================================= Break ======================================================

[oracle@localhost askm]$ pwd
/home/oracle/app/oracle/oradata/orcl/askm
[oracle@localhost askm]$ ls -lrt
total 234484
-rw-rw—- 1 oracle oracle 239869952 Mar 24 02:14 users01.dbf
[oracle@localhost askm]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 02:15:49 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table scott.test tablespace users as select * from scott.emp;

Table created.

SQL> drop table scott.test;

Table dropped.

SQL>

Restoring controlfile

Restoring controlfile
=======================SQL> desc v$controlfile
Name Null? Type
—————————————– ——– —————————-
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBERSQL> select name,status from v$controlfile;NAME
——————————————————————————–
STATUS
——-
/home/oracle/app/oracle/oradata/orcl/control01.ctl/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost askm]$ rm /home/oracle/app/oracle/oradata/orcl/control01.ctl /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
[oracle@localhost askm]$ ps -ef | grep -i pmon
oracle 5502 1 0 01:56 ? 00:00:04 ora_pmon_orcl
[oracle@localhost askm]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.1.0.7.0 – Production on Sun Mar 24 02:25:15 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table scott.test tablespace users as select * from scott.emp;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> shut immediate
ORA-00210: cannot open the specified control file
ORA-00202: control file: ‘/home/oracle/app/oracle/oradata/orcl/control01.ctl’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shut abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
ORA-00205: error in identifying control file, check alert log for more info

SQL>

================================== Break =================================================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 – Production on Sun Mar 24 02:29:14 2013

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

connected to target database: ORCL (not mounted)
connected to recovery catalog database

RMAN> set dbid=1229390655

executing command: SET DBID
database name is “ORCL” and DBID is 1229390655

RMAN> restore controlfile;

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_ncsn1_LVL1C_FULL_DB_8lmjhknt_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_ncsn1_LVL1C_FULL_DB_8lmjhknt_.bkp tag=LVL1C_FULL_DB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/home/oracle/app/oracle/oradata/orcl/control01.ctl
output file name=/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 24-MAR-13

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 03/24/2013 02:30:27
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> recover database;

Starting recover at 24-MAR-13
Starting implicit crosscheck backup at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 24-MAR-13

Starting implicit crosscheck copy at 24-MAR-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 24-MAR-13

searching for all files in the recovery area
cataloging files…
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_372_8nxkowqt_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_ncsn1_LVL1C_FULL_DB_8lmjhknt_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T033253_8lmym81j_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp

using channel ORA_DISK_1
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=810873044 file name=/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log for thread 1 with sequence 369 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
archived log for thread 1 with sequence 370 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc
archived log for thread 1 with sequence 371 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc
archived log for thread 1 with sequence 372 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_372_8nxkowqt_.arc
archived log for thread 1 with sequence 373 is already on disk as file /home/oracle/app/oracle/oradata/orcl/redo01.log
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=360
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=361
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=362
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=363
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp tag=TAG20130224T034327
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_360_8nxky72y_.arc thread=1 sequence=360
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_360_8nxky72y_.arc RECID=22 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_361_8nxky74t_.arc thread=1 sequence=361
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_361_8nxky74t_.arc RECID=19 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_362_8nxky831_.arc thread=1 sequence=362
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_362_8nxky831_.arc RECID=20 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_363_8nxky876_.arc thread=1 sequence=363
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_363_8nxky876_.arc RECID=21 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc thread=1 sequence=367
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc thread=1 sequence=368
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc thread=1 sequence=369
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc thread=1 sequence=370
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc thread=1 sequence=371
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc thread=1 sequence=371
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc thread=1 sequence=371
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_372_8nxkowqt_.arc thread=1 sequence=372
archived log file name=/home/oracle/app/oracle/oradata/orcl/redo01.log thread=1 sequence=373
media recovery complete, elapsed time: 00:00:01
Finished recover at 24-MAR-13

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 03/24/2013 02:31:09
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open resetlog;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found “identifier”: expecting one of: “resetlogs, ;”
RMAN-01008: the bad identifier was: resetlog
RMAN-01007: at line 1 column 21 file: standard input

RMAN>

============================================ Break ========================================================

SQL> alter database open resetlogs;

Database altered.

SQL> select name,user,open_mode from v$database;

NAME USER OPEN_MODE
——— —————————— ——————–
ORCL SYS READ WRITE

SQL> archive list logs;
SP2-0734: unknown command beginning “archive li…” – rest of line ignored.
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 1
Current log sequence 1
SQL>

============================================== Break ==========================================

RMAN> list incarnation;

List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
——- ——- ——– —————- — ———- ———-
1 18 ORCL 1229390655 PARENT 1 13-AUG-09
1 2 ORCL 1229390655 CURRENT 754488 30-OCT-09

RMAN>

============================================== Break ===========================================

restoring spfile
Refer video
Restoring online redologs
Refer Video
Restoring temporary datafiles
Refer Video
Incomplete Recovery ( time based , Change based and SCN based )
Refer Video
Recovering archived logs
Refer Video

Hope it helps
SRI

Posted in RMAN | Tagged: , , , , , , , , , | Leave a Comment »

Deleting RMAN “NO EXPIRE” BACKUPS FROM TAPE

Posted by Srikrishna Murthy Annam on November 3, 2011

The following steps are useful to delete the backups which are marked as NO-EXPIRE. No expire backup are the backups for which the retention policy will not apply and the backups remain till you manually and forcibly delete these backups.  The best example for No-expire backups are the backups kept for training purposes. After successfully creating any training environment, we will backup the database with NO-Expire option and these backups will be used to refresh the database every week.

The following commands show you how to delete these no-expire backups on tape from  RMAN CATALOG. This is useful in cases where if you made any changes to the databases and need to preseve these changes in the database forever, you will take new NO-EXPIRE backups and delete the old backups.

RMAN&gt; list backup summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
145913  B  0  A SBT_TAPE    25-APR-11       1       1       YES        NOEXPIRE
145914  B  0  A SBT_TAPE    25-APR-11       1       1       YES        NOEXPIRE
145915  B  0  A SBT_TAPE    25-APR-11       1       1       YES        NOEXPIRE
145916  B  0  A SBT_TAPE    25-APR-11       1       1       YES        NOEXPIRE
145917  B  0  A SBT_TAPE    25-APR-11       1       1       YES        NOEXPIRE
147274  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147275  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147276  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147277  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147278  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147498  B  F  A SBT_TAPE    29-APR-11       1       1       NO         NOEXPIRE

RMAN&gt; DELETE BACKUPSET 145913,145914,145915,145916,145917;

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=522 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of delete command at 05/01/2011 01:20:25
RMAN-06160: no backup pieces found for backup set key: 145913

RMAN&gt; ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;

released channel: ORA_DISK_1
allocated channel: ORA_MAINT_SBT_TAPE_1
channel ORA_MAINT_SBT_TAPE_1: sid=522 devtype=SBT_TAPE
channel ORA_MAINT_SBT_TAPE_1: Data Protection for Oracle: version 5.5.2.0

RMAN&gt; ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;

allocated channel: ORA_MAINT_SBT_TAPE_2
channel ORA_MAINT_SBT_TAPE_2: sid=525 devtype=SBT_TAPE
channel ORA_MAINT_SBT_TAPE_2: Data Protection for Oracle: version 5.5.2.0

RMAN&gt; DELETE BACKUPSET 145913,145914,145915,145916,145917;

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
145919  145913  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set9_piece1_copy1_20110425_09mal5t9_1_1
145920  145914  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set8_piece1_copy1_20110425_08mal5t9_1_1
145921  145915  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set11_piece1_copy1_20110425_0bmal6d9_1_1
145922  145916  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set7_piece1_copy1_20110425_07mal5t9_1_1
145923  145917  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set10_piece1_copy1_20110425_0amal6br_1_1

Do you really want to delete the above objects (enter YES or NO)? NO

RMAN&gt; delete noprompt BACKUPSET 145913,145914,145915,145916,145917;

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
145919  145913  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set9_piece1_copy1_20110425_09mal5t9_1_1
145920  145914  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set8_piece1_copy1_20110425_08mal5t9_1_1
145921  145915  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set11_piece1_copy1_20110425_0bmal6d9_1_1
145922  145916  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set7_piece1_copy1_20110425_07mal5t9_1_1
145923  145917  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set10_piece1_copy1_20110425_0amal6br_1_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of delete command on ORA_MAINT_SBT_TAPE_1 channel at 05/01/2011 01:27:05
ORA-27191: sbtinfo2 returned error
Additional information: 2

RMAN&gt; delete noprompt force BACKUPSET 145913,145914,145915,145916,145917;

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
145919  145913  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set9_piece1_copy1_20110425_09mal5t9_1_1
145920  145914  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set8_piece1_copy1_20110425_08mal5t9_1_1
145921  145915  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set11_piece1_copy1_20110425_0bmal6d9_1_1
145922  145916  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set7_piece1_copy1_20110425_07mal5t9_1_1
145923  145917  1   1   AVAILABLE   SBT_TAPE    backup_CRTRNG_3679252776_set10_piece1_copy1_20110425_0amal6br_1_1
deleted backup piece
backup piece handle=backup_CRTRNG_3679252776_set9_piece1_copy1_20110425_09mal5t9_1_1 recid=7 stamp=749377449
deleted backup piece
backup piece handle=backup_CRTRNG_3679252776_set8_piece1_copy1_20110425_08mal5t9_1_1 recid=8 stamp=749377449
deleted backup piece
backup piece handle=backup_CRTRNG_3679252776_set11_piece1_copy1_20110425_0bmal6d9_1_1 recid=9 stamp=749377962
deleted backup piece
backup piece handle=backup_CRTRNG_3679252776_set7_piece1_copy1_20110425_07mal5t9_1_1 recid=10 stamp=749377449
deleted backup piece
backup piece handle=backup_CRTRNG_3679252776_set10_piece1_copy1_20110425_0amal6br_1_1 recid=11 stamp=749377916
Deleted 5 objects

RMAN&gt; list backup summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
147274  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147275  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147276  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147277  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147278  B  0  A SBT_TAPE    29-APR-11       1       1       YES        NOEXPIRE
147498  B  F  A SBT_TAPE    29-APR-11       1       1       NO         NOEXPIRE

RMAN&gt;

Hope it helps

SRI

Posted in RMAN | Tagged: , , , , | Leave a Comment »

RMAN DUPLICATION FROM TAPE BACKUPS

Posted by Srikrishna Murthy Annam on July 4, 2011

In the present article i am going to explain how to use RMAN to duplicate database from server A to server B.
I am following the reference note : 388431.1 to perform this activity. The only difference from the reference note id 388431.1 in the present article is that the backups are available on TAPE. The procedure defined in the reference note id is slightly deviated to explain the RMAN duplication precedure if the database backups are on TAPE.

Assumptions Made:
Source Database  : SOURCEDB
Target Database  : TARGETDB
RMAN Catalog SID : RMANCAT
TAPE Configuration : TIVOLI TAPE

STEPS:

  1. Backup the source database SOURCEDB
  2. Calculate the source and target SPACE requirements
  3. Making the TAPE backups of SOURCEDB available to TARGETDB
  4. Creating init.ora and administration directories
  5. Verifying the connections from TARGETDB node
  6. Executing the RMAN duplication scripts.

1. Backup the source database SOURCEDB

Please follow the article how to perform the database tape backups.

2. Calculate the source and target SPACE requirements

Execute the script on SOURCEDB and calculate the SIZE of database.

SQL> select DF.TOTAL/1048576 "DataFile Size Mb",
LOG.TOTAL/1048576 "Redo Log Size Mb",
CONTROL.TOTAL/1048576 "Control File Size Mb",
(DF.TOTAL + LOG.TOTAL + CONTROL.TOTAL)/1048576 "Total Size Mb"
from dual,
(select sum(a.bytes) TOTAL from dba_data_files a) DF,
(select sum(b.bytes) TOTAL from v$log b) LOG,
(select sum((cffsz+1)*cfbsz) TOTAL from x$kcccf c) CONTROL;

If you need the database size with all tablespace sizes, please check the script here.

On the target database node(HOST B), verify the disk space using linux command “df -h”

Compare the results of SOURCEDB size and disk space on target node ( HOST B) and ensure you have enough diskspace for your duplicate database.

3. Making the TAPE backups of SOURCEDB available to TARGETDB

Copy the tdpo.opt file from HOST A to HOST B. Place this in any temporary location say  “/tmp/askm”.

Copy the TSM password file from HOST A to HOST B and place it in the same location as “/tmp/askm”. Make sure the file has proper read write permissions.

Modify this tdpo.opt file and change the password location on HOST B as in:


TDPO_PSWDPATH      /tmp/askm

NOTE : Execute “tdpoconf showenvironment” on HOST A to know the tdpo.opt and password file locations

4. Creating init.ora and administration directories

Copy the SOURCEDB pfile from HOST A to HOST B and modify the DB_NAME , control_file and Dump file locations as per the directory structure on HOST B. Make sure to create DUMP directories on target host HOST B.
Add following two parameter to init.ora on HOST B to reflect the directory structure modification from SOURCEDB to TARGETDB.

db_file_name_convert =("/u01/app/oradata/SOURCEDB/", "/u01/app/oradata/TARGETDB/")
log_file_name_convert =("/u01/app/oradata/SOURCEDB/", "/u01/app/oradata/TARGETDB/")

Modify the undo_tablespace value to be same as the SOURCEDB undo_tablespace value.

( Please refer to note ID : 388431.1, for more details how to prepare init.ora file on target host B)

5. Verifying the connections from TARGETDB node

Verify the sql*net connection to SOURCEDB from HOST B.

$ sqlplus 'sys/oracle@SOURCEDB as sysdba'

If it is not working , please perform the following tasks ..
Modify the tnsnames.ora file on HOST B and add tns entries for SOURCEDB. And execute “tnsping SOURCEDB” on HOST B. It should successfully resolve the connection.
Create  password file for remote database connections on HOST A using following command…

orapwd file=orapwSOURCEDB password=oracle entries=5

Now check the sqlplus connection to SOURCEDB again from HOST B.

Verify the rman connections using

sqlplus rman/rman@rmancat

6.  Executing the RMAN duplication script.

Connect to rman and execute the RMAN duplicate script on HOST B.

NOTE : Make sure the TARGETDB is in nomount stage and SOURCEDB is up and running.

$ export ORACLE_SID=TARGETDB

$ rman target sys/oracle@SOURCEDB catalog rman/rman@rmancat auxiliary /
RMAN> run {
# Recovery Time
#set until time 'MON DD YYYY HH:MI:SS';

# Allocate Channels to Tape
configure auxiliary channel 1 device type sbt parms="ENV=(TDPO_OPTFILE=/tmp/askm/tdpo.opt)";

# Issue the duplicate command
DUPLICATE TARGET DATABASE TO TARGETDB

# Create online redo log groups

LOGFILE
GROUP 1 (
'/u01/app/oradata/TARGETDB/redolog1a.log',
'/u01/app/oradata/TARGETDB/redolog1b.log'
) SIZE 50M,
GROUP 2 (
'/u01/app/oradata/TARGETDB/redolog2a.log',
'/u01/app/oradata/TARGETDB/redolog2b.log'
) SIZE 50M,
GROUP 3 (
'/u01/app/oradata/TARGETDB/redolog3a.log',
'/u01/app/oradata/TARGETDB/redolog3b.log'
) SIZE 50M,
GROUP 4 (
'/u01/app/oradata/TARGETDB/redolog4a.log',
'/u01/app/oradata/TARGETDB/redolog4b.log'
) SIZE 50M;

}

Follow the video demo for the visual presenation of the above procedure. This is a private video so, send me a personal request if you need access to this video.

HOPE IT HELPS
SRI

Posted in RMAN | Tagged: , , , , , | 32 Comments »

RMAN KEEP FOREVER ( NO-EXPIRE ) backups to tape

Posted by Srikrishna Murthy Annam on June 20, 2011

In this article, i am going to present two different type of backups to keep forever which exempts them from the retention policy

In the present article, i am going to present the scripts  to backup the database which are exempted from the retention policy and can be kept forever in the  storage. These type of backups will be done immediately after certifying any training instances to refresh every week. One backup will be kept forever with no expire option and the same backup will be used to refresh the database every time.

We can have either consistant backup and in-consistant backups. Consistant backups need the database in mount stage and we can backup database with nologs option. We dont need any archive logs to recover database.
In-consistant backups are done when the database is up and running. And if we have these backups with keep forever option, we may need to keep all the archive log backups taken after the KEEP FOREVER backups were taken.

From 11g onwards, KEEP FOREVER option is improved and it only retains the archivelogs which are required to keep the online backup consistent.

FOREVER Consistant Backups:

startup mount;
run
{
allocate channel t1 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/opt/app/oracle/oradba/rman/tdpo/tdpo.opt)";
allocate channel t2 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/opt/app/oracle/oradba/rman/tdpo/tdpo.opt)";
allocate channel t3 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/opt/app/oracle/oradba/rman/tdpo/tdpo.opt)";
backup as compressed backupset check logical incremental level 0 database format 'backup_%d_%I_set%s_piece%p_copy%c_%T_%U' TAG=NOEXPIRE keep forever nologs;
backup current controlfile TAG=NOEXPIRE;
backup spfile TAG=NOEXPIRE;
delete obsolete;
}

FOREVER Backups with DB up:

First backup all the archive logs using
backup archivelog all;
Then execute the script :
run
{
allocate channel t1 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/opt/app/oracle/oradba/rman/tdpo/tdpo.opt)";
allocate channel t2 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/opt/app/oracle/oradba/rman/tdpo/tdpo.opt)";
allocate channel t3 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/opt/app/oracle/oradba/rman/tdpo/tdpo.opt)";
backup as compressed backupset check logical incremental level 0 database format 'backup_%d_%I_set%s_piece%p_copy%c_%T_%U' plus archivelog TAG=NOEXPIRE keep forever logs;
backup current controlfile TAG=NOEXPIRE;
backup spfile TAG=NOEXPIRE;
delete obsolete;
}

Hope it helps
SRI

Posted in RMAN | Tagged: , , , , , , , | Leave a Comment »

RMAN DATABASE BACKUPS TO TAPE

Posted by Srikrishna Murthy Annam on May 30, 2011

In this article, i am going to show you how to backup a database using RMAN to tape. First verify the tape configuration from the following commands …

$ tdpoconf showenvironment
$ tdpoconf showENVironment -TDPO_OPTfile=tdpo.opt

IBM Tivoli Storage Manager for Databases:
Data Protection for Oracle
Version 5, Release 5, Level 2.0
(C) Copyright IBM Corporation 1997, 2009. All rights reserved.

Data Protection for Oracle Information
Version:              5
Release:              5
Level:                2
Sublevel:             0
Platform:             64bit TDPO Linux86-64

Tivoli Storage Manager Server Information
Server Name:          TDPAURORA
Server Address:       GBTSMSERVER
Server Type:          AIX-RS/6000
Server Port:          1500
Communication Method: TCP/IP

Session Information
Owner Name:           oracle
Node Name:            tdpb600e6tr01
Node Type:            TDPO Linux86-64
DSMI_DIR:             /opt/tivoli/tsm/client/api/bin64
DSMI_ORC_CONFIG:      /opt/tivoli/tsm/client/oracle/bin64/dsm.opt
TDPO_OPTFILE:         tdpo.opt
Password Directory:   /opt/tivoli/tsm/client/oracle/bin64
Compression:          FALSE
License Information:  License file exists and contains valid license data.

[oracle@b600e6tr01 tdpo]$

In this demo i am showing RMAN consistant backup , so shutdown the database and start it again in mount stage.

Then connect to database using rman with catalog database …

[oracle@b600e6tr01 bkup]$ rman target / catalog rman/rman@rmancat

Recovery Manager: Release 10.2.0.4.0 - Production on Mon May 2 08:51:22 2011

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

connected to target database: TESTDB (DBID=38948753088)
connected to recovery catalog database

RMAN>run
{
allocate channel t1 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=tdpo.opt)";
allocate channel t2 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=tdpo.opt)";
allocate channel t3 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=tdpo.opt)";
backup as compressed backupset check logical incremental level 0 database format 'backup_%d_%I_set%s_piece%p_copy%c_%T_%U' TAG=FULL_BACKUP;
backup current controlfile TAG=CURR_CTLFILE;
backup spfile TAG=CURR_SPFILE;
delete obsolete;
}

This will complete the backup of database. But in case if you get any error messages due to tape configuration problems, RMAN will not give you any useful error message. All you have to do is, go to the log file location specified in the configuration file tdpo.opt ( parameter  DSMI_LOG ) and review the logfiles. If you dont have this directory created, the default location for tape log files is $ORACLE_HOME/dbs. These log files will give you some useful error messages.

Rectify the issues  and  execute the RMAN backup script again.

Example error messages from RMAN session :

Starting restore at Apr 13 2011 07:41:20
using channel ORA_AUX_SBT_TAPE_1
using channel ORA_AUX_DISK_1

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/13/2011 07:41:22
RMAN-03015: error occurred in stored script Memory Script
ORA-27191: sbtinfo2 returned error
Additional information: 2

Follow the following video demo showing how to bakckup a database to tape. This is a private video so, send me a personal request if you need access to this video.

Hope it helps

SRI

Posted in RMAN | Tagged: , , , , , , , , , , | 32 Comments »

TIVOLI TAPE CONFIGURATION FOR DATABASE BACKUPS

Posted by Srikrishna Murthy Annam on May 27, 2011

In the present article i am going to explain the tivoli tape configuration for oracle backups to tape. I am explaining this considering the oracle DBAs and not from the scratch how it should be installed.
DBAs need to configure the tape backups after system administrators installing the tape libraries.
DBAs start their configuration with the confirmation that the tape libraries are installed properly. To check the tape installation , try to execute the commands tdpoconf or tdposync and if they are not found, get the installation directory from the system admins and include the directory in the PATH env variable. Then  execute the command again and you should be able to execute the commands tdpoconf and tdposync successfully. If you still not able to execute, check if the tape libraries are installed for 32bit or 64bit. Make proper corrections that these executable are linked to correct bit version corresponding to your OS.

Example :

[root@b600e6tr01 bin]# ls -lrt tdpo*
lrwxrwxrwx 1 root root 42 Dec 21 20:56 tdposync -> /opt/tivoli/tsm/client/oracle/bin/tdposync
lrwxrwxrwx 1 root root 42 Dec 21 20:56 tdpoconf -> /opt/tivoli/tsm/client/oracle/bin/tdpoconf
[root@b600e6tr01 bin]#

[root@b600e6tr01 bin]# ln -s /opt/tivoli/tsm/client/oracle/bin64/tdpoconf tdpoconf
[root@b600e6tr01 bin]# ln -s /opt/tivoli/tsm/client/oracle/bin64/tdposync tdposync
[root@b600e6tr01 bin]# ls -lrt tdpo*
lrwxrwxrwx 1 root root 44 May  2 02:12 tdpoconf -> /opt/tivoli/tsm/client/oracle/bin64/tdpoconf
lrwxrwxrwx 1 root root 44 May  2 02:12 tdposync -> /opt/tivoli/tsm/client/oracle/bin64/tdposync
[root@b600e6tr01 bin]#

After confirming that the tape libraries are installed properly, now you need to configure the tape configuration to backup the databases. There are two important configuration files which are important to DBAs for configuration. They are tdpo.opt tape configuration file and password file.

Edit the tdpo.opt file and modify the parameter to reflect to your environment. Important parameters to modify in the tdpo.opt file are TDPO_FS,TDPO_NODE and TDPO_OWNER.

Using this modified configuration file, create a password file using command

tdpoconf passw -tdpo_optfile=tdpo.opt

The password file will be of the form TDPO.<node name> where the node name is defined in the tdpo.opt file.

After creating a new password file, modify the parameter TDPO_PSWDPATH in tdpo.opt file again to include the newly created password file.

Then the final step is to check the tape configuration ….

tdpoconf showENVironment -TDPO_OPTfile=tdpo.opt

If you are able to execute the above command successfully, then your tape configuration is complete.

Sample Configuration file :

$ cat tdpo.opt
***************************************************************************
* IBM Tivoli Storage Manager for Databases
*    Data Protection for Oracle
*
* Sample tdpo.opt for the LinuxAMD64 Data Protection for Oracle
*********************************************************************

DSMI_ORC_CONFIG    /opt/tivoli/tsm/client/oracle/bin64/dsm.opt
DSMI_LOG           /var/log/tdp

*TDPO_FS            /tdp_<sid>
TDPO_FS             /tdp_TESTDB
TDPO_NODE           tdpb600e6tr01
TDPO_OWNER          oracle
TDPO_PSWDPATH      /opt/tivoli/tsm/client/oracle/bin64

*TDPO_DATE_FMT      1
*TDPO_NUM_FMT       1
*TDPO_TIME_FMT      1

*TDPO_MGMT_CLASS_2   mgmtclass2
*TDPO_MGMT_CLASS_3   mgmtclass3
*TDPO_MGMT_CLASS_4   mgmtclass4

[oracle@b600e6tr01 tdpo]$

NOTE : The * mark in the above file indicates that  the parameter is commented.

$ tdpoconf showENVironment -TDPO_OPTfile=tdpo.opt

IBM Tivoli Storage Manager for Databases:
Data Protection for Oracle
Version 5, Release 5, Level 2.0
(C) Copyright IBM Corporation 1997, 2009. All rights reserved.

Data Protection for Oracle Information
Version:              5
Release:              5
Level:                2
Sublevel:             0
Platform:             64bit TDPO Linux86-64

Tivoli Storage Manager Server Information
Server Name:          TDPAURORA
Server Address:       GBTSMSERVER
Server Type:          AIX-RS/6000
Server Port:          1500
Communication Method: TCP/IP

Session Information
Owner Name:           oracle
Node Name:            tdpb600e6tr01
Node Type:            TDPO Linux86-64
DSMI_DIR:             /opt/tivoli/tsm/client/api/bin64
DSMI_ORC_CONFIG:      /opt/tivoli/tsm/client/oracle/bin64/dsm.opt
TDPO_OPTFILE:         tdpo.opt
Password Directory:   /opt/tivoli/tsm/client/oracle/bin64
Compression:          FALSE
License Information:  License file exists and contains valid license data.

[oracle@b600e6tr01 tdpo]$

Now backups are performed by configuring a channel to tape using above tape configuration file

run
{
allocate channel t1 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=tdpo.opt)";
allocate channel t2 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=tdpo.opt)";
allocate channel t3 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=tdpo.opt)";
....
your backup commands
...

}

Please follow the below video for more details …..( Send me a personal request if you want to access this VIDEO )

Reference Link:
http://publib.boulder.ibm.com/tividd/td/ITSMFD/SC32-9065-00/en_US/HTML/ab5w0009.htm

HOPE IT HELPS

SRI

Posted in RMAN | Tagged: , , , , , , , | 6 Comments »

Refreshing a Database with backups available on Tape

Posted by Srikrishna Murthy Annam on May 4, 2011

In the present article i am going to describe how to refresh a database. Assume that you have some consistant backups available on TAPE for the database to be refreshed.

Just follow the following sequence of steps to refresh a database ….

$sqlplus '/as sysdba'
SQL> select dbid,created,controlfile_created,last_open_incarnation# from v$database;
-- Note down the dbid and incarnation
SQL> archive log list
-- Note down sequence numbers
-- Now create one user and input some data to user. This is to verify  that after refresh we should not get this data.
SQL> create user askm identified by askm;

SQL> grant connect,resource to askm;

SQL> conn askm/askm

SQL> create table test_table as select * from sys.dba_objects;

-- Verify the tape configuration
$ tdpoconf SHOWENVironment

$ tdpoconf SHOWENVironment -tdpo_optfile=tdpo.opt

-- Connect to RMAN and verify the available backups
$ rman target / catalog rman/rman@rmancat

RMAN> list backup summary;

-- Exit from RMAN session and shutdown the database
SQL> shut immediate

RMAN Refresh Script:

$ rman target / catalog rman/rman@rmancat
RMAN> startup nomount;
RMAN> run {
allocate channel t1 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=tdpo.opt)";
restore controlfile;
alter database mount;
restore database;
recover database noredo;
release channel t1;
}
alter database open resetlogs;

Verification Steps :

$sqlplus '/as sysdba'
SQL> select dbid,created,controlfile_created,last_open_incarnation# from v$database;
-- compare incarnation with earlier value
SQL> archive log list
-- compare sequence numbers,it now starts from 0.
SQL> select username ,created from dba_users where username='ASKM';
-- Should return no rows.

Follow the video demo showing how to restore a database from backups available on tape. This is a private video so, send me a personal request if you need access to this video.

Hope it helps
SRI

Posted in RMAN | Tagged: , , , , , , , , | 9 Comments »

Copying files from ASM to file system

Posted by Srikrishna Murthy Annam on January 9, 2011

In the present article i am going to describe the various methods that we have to copy(Not moving,just copying) a datafile from ASM storage to file system storage.

1) Using ASMCMD Utility ( Latest method )
2) Using RMAN ( alternative method )
3) Using DBMS package ( old method )

In each method, we will copy the file from ASM to file system.

Method 1 : Using ASMCMD Utility

In this method, we are copying the datafile “TS1.256.739191187” in diskgroup DG1 from ASM to “ts2.dbf” on to the file system. 

[oracle@dhcppc1 datafiles]$ pwd
/u01/datafiles
[oracle@dhcppc1 datafiles]$ ls
[oracle@dhcppc1 datafiles]$

[oracle@dhcppc1 ~]$ asmcmd
ASMCMD> ls -lt
State    Type    Rebal  Name
MOUNTED  EXTERN  N      DATA/
MOUNTED  EXTERN  N      DG1/
MOUNTED  EXTERN  N      FRA/
MOUNTED  EXTERN  N      OCR/
ASMCMD> cd dg1
ASMCMD> cd testdb/datafile
ASMCMD> ls -lt
Type      Redund  Striped  Time             Sys  Name
DATAFILE  UNPROT  COARSE   DEC 31 13:00:00  Y    TS1.256.739191187
ASMCMD> cp TS1.256.739191187 /u01/datafiles/ts2.dbf
copying +dg1/testdb/datafile/TS1.256.739191187 -> /u01/datafiles/ts2.dbf
ASMCMD>

[oracle@dhcppc1 datafiles]$ ls -lrt
total 525208
-rw-r—– 1 oracle oinstall 314580992 Dec 31 13:17 ts2.dbf
[oracle@dhcppc1 datafiles]$

Method 2 : Using RMAN

[oracle@dhcppc1 datafiles]$ pwd
/u01/datafiles
[oracle@dhcppc1 datafiles]$ ls
[oracle@dhcppc1 datafiles]$ 

SQL> create tablespace ts1 datafile ‘+DG1’ size 20m;

Tablespace created.

SQL> select tablespace_name,status from dba_tablespaces where  tablespace_name=’TS1′;

TABLESPACE_NAME STATUS
————— ———
TS1             ONLINE

SQL> select file_name,status from dba_data_files where file_id=8;

FILE_NAME                                          STATUS
————————————————– ———
+DG1/testdb/datafile/ts1.256.739204397             AVAILABLE

[oracle@dhcppc1 datafiles]$ rman target / nocatalog

Recovery Manager: Release 11.2.0.1.0 – Production on Fri Dec 31 14:34:15 2010

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

connected to target database: TESTDB (DBID=2521935115)
using target database control file instead of recovery catalog

RMAN> copy datafile 8 to ‘/u01/datafiles/ts1.dbf’;

Starting backup at 31-DEC-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=31 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=+DG1/testdb/datafile/ts1.256.739204397
output file name=/u01/datafiles/ts1.dbf tag=TAG20101231T143435 RECID=7 STAMP=739204478
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 31-DEC-10

RMAN>

[oracle@dhcppc1 datafiles]$ ls -lrt
total 525208
-rw-r—– 1 oracle dba      314580992 Dec 31 14:40 ts1.dbf
[oracle@dhcppc1 datafiles]$

Method 3 : Using DBMS package

SQL> select file_name from dba_data_files; 

FILE_NAME
——————————————————————————–
+DATA/testdb/datafile/users.259.738606665
+DATA/testdb/datafile/undotbs1.258.738606665
+DATA/testdb/datafile/sysaux.257.738606663
+DATA/testdb/datafile/system.256.738606661
+DATA/testdb/datafile/example.269.738607053
+DATA/testdb/datafile/test.271.738755277
+TESTDG/testdb/datafile/test1.257.738755445
+DG1/testdb/datafile/ts1.256.739191187

8 rows selected.

SQL> desc dbms_file_transfer
PROCEDURE COPY_FILE
Argument Name                  Type                    In/Out Default?
—————————— ———————– —— ——–
SOURCE_DIRECTORY_OBJECT        VARCHAR2                IN
SOURCE_FILE_NAME               VARCHAR2                IN
DESTINATION_DIRECTORY_OBJECT   VARCHAR2                IN
DESTINATION_FILE_NAME          VARCHAR2                IN
PROCEDURE GET_FILE
Argument Name                  Type                    In/Out Default?
—————————— ———————– —— ——–
SOURCE_DIRECTORY_OBJECT        VARCHAR2                IN
SOURCE_FILE_NAME               VARCHAR2                IN
SOURCE_DATABASE                VARCHAR2                IN
DESTINATION_DIRECTORY_OBJECT   VARCHAR2                IN
DESTINATION_FILE_NAME          VARCHAR2                IN
PROCEDURE PUT_FILE
Argument Name                  Type                    In/Out Default?
—————————— ———————– —— ——–
SOURCE_DIRECTORY_OBJECT        VARCHAR2                IN
SOURCE_FILE_NAME               VARCHAR2                IN
DESTINATION_DIRECTORY_OBJECT   VARCHAR2                IN
DESTINATION_FILE_NAME          VARCHAR2                IN
DESTINATION_DATABASE           VARCHAR2                IN

SQL> create directory TEST_DIR as ‘+DG1/testdb/datafile/’;

Directory created.

SQL> create directory TARGET_DIR as ‘/u01/datafiles/’;

Directory created.

SQL> !ls -lrt /u01/datafiles/
total 0

SQL> BEGIN
dbms_file_transfer.copy_file(source_directory_object =>
‘TEST_DIR’, source_file_name => ‘ts1.256.739191187’,
destination_directory_object => ‘TARGET_DIR’,
destination_file_name => ‘ts1.dbf’);
END;
/   2    3    4    5    6    7

PL/SQL procedure successfully completed.

SQL> SQL>
SQL> !ls -lrt /u01/datafiles/
total 307512
-rw-r—– 1 oracle dba 314580992 Dec 31 13:12 ts1.dbf

SQL> select file_name from dba_data_files where tablespace_name=’TS1′;

FILE_NAME
——————————————————————————–
+DG1/testdb/datafile/ts1.256.739191187

SQL>

Hope it helps

SRI

Posted in ASM, Database Articles, RMAN | Tagged: , , , , | 7 Comments »

RMAN COLD BACKUP FOR RAC , HOW ?

Posted by Srikrishna Murthy Annam on August 26, 2010

What is meant by COLD BACKUP? Is it possible to take COLD BACKUP with RMAN?

In the normal backup and recovery terms , COLD BACKUP is the backup taken when the database is completely down. Then how do we connect to database with RMAN when the database is down?
The RMAN differentiates between “inconsistent” and “consistent” backups on the basis of whether the database is OPEN or not during the Backup. It will not use the terms “COLD BACKUP” and “HOT BACKUP”.

For consistance RMAN RAC backup :

  1. Shutdown all the instances in a cluster
  2. connect to any one node and execute the following script

$rman target / nocatalog
RMAN>
run{
startup mount;
allocate channel backup_disk1 type disk format ‘+FRA’;
backup full database;
shutdown immediate;
release channel backup_disk1;
}

Now we have the RMAN cold backup. Does it include online redo logs. How do we restore the RMAN backup taken earlier. Can we directly restore and open the database.

No.

RMAN will not backup online redologs. So when you restore the database from the backup taken above , you cant directly open the database as you dont have the online redologs. You have to open the database with reset logs.

This article is an example to backup RAC database with ASM. When the RAC with ASM Storage provides the high availability , why should we think of cold backup !!!!!!. This articles is only for concepts purpose and the real time RAC backups with RMAN  are completely different.

Hope it helps ….

–SRI

Posted in 11gR2 RAC, ASM, RMAN | Tagged: , , , | 6 Comments »

 
%d bloggers like this: