Sie sind auf Seite 1von 33

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

DATABASE RECOVERY
Database Recovery having 2 types.

COMPLETE

INCOMPLETE - DATA LOSS (CAN RECOVER TO A CERTAIN TIME OR SCN).

- NO DATA LOSS

We can perform complete recovery, if we lost only datafiles.


We can perform incomplete recovery, if we lost either redolog files, control files, archivelog
files.
INCOMPLETE RECOVERY is possible in 3 ways.

UNTIL SCN

UNTIL TIME

UNTIL CANCEL (Always we can use this method).

RECOVER CRD FILES IN NOARCHIVELOG MODE


SYS> select name, log_mode, open_mode from v$database;
NAME

LOG_MODE

OPEN_MODE

--------- ------------ ---------ROSE

NOARCHIVELOG READ WRITE

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u03/coldbkp/

SQL> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SYS> conn sham/sham
Connected.
SHAM> create table tab2 as select * from tab1;
Table created.
SHAM> select count(*) from tab2;
COUNT(*)
---------524288
$ cd /u01/app/oracle/oradata/rose/
$ rm *.*

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> shut abort;


ORACLE instance shut down.
$ cd /u03/coldbkp/
[oracle@oel5 coldbkp]$ cp * /u01/app/oracle/oradata/rose/
SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SYS> conn sham/sham
Connected.
SHAM> select count(*) from tab2;
select count(*) from tab2
*
ERROR at line 1:
ORA-00942: table or view does not exist

RECOVER CRD FILES IN ARCHIVELOG MODE


SYS> select status from v$instance;
STATUS
-----------OPEN
SYS> alter database close;
Database altered.
SYS> alter database archivelog;
Database altered.
SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SYS> select name, log_mode, open_mode from v$database;
NAME

LOG_MODE

OPEN_MODE

--------- ------------ ---------ROSE

ARCHIVELOG

READ WRITE

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u03/coldbkp/

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.

SYS> archive log list;


Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

88

Next log sequence to archive

90

Current log sequence

90

SYS> conn sham/sham


Connected.
SHAM> create table tab2 as select * from tab1;
Table created.
SHAM> insert into tab2 select * from tab1;
524288 rows created.
SHAM> /
524288 rows created.
SHAM> /
524288 rows created.
SHAM> /
524288 rows created.
SHAM> commit;
Commit complete.
SHAM> select count(*) from tab2;
COUNT(*)
---------4718592
SYS> archive log list;
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

104

Next log sequence to archive

106

Current log sequence

106

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

$ cd /u01/app/oracle/oradata/rose/
[oracle@oel5 rose]$ rm -rf *
[oracle@oel5 rose]$ ls -l
total 0
SYS> shut immediate;
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/rose/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SYS> shut abort;
ORACLE instance shut down.
$ cd /u03/coldbkp/
[oracle@oel5 coldbkp]$ cp *

/u01/app/oracle/oradata/rose/

SYS> startup mount;


ORACLE instance started.
..
[Trimmed]
Database mounted.
SYS> select file#, checkpoint_change# from v$datafile;
FILE#

CHECKPOINT_CHANGE#

--------- -----------------1

714338

714338

714338

714338

714338

SYS> alter database recover automatic using backup controlfile until cancel;
alter database recover automatic using backup controlfile until cancel
*
ERROR at line 1:
ORA-00279: change 736465 generated at 09/22/2014 19:48:08 needed for thread 1
ORA-00289: suggestion:
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_09_22/o1_mf_1_106_%u_.arc
ORA-00280: change 736465 for thread 1 is in sequence #106
ORA-00278: log file
'/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_09_22/o1_mf_1_106_%u_.arc'
no longer needed for this recovery
ORA-00308: cannot open archived log
'/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_09_22/o1_mf_1_106_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> recover cancel;


Media recovery complete.
SYS> @df.sql;
FILE#

CHECKPOINT_CHANGE#

---------- ----------------1

736465

736465

736465

736465

736465

SYS> select open_resetlogs from v$database;


OPEN_RESETL
----------REQUIRED
SYS> alter database open resetlogs;
Database altered.
SYS> archive log list;
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

Next log sequence to archive

Current log sequence

SHAM> conn sham/sham


Connected.
SHAM> select count(*) from tab2;
COUNT(*)
---------3670016
NOTE: We performed recovery, but it is Incomplete Recovery.
LOSS OF NON SYSTEM DATAFILE
SYS> select name, log_mode, open_mode from v$database;
NAME

LOG_MODE

OPEN_MODE

--------- ------------ ---------ROSE

ARCHIVELOG READ WRITE

SYS> conn sham/sham


Connected.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SHAM> select count(*) from tab1;


COUNT(*)
---------150000
SHAM> select count(*) from tab2;
COUNT(*)
---------150000
SYS> archive log list
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

67

Next log sequence to archive

69

Current log sequence

69

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u02/coldbkp/

