You are on page 1of 65

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP

COLD BACKUP Vs HOT BACKUP


ONLINE BACKUP

HOT BACKUP
INCONSISTENT BACKUP
OFFLINE BACKUP

COLD BACKUP

CONSISTENT BACKUP

PHYSICAL BACKUPS
Cold backup can be taken after you shutdown the database, now database is unavai
lable for database
users. To perform cold backup, that database can be in ARCHIVELOG or NOARCHIVELO
G mode.
Hot backup is active backup, it can be done when the database is running and dat
a is being updated
or read by database users. We can perform online backup and HOT BACKUP does NOT
require downtime
and database MUST be in ARCHIVELOG mode, because the archiver (ARCH) background
process will make
a copy of online redo log files to archive destination FRA by default.
WHY HOT BACKUP IS INCONSISTENT ?
Once put your database in backup mode, Oracle only freezes the datafile headers,
but it keep
updating the blocks inside the datafile. So their headers are at the same SCN, b
ut the database
blocks are not. The database writer (DBWR) is updating the file.
During hot backup, when we are copying a data file meanwhile, the database is wr
iting to the data
file by DBWR. Oracle database is also writing to the redo. So the split is in th
e copied data
file.
Later, when a recovery occurs, the redo is used to reconcile the split block.
DURING HOT BACKUP WHAT HAPPENS EXACTLY ?
During hot backup oracle database will be in fuzzy state and still users can per
form transactions
which makes backup inconsistent. Once we place a tablespace or database in begin
backup mode, lets
see what happens.
SYS> alter database begin backup;
SYS> alter tablespace <tbs_name> begin backup;
Above any one of the command has been executed, corresponding datafile header wi
ll be freezed i.e.
SCN will NOT be updated on datafile header(s) but datafile is in active state i.
e.
DBWRn writes
dirty blocks to datafile(s).

SYS> alter database end backup;