SYS> startup
ORACLE instance started.
..
[Trimmed]
Database opened.
SHAM> insert into tab1 select * from tab1;
150000 rows created.
SHAM> /
300000 rows created.
SHAM> /
600000 rows created.
SHAM> insert into tab2 select * from tab1;
600000 rows created.
SHAM> /
1200000 rows created.
SHAM> /
1200000 rows created.
SHAM> select count(*) from tab1;
COUNT(*)
---------1200000

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SHAM> select count(*) from tab2;


COUNT(*)
---------2400000
SHAM> commit;
Commit complete.
SYS> archive log list;
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

90

Next log sequence to archive

92

Current log sequence

92

SYS> select name from v$datafile;


NAME
-------------------------------------------/u01/app/oracle/oradata/rose/system01.dbf
/u01/app/oracle/oradata/rose/undotbs01.dbf
/u01/app/oracle/oradata/rose/sysaux01.dbf
/u01/app/oracle/oradata/rose/users01.dbf
/u01/app/oracle/oradata/rose/example01.dbf
SYS> ! rm -rf /u01/app/oracle/oradata/rose/users01.dbf
SYS> create table tab3 as select * from tab2;
create table tab3 as select * from tab2
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata/rose/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SYS> alter database datafile 4 offline;
Database altered.
SYS> select file#, status from v$datafile where file#=4;
FILE# STATUS
-------- ----4

RECOVER

SYS> select * from v$recover_file;


FILE# ONLINE_STATUS
-----4

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

OFFLINE

ERROR
------------FILE NOT FOUND

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

$ cd /u02/coldbkp/
$ cp users01.dbf /u01/app/oracle/oradata/rose/
$ sqlplus / as sysdba
SYS> recover datafile 4;
ORA-00279: change 1371836 generated at 09/24/2014 01:47:26 needed for thread 1
ORA-00289: suggestion:
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_09_24/o1_mf_1_68_b23pdcvz_.arc
ORA-00280: change 1371836 for thread 1 is in sequence #68
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
...
...
..
Log applied.
Media recovery complete.
SYS> alter database datafile 4 online;
Database altered.
SYS> conn sham/sham
Connected.
SHAM> select count(*) from tab1;
COUNT(*)
---------1200000
SHAM> select count(*) from tab2;
COUNT(*)
--------2400000
NOTE: If we configure NOARCHIVELOG mode, we cannot do complete Recovery. Because archivelogs are
needed for complete recovery, it needs to be applied.

LOSS OF ALL CONTROLFILES IN ARCHIVELOG MODE

SYS> select name, log_mode from v$database;


NAME
LOG_MODE
--------- -----------ROSE
ARCHIVELOG
SYS> select name from v$controlfile;
NAME
-------------------------------------------/u01/app/oracle/oradata/rose/control01.ctl
/u01/app/oracle/oradata/rose/control02.ctl
/u01/app/oracle/oradata/rose/control03.ctl

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> archive log list;


Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

Next log sequence to archive

Current log sequence

SHAM> select * from tab;


TNAME

TABTYPE

CLUSTERID

------------------------------ ------- ---------TAB1

TABLE

TAB2

TABLE

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u02/coldbkp/

SYS> startup
ORACLE instance started.
..
...
[Trimmed]
Database opened.
SYS> conn sham/sham
Connected.
SHAM> create table tab3 as select * from tab1;
Table created.
SHAM> create table tab4 as select * from tab1;
Table created.
SHAM> update tab4 set name='ROSELIN';
1200000 rows updated.
SHAM> update tab3 set name='ROSELIN';
1200000 rows updated.
SYS> archive log list;
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

23

Next log sequence to archive

25

Current log sequence

25

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

$ pwd
/u01/app/oracle/oradata/rose
$ rm *.ctl
$ ls

*.ctl

ls: *.ctl: No such file or directory


SQL> select name from v$datafile;
select name from v$datafile
*
ERROR at line 1:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/rose/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.
$ cd /u02/coldbkp/
$ cp *.ctl /u01/app/oracle/oradata/rose/
SYS> startup mount;
ORACLE instance started.
..
....
[Trimmed]
Database mounted.
SYS> recover database using backup controlfile until cancel;
auto
...

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/rose/system01.dbf'
SYS> recover cancel;
SYS> select member from v$logfile;
MEMBER
----------------------------------------/u01/app/oracle/oradata/rose/redo03.log
/u01/app/oracle/oradata/rose/redo02.log
/u01/app/oracle/oradata/rose/redo01.log
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 1544063 generated at 09/24/2014 15:23:22 needed for thread 1
ORA-00289: suggestion:
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_09_24/o1_mf_1_25_%u_.arc

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

ORA-00280: change 1544063 for thread 1 is in sequence #25


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/rose/redo01.log
Log applied.
Media recovery complete.
SYS> recover cancel;
SYS> alter database open resetlogs;
Database altered.
SHAM> select * from tab;
TNAME

TABTYPE

CLUSTERID

------------------------------ ------- ---------TAB4

TABLE

TAB1

TABLE

TAB2

TABLE

TAB3

TABLE

LOSS OF REDOLOG FILES IN ARCHIVELOG MODE

SYS> select name, log_mode from v$database;


NAME
LOG_MODE
--------- -----------ROSE
ARCHIVELOG
SYS> archive log list;
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

Next log sequence to archive

Current log sequence