SYS> alter tablespace <tbs_name> end backup;
After end backup, datafile(s) header will be unfreezed and CKPT process will upd
ate latest SCN
immediately by taking the information from control files. During hot backup easi
ly we can observe
much redo generated because oracle will copy entire data block as redo entry in R
LBC. Many folks
having some misconception around hot backup. Lets us have a look.
SYS> alter tablespace users begin backup;
SHAM> update tab1 set bonus3=1000;
The first change to a data block, the entire block is copied to the redo log buf
fer (part of SGA)
as redo entry which is later moved to the redo log file. i.e. (The entire block is
brought into
the redo log buffer. Oracle writes the first DML for the block. Consecutive (rep
eated) changes to
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
the same block will NOT cause the entire block to be logged into redo log buffer
, but just the
change vectors. i.e. (Subsequent transactions to that block are written as norma
l. Hot backup
generates huge amount of redo data, it is dramatically slows down your database.
Redo_Info.txt
Normally, Oracle logs an entry in the redologs for every change in the database,
but it does NOT
log the whole image of the database block. But during the HOT backup process the
first time a block
is changed, Oracle is logging of full images of changed DB blocks to the redolog
s. So excessive
redo log generation is huge rather than normal mode and also depends on amount o
f block changes
during hot backup. If we keep our entire database in begin backup mode for longe
r duration,
Excessive redo leads to more number of log switches and more number of archives
in the archive
destination. If archive destination is full, Database goes to hung state.
In case of redo log generation, already i said, each block will be recorded into
the redo log files
from RLBC, the first time if the block is changed in hot backup. Whole transacti
on information is
recorded in redolog, thats why entire block is written to redo the first time you
modify it.
FRACTURED BLOCK IN ORACLE
Typically, Oracle database blocks are a multiple of O/S blocks. Oracle default b
lock size is 8k
and OS block size is 4k, Let it be Oracle is writing to the data files at 8kb bl
ock size, while
the OS backup copy is reading 4k. The order in which 4k block is read is determi
ned by the OS and
it is completely independent of oracle.
In user managed backup, an operating system utility can back up a data file at t
he same time DBWR
is updating the file. It is possible the OS utility (cp) command
to read a block in half updated
state, so that the block that is copied to the backup media and that block is up
dated in its first
half, while the second half contains older data. In this case, the block is that
is not consistent
with an SCN.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
The OS copy could read first or second 4k
(half of the oracle block) just consid
er before dbwr
updates the data in that block) Once the block gets updated with new image subse
quently the os
utility copy reads the remaining first or second half of the block.(First 4k blo
ck is written at
one point time while the second 4k
block is written at another point of time. The copy image of
that particular block now contains two splits from different point in time, perh
aps with different
SCNs this is fractured block or split block.
Now you can understand in begin backup mode, why SCN of the datafile header does
NOT change. The
current SCN is recorded in redo but not in datafile. This is ensure oracle will
recover the datafile
contents with redo entries.
When we restore the file which contains (fractured blocks) require recovery beca
use once oracle
read those blocks then the blocks considered as corrupt. We cannot do simple res
tore and must
perform recovery. During recovery, the fractured block will be replaced by the c
omplete block from
redo and just we can apply the change vectors.
Fractured blocks can be prevented during backups by using Recovery Manager. Rman
never copies a
fractured block Rman knows the correct order to read the blocks and it continuou
sly rereads the
block until it gets a consistent image.
Usually Oracle logs an entry in the redologs for each and every change in the da
tabase, but it
does NOT log the whole image of the database block. But during the hot backup or
acle brings the
entire block is copied to the redo log buffer. Fracture block can occur when bac
kup/copy utility
reads at smaller block size than oracle blocks.
POINTS TO REMEMBER DURING HOTBACKUP
Once begin backup command issued,
Corresponding datafile header(s) is freezed.
No more updates are allowed on the datafile(s) header.
The database to know which was the last time the tablespace had a consistent ima
ge of the data.
Database allows read/write operations I/O activity is NOT frozen.
Users can insert/update data to the database.
Full images of changed DB blocks are written to the redologs.
The complete block is recorded to the redo log file if it is modified very first
time.
Subsequent transactions on the block only records the transaction just as normal
.
This is to ensure that we have a full representation of every block that is chan
ged
The hot backup generates "a lot of redo information.
More redo generation "dramatically slows down" the database.
Once the end backup command issued,
Immediately datafile header will be unfreezed.
CKPT process will update latest SCN immediately by taking from controlfile.

The datafile header resumes its regular IO activity.


Taking backup of online redo log files are NOT required and also NOT advisable (
would cause
corruption if used in recovery) because they are written continuously data lost.
Better to take
backup of all archive logs and also these are important for recovery. Once the b
ackup completed,
switch the log file so that the redolog which is being written would be avail to
do recovery.
When we perform recovery the fractured block will be replaced by the whole block
from redo by
applying change vectors.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
WHAT IS SCN - ( SYSTEM CHANGE NUMBER )
It is a logical, internal time stamp for database and is incremented every 3 sec
onds. It is useful
to maintain data consistency. Once the transaction or set of transaction is comm
it then the SCN
is assigned to the transaction. All the datafile headers are having same SCN whe
n the instance is
shutdown normally. Whenever open the database SMON checkS the control file & dat
afile headers. If
the SCN in datafile header is not matching with the controlfile, datafile needs
recovery.
WHAT IS LSN - LOG SEQUENCE NUMBER
A number that uniquely identifies a set of redo records in a redo log file. When
Oracle database
files one online redo log file and switches to a different one, then Oracle data
base automatically
assigns the new file a log sequence number.
If you create a database with two online log files, then the first file is assig
ned log sequence
number 1. When the first file fills and Oracle switches to the second file, it a
ssigns log sequence
number 2; hen it switches back to the first file, it assigns log sequence number
3, and so forth.
HOT BACKUP INSIGHTS
As I said, first the database is required to be in archivelog mode to perform an
hot backup.
SYS> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------SHAM
NOARCHIVELOG
SYS> alter tablespace users begin backup;
alter tablespace users begin backup
*
ERROR at line 1:
ORA-01123: cannot start online backup; media recovery not enabled
SYS> alter database close;
Database altered.
SYS> alter database archivelog;
Database altered.
SYS> shut immediate;
Database dismounted.
ORACLE instance shut down.
SYS> startup;
ORACLE instance started.
..
....
[Trimmed]
Database opened.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
Once a hot backup is started, the database cannot be shutdown with the NORMAL or
IMMEDIATE option.
An error message will indicate the database is in backup mode.
SQL> alter database begin backup;
Database altered.
SQL> shut immediate;
ORA-01149: cannot shutdown - file 1 has online backup set
ORA-01110: datafile1: /u01/app/oracle/oradata/sham/system01.dbf
STEPS TO TAKE HOT BACKUP
In order to decide which files you need to backup issue the following query.
SQL> SELECT NAME "File Need Backup" FROM V$DATAFILE
UNION ALL
SELECT NAME FROM V$CONTROLFILE
UNION ALL
SELECT VALUE FROM V$PARAMETER WHERE NAME= spfile ;
In any version, during hot backup NOT required to take redolog files backup.
LOSS OF FULL DATABASE - RECO VER C / R / D FILES
SYS> select name, log_mode, open_mode from v$database;
NAME
LOG_MODE
OPEN_MODE
--------- ------------ ---------SHAM
ARCHIVELOG
READ WRITE
SYS> 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
3
Current log sequence
3

SQL> select max(sequence#) from v$log;


MAX(SEQUENCE#)
-------------3
SYS> alter database begin backup;
Database altered.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> select current_scn from v$database;
CURRENT_SCN
----------432760
SYS> select * from v$backup;
FILE# STATUS
CHANGE#
TIME
----- ------ ------------ -------1
ACTIVE
432768
29-OCT-14
2
ACTIVE
432768
29-OCT-14
3
ACTIVE
432768
29-OCT-14
4
ACTIVE
432768
29-OCT-14
5
ACTIVE
432768
29-OCT-14
$ cd /u01/app/oracle/oradata/sham/
$ cp *.dbf *.ctl /u03/hotbkp/sham/
SYS> grant connect, resource to sham identified by sham;
Grant succeeded.
SYS> conn sham/sham
Connected.
SHAM> @sample.sql;
Table created.

PL/SQL procedure successfully completed.


Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
SHAM> update tab3 set name= ORACLE ;
936000 rows updated.
SHAM> create table tab4 as select * from tab1;
Table created.
SHAM> commit;
Commit complete.
SYS> update sham.tab5 set name=FINAL;
192000 rows updated.
SYS> alter database end backup;
Database altered.
SYS> alter system archive log current;
System altered.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> select max(sequence#) from v$log;
MAX(SEQUENCE#)
-------------8
SYS> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
6
Next log sequence to archive
8
Current log sequence
8
$ cd /u01/app/oracle/oradata/sham/
[oracle@oel5 sham]$ rm -f *
SYS> shut immediate;
ORA-00210: cannot open the specified control file
ORA-00202: control file: /u01/app/oracle/oradata/sham/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/hotbkp/sham
$ cp *.dbf /u01/app/oracle/oradata/sham/
$ cp *.ctl /u01/app/oracle/oradata/sham/
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> startup mount;
ORACLE instance started.
..
[Trimmed]
Database mounted
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 440398 generated at 10/30/2014 02:15:29 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_8_%u_.arc
ORA-00280: change 440398 for thread 1 is in sequence #8
ORA-00278: log file
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_8_%u_.ar
c no longer
needed for this recovery
ORA-00308: cannot open archived log
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_8_%u_.ar
c
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
SYS> recover cancel;
Media recovery complete.
SYS> alter database open resetlogs;
Database altered.
LOSS OF NON SYSTEM DATAFILE
SYS> select name, log_mode, open_mode from v$database;
NAME
LOG_MODE
OPEN_MODE
--------- ------------ ---------SHAM
ARCHIVELOG READ WRITE
SYS> 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

3
Current log sequence
3
SQL> select max(sequence#) from v$log;
MAX(SEQUENCE#)
-------------3
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> alter database begin backup;
Database altered.
SYS> select current_scn from v$database;
CURRENT_SCN
----------432810
SYS> select * from v$backup;
FILE# STATUS
CHANGE#
TIME
----- ------ ------------ -------1
ACTIVE
554855
29-OCT-14
2
ACTIVE
554855
29-OCT-14
3
ACTIVE
554855
29-OCT-14
4
ACTIVE
554855
29-OCT-14
5
ACTIVE
554855
29-OCT-14
$ cd /u01/app/oracle/oradata/sham/
$ cp *.dbf *.ctl /u03/hotbkp/sham/
SYS> grant connect, resource to sham identified by sham;
Grant succeeded.
SHAM>@sample.sql;
Table created.
PL/SQL procedure successfully completed.

Table created.
PL/SQL procedure successfuly completed.
Table created.
PL/SQL procedure successfully completed.
SHAM> update tab3 set name= ORACLE ;
886000 rows updated.
SHAM> create table tab4 as select * from tab1;
Table created.
SHAM> commit;
Commit complete.
SYS> update sham.tab5 set name=FINAL;
190000 rows updated.
SYS> alter database end backup;
Database altered.
SYS> alter system archive log current;
System altered.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> select max(sequence#) from v$log;
MAX(SEQUENCE#)
-------------8
SYS> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
6
Next log sequence to archive
8
Current log sequence
8
$ mv users01.dbf users01.dbf.tmp
$ ls -l users*
-rw-r----- 1 oracle oinstall 26222592 Oct 30 03:27 users01.dbf.tmp
SYS> conn sham/sham
Connected.
SHAM> create table sample as select * from tab1;
create table sample as select * from tab1
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: /u01/app/oracle/oradata/sham/users01.dbf
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
$ cd /u03/hotbkp/sham/
[oracle@oel5 sham]$ cp users01.dbf /u01/app/oracle/oradata/sham/
SYS> recover datafile 4;
ORA-00283: recovery session canceled due to errors
ORA-01124: cannot recover data file 4 - file is in use or recovery
ORA-01110: data file 4: /u01/app/oracle/oradata/sham/users01.dbf
SYS> alter database datafile 4 offline;
Database altered.
SYS> recover datafile 4;
ORA-00279: change 432814 generated at 10/30/2014 03:09:15 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_3_b52qwyc
z_.arc
ORA-00280: change 432814 for thread 1 is in sequence #3
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..
...
[Trimmed]
Log applied.
Media recovery complete.
SYS> alter database datafile 4 online;
Database altered.
SYS> conn sham/sham
Connected.
SQL> select name from tab5 where id=1;
NAME
----FINAL
LOSS OF SYSTEM DATAFILE
SQL> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------SHAM
ARCHIVELOG
SYS> 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
3

Current log sequence


3
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> select current_scn from v$database;
CURRENT_SCN
----------433581
SYS> alter database begin backup;
Database altered.
SYS> select * from v$backup;
FILE#
STATUS
CHANGE#
TIME
----- -------- --------- --------1
ACTIVE
433660
30-OCT-14
2
ACTIVE
433660
30-OCT-14
3
ACTIVE
433660
30-OCT-14
4
ACTIVE
433660
30-OCT-14
5
ACTIVE
433660
30-OCT-14
$ cd /u01/app/oracle/oradata/sham/
$ cp *.dbf *.ctl /u03/hotbkp/sham/
SYS> grant connect ,resource to rose identified by rose;
Grant succeeded.

SYS> conn rose/rose


Connected.
SYS>@sample.sql;
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
SYS> create table tab4 as select * from tab1;
Table created.
SYS> insert into tab4 select * from tab4;
1500 rows created.
SYS> update tab1 set name= ORACLE ;
256 rows updated.
SYS> commit;
Commit complete.
$ mv system01.dbf system01.dbf.tmp
-rw-r----- 1 oracle oinstall 461381632 Oct 30 05:01 system01.dbf.tmp
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> 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 1
ORA-01110: data file 1: /u01/app/oracle/oradata/sham/system01.dbf
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/hotbkp/sham
cp system01.dbf
/u01/app/oracle/oradata/sham/
SYS> startup mount;
ORACLE instance started.
..
....
[Trimmed]
Database mounted.
SYS> recover database;
ORA-00279: change 433660 generated at 10/30/2014 04:24:12 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_3_b52xl4c
7_.arc
ORA-00280: change 433660 for thread 1 is in sequence #3
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..
...
[Trimmed]
Log applied.
Media recovery complete.
SYS> alter database open;
Database altered.
SYS> select count(*) from tab1;
COUNT(*)
-------256
LOSS OF SYSAUX DATAFILE
SYS> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------SHAM
ARCHIVELOG
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
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> 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
3
Current log sequence
3
SYS> alter database begin backup;
Database altered.
SYS> select current_scn from v$database;
CURRENT_SCN
----------433382
$ cd /u01/app/oracle/oradata/sham
$ cp *.dbf *.ctl /u03/hotbkp/sham/
SYS> grant connect, resource to sham identified by sham;
Grant succeeded.
SHAM> @sample.sql;
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
SHAM> create table tab4 as select * from tab1;
Table created.
SHAM> insert into tab4 select * from tab4;
192000 rows created.
SHAM> update tab4 set name= ORACLE ;
192000 rows updated.
SYS> commit;
Commit complete.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> alter database end backup;
Database altered.
SYS> alter system archive log current;
System altered.
$ mv sysaux01.dbf sysaux01.dbf.tmp
$ ls -l sysaux*
-rw-r----- 1 oracle oinstall 251666432 Oct 30 19:23 sysaux01.dbf.tmp
SYS> alter tablespace sysaux offline;
Tablespace altered.
SYS> alter tablespace sysaux online;
alter tablespace sysaux online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: /u01/app/oracle/oradata/sham/sysaux01.dbf
SYS> alter database datafile 3 offline;
Database altered.
SYS> recover datafile 3;
ORA-00279: change 433386 generated at 10/30/2014 19:23:22 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_3_b54k4r4
n_.arc
ORA-00280: change 433386 for thread 1 is in sequence #3
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 439145 generated at 10/30/2014 19:30:55 needed for thread 1
ORA-00289: suggestion:
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_4_b54k52n
j_.arc
ORA-00280: change 439145 for thread 1 is in sequence #4
ORA-00278: log file
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_3_b54k4r
4n_.arc no
longer needed for this recovery
Log applied.
Media recovery complete.
SYS> alter database datafile 3 online;
Database altered.
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
LOSS OF DATA FILE WHICH WAS NOT IN THE BACKUP
SQL> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------SHAM
ARCHIVELOG
SYS> select name from v$datafile;
NAME
-----------------------------------------/u01/app/oracle/oradata/sham/system01.d
bf
/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 database begin backup;
Database altered.
$ cd /u01/app/oracle/oradata/sham
$ cp *.dbf *.ctl /u03/hotbkp/sham/
SYS> create tablespace sample datafile /u01/app/oracle/oradata/sham/test01.dbf
size 10m;
Tablespace created.
SYS> grant connect, resource to rose identified by rose;
Grant succeeded.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
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
ROSE>@sample.sql;
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
ROSE> create table tab4 as select * from tab1;
Table created.
ROSE> insert into tab4 select * from tab4;
192000 rows created.
ROSE> update tab4 set name= ORACLE ;
192000 rows updated.
ROSE> commit;
Commit complete.
SYS> alter database end backup;
*
ERROR at line 1:
ORA-01260: warning: END BACKUP succeeded but some files found not to be in backu
p mode
SYS> select * from v$backup;
FILE# STATUS
CHANGE# TIME
---------- ------------------ ---------- --------1 NOT ACTIVE
432854 30-OCT-14
2 NOT ACTIVE
432854 30-OCT-14
3 NOT ACTIVE
432854 30-OCT-14
4 NOT ACTIVE
432854 30-OCT-14
5 NOT ACTIVE
432854 30-OCT-14
6 NOT ACTIVE

0
SYS> alter system archive log current;
System altered.
$ mv sample01.dbf sample01.dbf.tmp
[oracle@oel5 sham]$ ls -l sample*
-rw-r----- 1 oracle oinstall 52436992 Oct 30 21:44 sample01.dbf.tmp
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
ROSE> drop table tab1;
Table dropped.
ROSE> create table tab1 as select * from tab2;
create table tab1 as select * from tab2
*
ERROR at line 1:
ORA-01116: error in opening database file 6
ORA-01110: data file 6: /u01/app/oracle/oradata/sham/sample01.dbf
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SYS> alter database create datafile /u01/app/oracle/oradata/sham/sample01.dbf ;
Database altered.
SYS> recover datafile 6;
ORA-00279: change 432977 generated at 10/30/2014 20:59:12 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_3_b54q2hj
r_.arc
ORA-00280: change 432977 for thread 1 is in sequence #3
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 439689 generated at 10/30/2014 21:12:06 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_4_b54q2rj
k_.arc
ORA-00280: change 439689 for thread 1 is in sequence #4
ORA-00278: log file
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_30/o1_mf_1_3_b54q2h
jr_.arc
no longer needed for this recovery
Log applied.
Media recovery complete.
SYS> alter database datafile 6 online;
Database altered.
SYS> conn rose/rose
Connected.
ROSE> select * from tab;
TNAME
TABTYPE
CLUSTERID
------------------------------ ------- ---------TAB2
TABLE
TAB3
TABLE
TAB4
TABLE
TAB5
TABLE

BIN$BqdD7PLiyBbgUKjAg/FVJg==$0 TABLE
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
********
RESTORE & RECOVERY OF A DATAFILE TO A DIFFERENT LOCATION.
SYS> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------ROSE
ARCHIVELOG
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 database begin backup;
Database altered.
SYS> select current_scn from v$database;
CURRENT_SCN
----------412419
SYS> select * from v$backup;
FILE#
STATUS
CHANGE#
TIME
----- ---------- -------------- ---------- --------1
ACTIVE
412111
30-OCT-14
2
ACTIVE
412111
30-OCT-14
3
ACTIVE
412111
30-OCT-14
4
ACTIVE

412111
30-OCT-14
5
ACTIVE
412111
30-OCT-14
$ cd /u01/app/oracle/oradata/sham
$ cp *.dbf *.ctl /u03/hotbkp/sham/
SYS> grant connect, resource to sham identified by sham;
Grant succeeded.
SYS> conn sham/sham
Connected.
SHAM>@sample.sql
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SHAM> insert into tab4 select * from tab4;
252000 rows created.
SHAM> /
252000 rows created.
SHAM> update tab4 set name= ORACLE DATABASE ;
504000 rows updated.
SYS> alter database end backup;
Database altered.
SYS> alter system archive log current;
System altered.
SYS> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
5
Next log sequence to archive
7
Current log sequence
7
$ mv users01.dbf users01.dbf.tmp
[oracle@oel5 sham]$ ls -l users*
-rw-r----- 1 oracle oinstall 32776192 Oct 30 23:49 users01.dbf.tmp
SYS> alter database datafile 4 resize 100m;
alter database datafile 4 resize 100m
*
ERROR at line 1:
ORA-01565: error in identifying file /u01/app/oracle/oradata/sham/users01.dbf
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
$ cd /u03/hotbkp/sham/
[oracle@oel5 sham]$ cp users01.dbf /u02/app/oracle/oradata/sham/
SYS> alter tablespace users rename datafile
/u01/app/oracle/oradata/sham/users01.dbf to /u02/app/oracle/oradata/sham/user
s01.dbf ;
Tablespace altered.
SYS> recover tablespace users;
ORA-00279: change 412411 generated at 10/31/2014 14:19:20 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_31/o1_mf_1_2_b56mo45
9_.arc
ORA-00280: change 412411 for thread 1 is in sequence #2

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


auto
..
...
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
[Trimmed]
ORA-00279: change 424679 generated at 10/31/2014 14:26:29 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_31/o1_mf_1_4_b56mpcb
g_.arc
ORA-00280: change 424679 for thread 1 is in sequence #4
ORA-00278: log file
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_10_31/o1_mf_1_3_b56moy
70_.arc
no longer needed for this recovery
Log applied.
Media recovery complete.
SYS> alter tablespace users online;
Tablespace altered.
SYS> alter tablespace users online;
Tablespace altered.
SYS> select name from v$datafile;
NAME
------------------------------------------------/u01/app/oracle/oradata/sham/sys
tem01.dbf
/u01/app/oracle/oradata/sham/undotbs01.dbf
/u01/app/oracle/oradata/sham/sysaux01.dbf
/u02/app/oracle/oradata/sham/users01.dbf
/u01/app/oracle/oradata/sham/example01.dbf
LOSS OF SINGLE CONTROL FILE WHEN CONTRO LFILES ARE MULTIPLEXED
SYS> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------SHAM
ARCHIVELOG
SYS> select current_scn from v$database;
CURRENT_SCN
----------428605
SYS> select name from v$controlfile;
NAME
-------------------------------------------/u01/app/oracle/oradata/rose/control0
1.ctl
/u02/app/oracle/oradata/rose/control02.ctl
/u03/app/oracle/oradata/rose/control03.ctl
$ cd /u01/app/oracle/oradata/sham/
$ mv control01.ctl control01.ctl.tmp
-rw-r----- 1 oracle oinstall 7061504 Oct 31 18:58 control01.ctl.tmp
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
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: /u01/app/oracle/oradata/sham/control01.ctl
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
$ cp control02.ctl control01.ctl
SYS> select name from v$controlfile;
NAME
----------------------------------------------/u01/app/oracle/oradata/sham/contr
ol01.ctl
/u01/app/oracle/oradata/sham/control02.ctl
/u01/app/oracle/oradata/sham/control03.ctl
LOSS OF ALL CONTROLFILES
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
1
Next log sequence to archive
3
Current log sequence
3
SYS> select name from v$controlfile;
NAME
-------------------------------------------/u01/app/oracle/oradata/rose/control0
1.ctl
/u01/app/oracle/oradata/rose/control02.ctl
/u01/app/oracle/oradata/rose/control03.ctl
SYS> select current_scn from v$database;
CURRENT_SCN
----------412691

SYS> alter database begin backup;


Database altered.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
$ cd /u01/app/oracle/oradata/rose
$ cp *.dbf *.ctl /u03/hotbkp/rose/
SYS> grant connect, resource to sham identified by sham;
Grant succeeded.
SHAM>@sample.sql
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
SHAM> create table tab4 as select * from tab1;
Table created.
SHAM> update tab4 set name= UPDATE_ORACLEDB ;
336000 rows updated.
SHAM> commit;
Commit complete.
SYS> alter database end backup;
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
6
Next log sequence to archive
8
Current log sequence
8
SYS> alter system archive log current;
System altered.
[oracle@oel5 rose]$ mv control01.ctl control01.ctl.tmp
[oracle@oel5 rose]$ mv control02.ctl control02.ctl.tmp
[oracle@oel5 rose]$ mv control03.ctl control03.ctl.tmp
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: /u01/app/oracle/oradata/rose/control01.ctl
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> shut abort;
ORACLE instance shut down.
$ cd /u03/hotbkp/rose/
[oracle@oel5 rose]$ cp *.ctl /u01/app/oracle/oradata/rose/
SYS> startup mount;
ORACLE instance started.
..
....
[Trimmed]
Database mounted.
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 412713 generated at 10/31/2014 01:21:24 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_31/o1_mf_1_2_b57d5oo
m_.arc
ORA-00280: change 412713 for thread 1 is in sequence #2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..

[Trimmed]
ORA-00279: change 428023 generated at 10/31/2014 21:29:59 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_31/o1_mf_1_9_%u_.arc
ORA-00280: change 428023 for thread 1 is in sequence #9
ORA-00278: log file
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_31/o1_mf_1_8_b57dhz
7q_.arc
no longer needed for this recovery
ORA-00308: cannot open archived log
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_31/o1_mf_1_9_%u_.ar
c
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
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
# ON NEW TERMINAL
SYS> select * from v$log;
GROUP#
THREAD#
SEQUENCE#
BYTES
MEMBERS ARC
------- -------- --------- -------- ------- --STATUS
FIRST_CHANGE# FIRST_TIME
--------

------------- ------------1
1
1
52428800
1
YES
INACTIVE
3
1
0
52428800
1
YES
UNUSED
2
1
2
52428800
1
NO
CURRENT
383537
31-OCT-14
0
410135
31-OCT-14
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 428023 generated at 10/31/2014 21:29:59 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_31/o1_mf_1_9_%u_.arc
ORA-00280: change 428023 for thread 1 is in sequence #9
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/rose/redo02.log
ORA-00310: archived log contains sequence 8; sequence 9 required
ORA-00334: archived log: /u01/app/oracle/oradata/rose/redo02.log
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 database using backup controlfile until cancel;
ORA-00279: change 428023 generated at 10/31/2014 21:29:59 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_10_31/o1_mf_1_9_%u_.arc
ORA-00280: change 428023 for thread 1 is in sequence #9
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/rose/redo03.log
Log applied.
Media recovery complete.
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
1
Next log sequence to archive
1
Current log sequence
1
LOST DATAFILES & CONTROLFILES EXCEPT FOR ONLINE REDO LOGS
SQL> select name, log_mode from v$database;
NAME
------ROSE
LOG_MODE
---------ARCHIVELOG

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> alter database begin backup;
Database altered.
SYS> select current_scn from v$database;
CURRENT_SCN
----------412223
SYS> select * from v$backup;
FILE# STATUS
CHANGE# TIME
---------- ------------------ ---------- --------1 ACTIVE
412210 01-NOV-14
2 ACTIVE
412210 01-NOV-14
3 ACTIVE
412210 01-NOV-14
4 ACTIVE
412210 01-NOV-14
$ cd /u01/app/oracle/oradata/rose
$ cp *.dbf *.ctl /u03/hotbkp/rose/
SYS> grant connect, resource to rose identified by rose;
Grant succeeded.
SYS> conn rose/rose
Connected.
ROSE>@sample.sql;
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
ROSE> create table tab4 as select * from tab1;
Table created.
ROSE> insert into tab4 select * from tab4;
216000 rows created.
ROSE> /
216000 rows created.
ROSE> update tab4 set name= UPDATE_FINAL ;
432000 rows updated.
ROSE> commit;
Commit complete.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> alter database end backup;
Database altered.
SYS> alter system archive log current;
System altered.
SYS> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
5
Next log sequence to archive
7
Current log sequence
7
[oracle@oel5 rose]$ mv control* /home/oracle
[oracle@oel5 rose]$ mv *.dbf /home/oracle
SYS> 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
SYS> shut abort;
ORACLE instance shut down.
cd /u03/hotbkp/rose/
[oracle@oel5 rose]$ cp * /u01/app/oracle/oradata/rose/
SYS> startup mount;
ORACLE instance started.
Total System Global Area
373293056 bytes
..
...
[Trimmed]
Database mounted.
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 412210 generated at 11/01/2014 13:02:51 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_2_b593fn8

v_.arc
ORA-00280: change 412210 for thread 1 is in sequence #2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..
...
[Trimmed]
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_6_b593gz
6q_.arc no
longer needed for this recovery
ORA-00308: cannot open archived log
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_7_%u_.ar
c
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: /u01/app/oracle/oradata/rose/system01.dbf
SYS> select * from v$log;
GROUP#
THREAD#
SEQUENCE#
BYTES
MEMBERS
---------- ---------- ------- ------- -------ARC
STATUS
--- ------FIRS
------------1
1
1
52428800
1
YES
INACTIVE
3
1
0
52428800
1

YES
UNUSED
2
1
2
52428800
1
NO
CURRENT
01-NOV-2014
01- NOV-2014
SYS> select * from v$logfile;
GROUP#
STATUS
TYPE
MEMBER
------- -------- ------- -----------------------------------------3
ONLINE
/u01/app/oracle/oradata/rose/redo03.log
2
ONLINE
/u01/app/oracle/oradata/rose/redo02.log
1
ONLINE
/u01/app/oracle/oradata/rose/redo01.log
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 421202 generated at 11/01/2014 13:08:06 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_7_%u_.arc
ORA-00280: change 421202 for thread 1 is in sequence #7
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/rose/redo02.log
ORA-00310: archived log contains sequence 5; sequence 7 required
ORA-00334: archived log: /u01/app/oracle/oradata/rose/redo02.log
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent

ORA-01110: data file 1: /u01/app/oracle/oradata/rose/system01.dbf


SYS> recover database using backup controlfile until cancel;
ORA-00279: change 421202 generated at 11/01/2014 13:08:06 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_7_%u_.arc
ORA-00280: change 421202 for thread 1 is in sequence #7
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/rose/redo01.log
Log applied.
Media recovery complete.
SYS> select open_resetlogs from v$database;
OPEN_RESETL
----------REQUIRED
SYS> alter database open resetlogs;
Database altered.
LOSS OF ONLINE REDOLOG DATAFILE
SYS> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------ROSE
ARCHIVELOG
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> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
1
Next log sequence to archive
2
Current log sequence
2
SYS> alter database begin backup;
Database altered.
SYS> select current_scn from v$database;
CURRENT_SCN
----------412320
SYS> select * from v$backup;
FILE#
STATUS
CHANGE#
TIME

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


ACTIVE
412315
01-NOV-14
2
ACTIVE
412315
01-NOV-14
3
ACTIVE
412315
01-NOV-14
4
ACTIVE
412315
01-NOV-14
5
ACTIVE
412315
01-NOV-14
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
$ cd /u01/app/oracle/oradata/rose/
$ cp *.dbf *.ctl /u03/hotbkp/rose/
SYS> grant connect, resource to rose identified by rose;
Grant succeeded.
SYS> conn rose/rose
Connected.
ROSE>@sample.sql
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
ROSE> create table tab4 as select * from tab1;
Table created.
ROSE> insert into tab4 select * from tab4;
240000 rows created.
SYS> alter database end backup;
Database altered.
SYS> alter system archive log current;
System altered.
SYS> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
7
Next log sequence to archive
9
Current log sequence
9
$ mv *.log
/home/oracle/
ROSE> update tab4 set name= UPDATE FINAL ;
DB will Hang Here
Open alert log and check
$ tail -f /u01/app/oracle/admin/rose/bdump/alert_rose.log
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory

Additional information: 3
Sat Nov 01 14:20:14 IST 2014
Errors in file /u01/app/oracle/admin/rose/bdump/rose_arc1_11845.trc:
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: /u01/app/oracle/oradata/rose/redo03.log
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
SYS> shut abort;
ORACLE instance shut down.
$ cd /u03/hotbkp/rose
$ cp *.dbf /u01/app/oracle/oradata/rose/
$ cp *.ctl /u01/app/oracle/oradata/rose/
SYS> startup mount;
ORACLE instance started.
..
[Trimmed]
Database mounted.
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 411602 generated at 11/01/2014 20:42:57 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_2_b59yd0t
1_.arc
ORA-00280: change 411602 for thread 1 is in sequence #2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..
...
[Trimmed]
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_8_b59yj1
5s_.arc
no longer needed for this recovery
ORA-00308: cannot open archived log
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_01/o1_mf_1_9_%u_.ar
c
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
SYS> select open_resetlogs from v$database;
OPEN_RESETL
----------REQUIRED
SYS> alter database open resetlogs;
Database altered.
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
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
LOSS OF UNDO DATAFILE
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> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
11
Next log sequence to archive

13
Current log sequence
13
SYS> alter database begin backup;
Database altered.
SYS> select current_scn from v$database;
CURRENT_SCN
----------2136570
SYS> select * from v$backup;
FILE#
STATUS
CHANGE#
TIME
------ ---------- --------- ----------1
ACTIVE
2136548
02-NOV-14
2
ACTIVE
2136548
02-NOV-14
3
ACTIVE
2136548
02-NOV-14
4
ACTIVE
2136548
02-NOV-14
5
ACTIVE
2136548
02-NOV-14

$ cp *.dbf
*.ctl
/u03/hotbkp/rose
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> grant connect, resource to sham identified by sham;
Grant succeeded.
SHAM>@sample.sql;
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
Table created.
PL/SQL procedure successfully completed.
SHAM> create table tab4 as select * from tab1;
Table created.
SHAM> insert into tab4 select * from tab4;
768000 rows created.
SHAM> update tab4 set name= ORCL_DATABASE ;
768000 rows updated.
SHAM> commit;
Commit complete.
$ cd /u01/app/oracle/oradata/rose
$ mv undotbs01.dbf
undotbs01.dbf.tmp
$ ls -l undotbs01.dbf
ls: undotbs01.dbf: No such file or directory
SYS> alter database end backup;
alter database end backup
*
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> select * from
FILE#
v$backup;
STATUS
CHANGE#
TIME
------ ---------------- -----------------1
ACTIVE
2136548 02-NOV-14
2
CANNOT OPEN FILE

3
ACTIVE
2136548 02-NOV-14
4
ACTIVE
2136548 02-NOV-14
5
ACTIVE
2136548 02-NOV-14
0
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> alter system archive log current;
System altered.
SYS> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence
22
Next log sequence to archive
24
Current log sequence
24
SYS> shut abort;
ORACLE instance shut down.
$ cd /u03/hotbkp/rose
$ cp *.dbf /u01/app/oracle/oradata/rose/
SYS> startup mount;
ORACLE instance started.
..
....
[Trimmed]
Database mounted.
SYS> recover database using backup controlfile until cancel;
..
...
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
..
...
[Trimmed]
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
ORA-00308: cannot open archived log
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_02/o1_mf_1_24_%u_.a
rc
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: /u01/app/oracle/oradata/rose/system01.dbf
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 2164719 generated at 11/03/2014 01:35:10 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_02/o1_mf_1_24_%u_.ar
c
ORA-00280: change 2164719 for thread 1 is in sequence #24
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/rose/redo02.log
ORA-00310: archived log contains sequence 23; sequence 24 required
ORA-00334: archived log: /u01/app/oracle/oradata/rose/redo02.log
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: /u01/app/oracle/oradata/rose/system01.dbf
SYS> recover database using backup controlfile until cancel;
ORA-00279: change 2164719 generated at 11/02/2014 01:35:10 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ROSE/archivelog/2014_11_02/o1_mf_1_24_%u_.ar
c
ORA-00280: change 2164719 for thread 1 is in sequence #24
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/rose/redo03.log
Log applied.
Media recovery complete.
SYS> alter database open resetlogs;
Database altered.
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
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
RECREATING CONTROLFILE FROM TRACE
SYS> select name, log_mode from v$database;
NAME
LOG_MODE
--------- -----------SHAM
ARCHIVELOG
SYS> alter database backup controlfile to trace as /home/oracle/trace.sql ;
Database altered.
SYS> create pfile from spfile;
File created.
$ ls -l trace.sql
-rw-r--r-- 1 oracle oinstall 633 Oct 31 23:49 trace.sql
CREATING CONTROLFILE SCRIPT
I need
this script for same database so REUSE NOT required to be SET
nge

and NO need to cha

database name also.


Remove any lines that start with -Remove any lines that start with a #
Remove any blank lines in the CREATE CONTROLFILE section.
Remove the line RECOVER DATABASE USING BACKUP CONTROLFILE
Remove the line ALTER DATABASE OPEN RESETLOGS;
Once trace file is generated, need some changes in the trace file using vi edi
tor after removing
all unwanted comments on the top and bottom of the trace file. It should look li
ke shown below.
$ cd /home/oracle/
$ vi trace.sql;
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
$ cd /u01/app/oracle/oradata/sham
$ mv *.ctl /home/oracle/
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: /u01/app/oracle/oradata/sham/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.
POINTS TO NOTE :
We need to add the undocumented parameter _allow_resetlogs_corruption=true in th
e init.ora file.
Otherwise, you cannot open the database using RESETLOGS option. Without oracle
support team Never
ever use oracle undocumented parameters.
$ pwd
/u01/app/oracle/product/10.2.0/db_1/dbs
$ vi initsham.ora
SYS> shut abort;
ORACLE instance shut down.
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

BACKUP AND RECOVERY USING HOT BACKUP | HOT BACKUP Vs COLD BACKUP
SYS> startup nomount pfile= $ORACLE_HOME/dbs/initsham.ora ;
ORACLE instance started.
Total System Global Area
Fixed Size
373293056 bytes
1273780 bytes
Variable Size
113246284 bytes
Database Buffers
255852544 bytes
Redo Buffers
2920448 bytes
SYS>@/home/oracle/trace.sql;
Control file created.
SYS> select open_resetlogs from v$database;
OPEN_RESETL
----------REQUIRED
SYS> alter database open resetlogs;
Database altered.
SYS> select name from v$controlfile;
NAME
------------------------------------------/u01/app/oracle/oradata/sham/control01
.ctl
/u01/app/oracle/oradata/sham/control02.ctl
/u01/app/oracle/oradata/sham/control03.ctl
Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

You might also like