SYS> select member from v$logfile;


MEMBER
----------------------------------------/u01/app/oracle/oradata/rose/redo03.log
/u01/app/oracle/oradata/rose/redo02.log
/u01/app/oracle/oradata/rose/redo01.log
SYS> select group#, thread#, sequence#, members, archived, status from v$log;
GROUP#

THREAD#

SEQUENCE#

MEMBERS ARC STATUS

---------- ------- ---------- ---------- --- -------1

NO

CURRENT

YES

UNUSED

YES

UNUSED

SYS> conn sham/sham


Connected.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SHAM> select * from tab;


TNAME

TABTYPE

CLUSTERID

------------------------------ ------- ---------TAB1

TABLE

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u02/coldbkp/

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SYS> conn sham/sham
Connected.
SHAM> create table tab2 as select * from tab1;
Table created.
SHAM> create table tab3 as select * from tab1;
Table created.
SHAM> create table tab4 as select * from tab1;
Table created.
SHAM> update tab1 set name='JO' where id >= 1 and id <= 20;
20 rows updated.
SHAM> update tab2 set name='JOE' where id >=1 and id <=20;
20 rows updated.
SHAM> update tab3 set name='JYO_JO' where id >= 1 and id <=20;
20 rows updated.
SHAM> commit;
Commit complete.
SHAM> select name from tab4 where id=1 or id=2;
NAME
Jo
Jo
SHAM> update tab4 set name='rosalin' where id>=1 and id <=5;
10 rows updated.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> alter system switch logfile;


System altered.
$ cd /u01/app/oracle/oradata/rose/
[oracle@oel5 rose]$ rm -rf *.log
SHAM> create table tab5 as select * from user_objects;
Table created.
SYS> shut abort;
ORACLE instance shut down.
$ cd /u02/coldbkp/
[oracle@oel5 coldbkp]$ cp *.dbf /u01/app/oracle/oradata/rose/
SYS> startup mount;
ORACLE instance started.
..
....
[Trimmed]
Database mounted.
SYS> recover database until cancel;
auto
..
...
[Trimmed]
SYS> alter database open resetlogs;
Database altered.
SYS> conn sham/sham
Connected.
SYS> select * from tab;
TNAME

TABTYPE

CLUSTERID

------------------------------ ------- ---------TAB1

TABLE

TAB2

TABLE

TAB4

TABLE

TAB3

TABLE

SHAM> select * from tab4 where id=1;


NAME
rosalin
SHAM> select * from tab5;
select * from tab5
*
ERROR at line 1:
ORA-00942: table or view does not exist

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

STEPS TO RECOVER REDO LOG FILES IN NOARCHIVE MODE


STEP 1: SQL> shut immediate;
STEP 2: SQL>! cp /u03/coldbkp/*.dbf /u01/app/oracle/product/oradata/sham/
STEP 3: SQL>! cp /u03/coldbkp/*.ctl /u01/app/oracle/product/oradata/sham/
Step 4: SQL> recover database until cancel;
STEP 5: SQL> alter database open resetlogs;

LOSS OF REDO LOG FILES IN NOARCHIVE MODE


SYS> select name, log_mode from v$database;
NAME

LOG_MODE

--------- -----------ROSE

NOARCHIVELOG

SYS> conn sham/sham


Connected.
SHAM> select * from tab;
TNAME

TABTYPE

CLUSTERID

------------------------------ ------- ---------TAB1

TABLE

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u02/coldbkp/

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SYS> conn sham/sham
Connected.
SHAM> create table tab2 as select * from tab1;
Table created.
SHAM> create table tab3 as select * from tab1;
Table created.
SHAM> create table tab4 as select * from tab1;
Table created.
$ cd /u01/app/oracle/oradata/rose/
[oracle@oel5 rose]$ rm -rf *.log

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> shut abort;


ORACLE instance shut down.
$ cd /u02/coldbkp/
[oracle@oel5 coldbkp]$ cp *.dbf /u01/app/oracle/oradata/rose/
[oracle@oel5 coldbkp]$ cp *.ctl /u01/app/oracle/oradata/rose/
SYS> startup mount;
ORACLE instance started.
..
....
[Trimmed]
Database mounted.
SYS> recover database until cancel;
SYS> alter database open resetlogs;
SYS> conn sham/sham
Connected.
SHAM> select * from tab2;
select * from tab2
*
ERROR at line 1:
ORA-00942: table or view does not exist

LOSS OF SYSTEM TABLESPACE


SQL> select name, log_mode from v$database;
NAME

LOG_MODE

--------- -----------ROSE

ARCHIVELOG

SQL> select name from v$datafile;


NAME
-------------------------------------------/u01/app/oracle/oradata/rose/system01.dbf
/u01/app/oracle/oradata/rose/undotbs01.dbf
/u01/app/oracle/oradata/rose/sysaux01.dbf
/u01/app/oracle/oradata/rose/users01.dbf
/u01/app/oracle/oradata/rose/example01.dbf
SYS> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u02/coldbkp/

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.

LOS S OF DATA FILE WHICH WAS NOT IN THE BACKUP


SQL> select name, log_mode from v$database;
NAME

LOG_MODE

--------- -----------ROSE

ARCHIVELOG

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u03/coldbkp/rose

SYS> startup
ORACLE instance started.
Total System Global Area

746586112 bytes

Fixed Size

1275920 bytes

Variable Size

197134320 bytes

Database Buffers

545259520 bytes

Redo Buffers

2916352 bytes

Database mounted.
Database opened.
SYS> archive log list;
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

Next log sequence to archive

Current log sequence

SYS> select name from v$datafile;


NAME
-----------------------------------------/u01/app/oracle/oradata/rose/system01.dbf
/u01/app/oracle/oradata/rose/undotbs01.dbf
/u01/app/oracle/oradata/rose/sysaux01.dbf
/u01/app/oracle/oradata/rose/users01.dbf
/u01/app/oracle/oradata/rose/example01.dbf

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> create tablespace sample datafile '/u01/app/oracle/oradata/rose/test01.dbf' size 10m;


Tablespace created.
SYS> grant connect, resource to rose identified by rose;
Grant succeeded.
SYS> alter user rose default tablespace sample;
User altered.
SYS> select username, default_tablespace from dba_users where username='ROSE'
USERNAME

DEFAULT_TABLESPACE

------------------------------ ---------------------ROSE

SAMPLE

SYS> conn rose/rose


Connected.
ROSE> create table tab1(id number ,
name varchar2(15),
qual varchar2(15),
city varchar2(15),
mobile number);
Table created.
ROSE> begin
for i in 1..400000 loop
insert into tab1 values(i,'rosalin','m.sc','chennai',1234554321);
commit;
end loop;
end;
/
PL/SQL procedure successfully completed.
ROSE> select count(*) from tab1;
COUNT(*)
------4000000
SYS> ! rm /u01/app/oracle/oradata/rose/sample01.dbf
SYS> ! ls /u01/app/oracle/oradata/rose/sample01.dbf
ls: /u01/app/oracle/oradata/rose/sample01.dbf: No such file or directory
SYS> conn rose/rose
Connected.
ROSE> update tab1 set name='JO' where id>=1 and id <=5000;
5000 rows updated.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

ROSE> update tab1 set name='JYO' where id >= 5001 and id <=10000;
5000 rows updated.
ROSE> update tab1 set name='JYOTIKA' where id >= 10001 and id <=50000;
40000 rows updated.
ROSE> commit;
Commit complete.
ROSE> create table tab2 as select * from tab1;
create table tab2 as select * from tab1
*
ERROR at line 1:
ORA-01116: error in opening database file 6
ORA-01110: data file 6: '/u01/app/oracle/oradata/rose/sample01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SYS> alter tablespace sample offline immediate;

or

Tablespace altered.
SYS> alter database datafile 6 offline;
Database altered
SYS> alter database create datafile '/u01/app/oracle/oradata/rose/sample01.dbf';

(or)

SYS> alter database create datafile '/u01/app/oracle/oradata/rose/sample01.dbf' as


/u01/app/oracle/oradata/rose/sample01.dbf';
Database altered.
SYS> alter tablespace sample online;
alter tablespace sample online
*
ERROR at line 1:
ORA-01113: file 6 needs media recovery if it was restored from backup, or END
BACKUP if it was not
ORA-01110: data file 6: '/u01/app/oracle/oradata/rose/sample01.dbf'
SYS> recover tablespace sample;
ORA-00279: change 417154 generated at 10/01/2014 01:52:59 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_01/o1_mf_1_4_b2p6cf6q_.arc
ORA-00280: change 417154 for thread 1 is in sequence #4
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..
...
[Trimmed]
Log applied.
Media recovery complete.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> altter tablespace sample online;


Tablespace altered.

SYS> select * from tab1 where id=1001 or id=1002;


ID
------

NAME
-------

QUAL

CITY

-------

MOBILE

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

1001

JO

m.sc

chennai

1234554321

1002

JO

m.sc

chennai

1234554321

LOSS OF SINGLE CONTROL FILE


SYS> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------ROSE
ARCHIVELOG
SYS> select name from v$controlfile;
NAME
-------------------------------------------/u01/app/oracle/oradata/rose/control01.ctl
/u02/app/oracle/oradata/rose/control02.ctl
/u03/app/oracle/oradata/rose/control03.ctl
$ cd /u03/app/oracle/oradata/rose/
$ rm control03.ctl
SYS> update rose.tab1 set name='ORACLE';
400000 rows updated.
SYS> select current_scn from v$database;
select current_scn from v$database
*
ERROR at line 1:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u03/app/oracle/oradata/rose/control03.ctl'
ORA-27041: unable to open file Linux Error: 2: No such file or directory
SYS> shut abort;
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp control01.ctl /u03/app/oracle/oradata/rose/control03.ctl
SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> select * from rose.tab1 where id=1 or id=2;


ID

NAME

QUAL

CITY

MOBILE

--- ------- ---------- ---------- ------------1

ORACLE

m.sc

chennai

1234554321

ORACLE

m.sc

chennai

1234554321

LOSS OF UNDO TABLESPACE


SYS> select name, log_mode from v$database;
NAME

LOG_MODE

--------- -----------ROSE

ARCHIVELOG

SYS> select name from v$datafile;


NAME
------------------------------------------/u01/app/oracle/oradata/rose/system01.dbf
/u01/app/oracle/oradata/rose/untbs01.dbf
/u01/app/oracle/oradata/rose/sysaux01.dbf
/u01/app/oracle/oradata/rose/users01.dbf
/u01/app/oracle/oradata/rose/example01.dbf
SYS> show parameter undo;
NAME

TYPE

VALUE

------------------------------------ ----------- ---------undo_management

string

AUTO

undo_retention

integer

900

undo_tablespace

string

UNDOTBS1

SYS> shut immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u03/coldbkp/rose

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SYS> conn rose/rose
Connected.
ROSE> update tab1 set name='JO_JYO';
1000000 rows updated.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG


$ rm /u01/app/oracle/oradata/rose/undotbs01.dbf
$ ls /u01/app/oracle/oradata/rose/undotbs01.dbf
ls: /u01/app/oracle/oradata/rose/undotbs01.dbf: No such file or directory
ROSE> update rose.tab1 set name='JO';
update tab1 set name='JO'
*
ERROR at line 1:
ORA-01116: error in opening database file 2
ORA-01110: data file 2: '/u01/app/oracle/oradata/rose/undotbs01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SYS> alter database datafile 2 offline;
alter database datafile 2 offline
*
ERROR at line 1:
ORA-00603: ORACLE server session terminated by fatal error
SYS> select file#, name , status from v$datafile;
FILE#

NAME

STATUS

/u01/app/oracle/oradata/rose/system01.dbf

SYSTEM

/u01/app/oracle/oradata/rose/undotbs01.dbf

RECOVER

/u01/app/oracle/oradata/rose/sysaux01.dbf

ONLINE

/u01/app/oracle/oradata/rose/users01.dbf

ONLINE

/u01/app/oracle/oradata/rose/example01.dbf

ONLINE

$ cd /u03/coldbkp/rose/
$ cp undotbs01.dbf

/u01/app/oracle/oradata/rose/

ROSE> update rose.tab3 set name='JYO_JO';


update rose.tab3 set name='JYO_JO'
*
ERROR at line 1:
ORA-01122: database file 2 failed verification check
ORA-01110: data file 2: '/u01/app/oracle/oradata/rose/undotbs01.dbf'
ORA-01208: data file is an old version - not accessing current version
SYS> recover datafile 2;
ORA-00279: change 412728 generated at 10/10/2014 22:59:32 needed for thread 1
ORA-00289: suggestion:
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_10/o1_mf_1_2_b3j64mkm_.arc
ORA-00280: change 412728 for thread 1 is in sequence #2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..
[Trimmed]
Log applied.
Media recovery complete.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> recover cancel;


SYS> alter database datafile 2 online;
Database altered.
SYS> select file#, name, status from v$datafile;
FILE#

NAME

STATUS

/u01/app/oracle/oradata/rose/system01.dbf

SYSTEM

/u01/app/oracle/oradata/rose/undotbs01.dbf

ONLINE

/u01/app/oracle/oradata/rose/sysaux01.dbf

ONLINE

/u01/app/oracle/oradata/rose/users01.dbf

ONLINE

/u01/app/oracle/oradata/rose/example01.dbf

ONLINE

POINTS
We cannot "skip" or "exclude" or "drop" the undo datafile for an undo tablespace that was the
active undo tablespace when the database was OPEN. If there was clean shutdown when you dropped
the undo data file then follow different steps that are given below.

LOSS OF UNDO TABLESPACE ( IF DATABASE IS CLEAN SHUTDOWN )

SYS> select name, log_mode from v$database;


NAME
LOG_MODE
--------- -----------SHAM
ARCHIVELOG
SYS> show parameter undo;
NAME

TYPE

VALUE

------------------------------------ ----------- ------undo_management

string

AUTO

undo_retention

integer

900

undo_tablespace

string

UNDOTBS1

SYS> select name from v$datafile;


NAME
--------------------------------------------/u01/app/oracle/oradata/sham/system01.dbf
/u01/app/oracle/oradata/sham/undotbs01.dbf
/u01/app/oracle/oradata/sham/sysaux01.dbf
/u01/app/oracle/oradata/sham/users01.dbf
/u01/app/oracle/oradata/sham/example01.dbf
SYS> alter system set undo_management='MANUAL' scope=spfile;
System altered.
SYS> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

$ mv undotbs01.dbf

undotbs01.dbfx

[oracle@oel5 sham]$ ls -l undo*


-rw-r----- 1 oracle oinstall 293609472 Oct 12 19:59 undotbs01.dbfx
SYS> startup;
ORACLE instance started.
.
..
[Trimmed]
Database mounted.
ORA-01157: cannot identify/lock data file 2 - see DBWR trace file
ORA-01110: data file 2: '/u01/app/oracle/oradata/sham/undotbs01.dbf'
SYS> alter system set undo_management='manual' scope=spfile;
System altered.
SYS> shut immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SYS> startup
ORACLE instance started.
.
..
[Trimmed]
Database mounted.
ORA-01157: cannot identify/lock data file 2 - see DBWR trace file
ORA-01110: data file 2: '/u01/app/oracle/oradata/sham/undotbs01.dbf'
SYS> show parameter undo;
NAME

TYPE

VALUE

------------------------------------ ----------- -------undo_management

string

MANUAL

undo_retention

integer

900

undo_tablespace

string

UNDOTBS1

SYS>alter database datafile


'/u01/app/oracle/oradata/rose/undotbs01.dbf' offline drop;

(or)

SYS> alter database datafile 2 offline drop;


Database altered.
SYS> alter database open;
Database altered.
SYS> drop tablespace undotbs1;
Tablespace dropped.
SYS>create undo tablespace undotbs datafile '/u01/app/oracle/oradata/sham/untbs01.dbf' size 50m;
Tablespace created.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> alter system set undo_tablespace='undotbs' scope=spfile;


System altered.
SYS> alter system set undo_management='auto' scope=spfile;
System altered.
SYS> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS> startup;
ORACLE instance started.
Total System Global Area

746586112 bytes

..

[Trimmed]
Database mounted.
Database opened.
SYS> show parameter undo;
NAME

TYPE

VALUE

------------------------------------ ----------- -----------------------------undo_management

string

AUTO

undo_retention

integer

900

undo_tablespace

string

undotbs

SYS> select name from v$datafile;


NAME
-------------------------------------------/u01/app/oracle/oradata/sham/system01.dbf
/u01/app/oracle/oradata/sham/untbs01.dbf
/u01/app/oracle/oradata/sham/sysaux01.dbf
/u01/app/oracle/oradata/sham/users01.dbf
/u01/app/oracle/oradata/sham/example01.dbf

LOSS OF SYSAUX TABLESPACE


SYS> select name, log_mode from v$database;
NAME

LOG_MODE

--------- -----------ROSE

ARCHIVELOG

SYS> archive log list;


Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

Next log sequence to archive

Current log sequence

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> select name from v$datafile;


NAME
-------------------------------------------/u01/app/oracle/oradata/rose/system01.dbf
/u01/app/oracle/oradata/rose/undotbs01.dbf
/u01/app/oracle/oradata/rose/sysaux01.dbf
/u01/app/oracle/oradata/rose/users01.dbf
/u01/app/oracle/oradata/rose/example01.dbf
SYS> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u03/coldbkp/rose

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SHAM> update tab1 set name='JO';
100000 rows updated.
SHAM> update tab2 set name='JYO';
100000 rows updated.
$ mv sysaux01.dbf sysaux01.dbfx
$ ls -l sysaux01.dbfx
-rw-r----- 1 oracle oinstall 251666432 Oct 12 22:27 sysaux01.dbfx
SYS> alter tablespace sysaux offline;
alter tablespace sysaux offline
*
ERROR at line 1:
ORA-01116: error in opening database file 3
ORA-01110: data file 3: '/u01/app/oracle/oradata/rose/sysaux01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
$ cd /u03/coldbkp/rose/
[oracle@oel5 sham]$ cp sysaux01.dbf /u01/app/oracle/oradata/rose/
SYS> recover datafile 3;
ORA-00283: recovery session canceled due to errors
ORA-01124: cannot recover data file 3 - file is in use or recovery
ORA-01110: data file 3: '/u01/app/oracle/oradata/rose/sysaux01.dbf'

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> alter database datafile 3 offline;


Database altered.
SYS> recover datafile 3;
ORA-00279: change 412137 generated at 10/12/2014 18:53:21 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_12/o1_mf_1_2_b3o0z4qn_.arc
ORA-00280: change 412137 for thread 1 is in sequence #2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
.
..
[Trimmed]
Log applied.
Media recovery complete.
SYS> alter database datafile 3 online;
Database altered.
INCOMPLETE RECOVERY UNTIL TIME / SEQUENCE / CANCEL
A closed or open database backup and archived logs, the time or sequence that the 'until'
recovery needs to be performed. I am going to perform with closed cold) backup.
SQL> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------ROSE
ARCHIVELOG
SYS> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*

/u03/coldbkp/rose

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
SYS> archive log list;
Database log mode

Archive Mode

Automatic archival

Enabled

Archive destination

USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence

Next log sequence to archive

Current log sequence

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> grant connect, resource to sham identified by sham;


Grant succeeded.
SYS> conn sham/sham
Connected.
SHAM> set time on;
17:29:44 SHAM> @sample.sql;
Table created.
PL/SQL procedure successfully completed.
17:32:12 SHAM> select * from tab1 where id=1;
ID

NAME

--

--------

rosalin

QUAL

CITY

-------- ------m.sc

chennai

MOBILE
---------1234554321

17:32:57 SHAM> update tab1 set name='oracle';


100000 rows updated.
17:33:27 SHAM> commit;
Commit complete.
17:33:32 SHAM>update tab1 set name='ORACLEDB' where id=1000;
1 row updated.
17:34:23 SHAM> conn / as sysdba
Connected.
17:35:06 SYS> alter system switch logfile;
System altered.
17:35:12 SYS> /
System altered.
17:35:12 SYS> /
System altered.
17:35:18 SYS> drop user sham cascade;
User dropped.
17:35:57 SYS> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
$ mv *.dbf /u01/
$ ls -l *.dbf
ls: *.dbf: No such file or directory
$ cd /u03/coldbkp/rose/
[oracle@oel5 rose]$ cp *.dbf /u01/app/oracle/oradata/rose/

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

17:36:24 SYS> startup mount


ORACLE instance started.
..
....
[Trimmed]
Database mounted.
17:44:32 SYS>recover automatic database until time '2014-10-15 17:35:10';
Media recovery complete.
17:52:50 SYS> alter database open resetlogs;
Database altered.
17:53:35 SYS> conn sham/sham
Connected.
SHAM> select * from tab;
TNAME
TABTYPE CLUSTERID
------------------------------ ------- ---------TAB1
TABLE
SHAM> select * from tab1 where id=1 or id=1000;
ID

NAME

---- ------

QUAL

CITY

MOBILE

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

oracle

m.sc

chennai

1234554321

1000

ORACLEDB

m.sc

chennai

1234554321

POINTS TO NOTE
To recover to a past point in time you have to RESTORE the database from a backup older than the
recovery point in time. Make a new complete backup, as the database is open in a new incarnation
and previous archived log are not relevant.
LOSS OF TEMPORARY TABLESPACE
SYS> select name, log_mode from v$database;
NAME

LOG_MODE

--------- -----------ROSE

ARCHIVELOG

SYS> select * from v$tablespace;


TS# NAME

INC BIG FLA ENC

---------- ------------------------------ --- --- --- --0 SYSTEM

YES NO

YES

1 UNDOTBS1

YES NO

YES

2 SYSAUX

YES NO

YES

4 USERS

YES NO

YES

3 TEMP

NO

NO

YES

6 EXAMPLE

YES NO

YES

6 rows selected.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> select name from v$tempfile;


NAME
---------------------------------------/u01/app/oracle/oradata/rose/temp01.dbf
SYS> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u01/app/oracle/oradata/rose/
$ cp *.*
$ rm

/u03/coldbkp/rose

/u01/app/oracle/oradata/rose/temp01.dbf

SYS> startup
ORACLE instance started.
..
....
[Trimmed]
Database opened.
$ tail -f /u01/app/oracle/admin/rose/bdump/alert_rose.log
...
Re-creating tempfile /u01/app/oracle/oradata/rose/temp01.dbf

From 10g, Oracle is able to detect the missing temporary file and recreate it on the same location.
SCENARIO II
SYS> select file#, name, status from v$tempfile;
FILE#

NAME

------ ----------------------------------------1

/u01/app/oracle/oradata/rose/temp01.dbf

$ rm

/u01/app/oracle/oradata/rose/temp01.dbf

SYS> conn sham/sham


Connected.
SHAM> select * from tab1 order by id DESC;
..
...

more rows are displayed


$ tail -f /u01/app/oracle/admin/rose/bdump/alert_rose.log
ORA-01116: error in opening database file 201
ORA-01110: data file 201: '/u01/app/oracle/oradata/rose/temp01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

SYS> create temporary tablespace temptbs tempfile


'/u01/app/oracle/oradata/rose/temp01.dbf' size 10m;
Tablespace created.
SYS> alter database default temporary tablespace temptbs;
Database altered.
SYS> drop tablespace temp;
Tablespace dropped.
SYS> select * from v$tablespace;
TS# NAME

INC BIG

FLA

ENC

---------- ----- ---- ----- ----0 SYSTEM

YES

NO

YES

1 UNDOTBS1

YES

NO

YES

2 SYSAUX

YES

NO

YES

4 USERS

YES

NO

YES

6 EXAMPLE

YES

NO

YES

7 TEMPTBS

NO

NO

YES

6 rows selected.
SYS> select name from v$tempfile;
NAME
----------------------------------------/u01/app/oracle/oradata/rose/temp01.dbf

POINTS TO NOTE
UNIX/LINUX provide us with a command that does a safer remove.
$ rm -i <file_name>
$ rm -i undotbs01.dbfx
rm: remove regular file `undotbs01.dbfx'?

RECOVERY COMMANDS POINTS TO NOTE


SQL> alter database recover automatic using backup controlfile until cancel;
SQL> recover database using backup controlfile

until cancel;

SQL> recover database until cancel;


ALTER DATABASE is the basic SQL command to recover. RECOVER is an SQL command that automates
that, asking for the next archivelog. It is the recommended way (from sqlplus or rman).

USING BACKUP CONTROLFILE tells Oracle to assume that there are transactions and redo beyond the
controlfile that is used. i.e. It tells to oracle that you don't have the current control file.
So the recovery should continue beyond what is recorded in the control file. And you will need
to open resetlogs at the end to restart a redo log sequence.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

STEPS TO RECOVER NON SYSTEM TABLESPACE IS MISSING

Recovery of a missing datafile that has no backups (DB is up and running )


Pre Requisites:

All relevant archived logs.

STEP 1 alter tablespace <tbs_name> offline immediate;


STEP 2 alter database create datafile '/path/filename.dbf';
STEP 3 recover tablespace <tbs_name>;
STEP 4 alter tablespace <tbs_name> online;
If the create datafile command needs to be executed to place the datafile on a location different
than the original always use following query given below.
SQL>alter database create datafile '/u01/data/newdata01.dbf' as '/u02/data/newdata01.dbf
If a NON SYSTEM datafile that was not backed up since the last backup is missing, recovery can
be performed if all archived logs since the creation of the missing datafile exist.

Complete Open Database Recovery (Database is Initially closed)


If NON SYSTEM is missing or corrupted and the database crashed, recovery can be performed after
the database is open. Pre requisites:

A closed or open database backup and archived logs.

When startup database we would get ora-1157 & ora-1110 and the name of the missing datafile, the
database will be remained in mount phase, then use OS command cp to restore the missing datafile
to its original location,
STEP 1 $ cp -p /u03/coldbkp/rose/users01.dbf

/u01/app/oracle/ordata/rose/

STEP 2 alter database datafile3 offline;


STEP 3 alter database open;
STEP 4 recover datafile 3;
STEP 5 alter tablespace <tbs_name> online;
In step 2 Tablespace name cannot be used because the database is not opened.

Complete Open Database Recovery


If a NON SYSTEM tablespace is missing or corrupted while the database is open, recovery can be
performed while the database is up and running. Pre requisites are, a closed or open database
backup and archived logs.
Use OS command cp to restore the missing or corrupted datafile to its original location.
STEP 1 $ cp -p /u03/coldbkp/rose/users01.dbf /u01/app/oracle/oradata/rose/users01.dbf
STEP 2 alter tablespace <tbs_name> offline immediate;
STEP 3 recover tablespace <tbs_name>;
STEP 4 alter tablespace <tbs_name> online;

Restore & Recovery of a Datafile to a different location.


If a NON SYSTEM datafile is missing and its original location not available, restore can be made
to a different location and recovery performed. Pre requisites are all relevant archived logs.
Use OS commands to restore the missing or corrupted datafile to the new location.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

STEP 1 $ cp -p /u03/coldbkp/rose/users01.dbf /u02/app/oracle/oradata/rose/users01.dbf


STEP 2 alter tablespace <tbs_name> offline immediate;
STEP 3 alter tablespace <tbs_name> rename datafile '/old_path/user01.dbf' to
'/new_path/users01.dbf';
STEP 4 recover tablespace <tbs_name>;
STEP 5 alter tablespace <tbs_name> online;

Control File Recovery


If control files are missing, database crash. Pre requisites: A backup of your control file and
all relevant archived logs. Database startup gives us (ora-205, missing controlfile, instance start
but database is not MOUNTED. Use OS command cp to restore the missing control file to its
original location:
STEP 1 $ cp -p /u03/coldbkp/rose/*.ctl /u01/app/oracle/oradata/rose/
STEP 3 alter database mount;
STEP 4 recover automatic database using backup controlfile;
STEP 5 alter database open resetlogs;
NOTE: Take a new complete backup, as the database is open in a new incarnation and previous archived
log are not relevant.

Incomplete Recovery, Until Time/Sequence/Cancel


Incomplete recovery means when an archived log is missing, so recovery can only be made until the
previous sequence, or when an important object was dropped, and recovery needs to be made until
before the object was dropped.
Pre requisites are a closed or open database backup and archived logs, the time or sequence that
the 'until' recovery needs to be performed. If the database is open follow given steps,
STEP 1 shutdown abort;
Use OS command cp to restore all datafiles to its original locations:
STEP 2 $ cp -p /u03/coldbkp/rose
STEP 3 startup mount;
STEP 4 recover automatic database until time '2014-01-31:14:40:45';
STEP 5 alter database open resetlogs;
NOTE: Take a new complete backup, as the database is open in a new incarnation and previous
archived log are not relevant. Alternatively we can use instead of until time, until sequence or
until cancel.
STEPS TO RECOVER SYSTEM TABLESPACE IS MISSING
If the system tablespace is missing or corrupted the database cannot be started up so a complete
closed database recovery must be performed. Pre requisites are a closed or open database backup
and archived logs.
Use OS command cp to restore the missing or corrupted system datafile to its original
location.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING COLD BACKUP | ARCHIVELOG Vs NOARCHIVELOG

STEP 1 $ cp -p /u03/coldbkp/rose/system01.dbf /u01/app/oracle/oradata/rose/system01.dbf


STEP 2 startup mount;
STEP 3 recover datafile 1;
STEP 4 alter database open;

IF UNDO TABLESPACE BECOMES UNAVAILABLE


If you receive ORA-01110, follow given steps:
STEP 1 Startup your database in mount mode only.
STEP 2 Change the undo_management parameter to manual and bounce your database in mount mode again.
STEP 3 Drop the undo datafile using the offline option.
STEP 4 Open the database now.
STEP 5 Drop the Undo Tablespace.
STEP 6 Create a new undo tablespace
STEP 7 Change the undo_management parameter to auto:
STEP 8 Bounce(restart) your database.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

Das könnte Ihnen auch gefallen