Documente Academic
Documente Profesional
Documente Cultură
Scenario : The scenario presents the kinds of backups taken at the site, their
frequency and other background information, including version of the
database.
Problem: This section describes the kind of failure that occurred or the
situation the DBA is facing while operating the database.
Solution; This section gives all the possible alternatives to recover the
database for a specified failure.
CASE 1 :
Scenario : John uses an Oracle Database to maintain the inventory of his
grocery store. Once every week, he runs a batch job to insert, update and
delete data in his database. He uses a stand-alone UNIX machine running
Oracle 8.1.7. Johns starts the database up in the morning at 8A.M., and shuts
it down at 5 P.M., and operates the database all day in NOARCHIVELOG
mode. He takes an offline backup (cold backup) of the database once a
week, or every Sunday by copying all the datafiles, log files and control files
to tape.
Problem : On a Wednesday morning, John realized that he had lost a datafile
that contained all the user data. He tried to start up the database using the
STARTUP OPEN command got the following error;
ORA-01157 :cannot identify data file 4 file not found
ORA-01110: data file 4 :/home/oracle/orahome1/oradata/ora1/users01.dbf
He realized that he had accidentally deleted one of the data files while trying
to free some space on the disk.
How would he resolve this problem ?
How much data would you lose ?
Write down the steps you would perform to recover your database .
(Note: while doing tablespace recovery all the datafiles belonging to the
tablespace should be offline).
CASE 5
Scenario : Anita is a DBA in a banking firm. She administers an Oracle 8.1.7
database on a Unix Server. She stores all the user data in the USERS
tablespace, index data in the INDEXES tablespace, and all the rollback
segments in the RBS tablespace. In addition, she has other tablespaces to
store data for various banking applications. Since the database operates
24*7, she has an automated procedure to take online backups every night. In
addition, she takes an export once a month of all the important tables in the
database.
Problem: On Monday morning, due to a media failure, all the data files that
belong to the rollback segment tablespace RBS was lost. It was the
beginning of the week and a lot of applications needed to be run against the
database, so she decided to do an online recovery. Once she took the datafile
offline and opened the database, she tried to select from a user table and got
the following error:
ORA-00376 : file 2 cannot be read at this time
(File 2 happens to be one of the datafiles that belong to the rollback segment
tablespace.)
Simulation:
SQL> connect internal;
SQL> create table case5
(c1 number) tablespace users;
SQL> select * from case5;
SQL> commit;
SQL> set transaction use rollback segment r01;
SQL> insert into case5 values (5);
SQL> shutdown abort;
SQL> host rm /home/oracle/orahome1/oradata/ora1/rbs01.dbf
How would you perform a recovery ?
Solution for case 5:
An important step you need to perform is modify the initialization file and
comment out the ROLLBACK_SEGMENTS parameter. If this is not done,
Oracle will not be able to find the rollback segments and will not be able to
open the database.
SQL> startup mount;
SQL> alter database datafile
/home/oracle/orahome1/oradata/ora1/rbs01.dbf offline;
SQL> alter database open;
SQL>select * from case5;
(error indicating file cannot be read at this time)
SQL> select segment_name, status from dba_rollback_segs;
(some of the rollback segments will indicate they need recovery)
SQL> host cp /home/oracle/backup/rbs01.dbf
/home/oracle/orahome1/oradata/ora1/rbs01.dbf
SQL>recover tablespace rbs;
SQL>alter tablespace rbs online;
SQL>select * from case5 ;
No rows selected
SQL>select segment_name, status from dba_rollback_segs;
(the segments continue to show that that they need recovery. To take of this
issue)
SQL> alter rollback segment r01 online;
CASE 6 :
Scenario : Sara works in a software company as a DBA to administer a small
development database on a UNIX machine. She created a 500MB database.
She decided to mirror the control files but not the online redo logs, so
created the database with three log groups with one member each. Her
backup strategy includes taking online backups twice a week and a full
database export once a week.
Problem: A power surge caused the database to crash and also caused a
media failure, losing all the online log files. All the data files and the current
control files are intact.
Although the data files are OK, after the crash they cannot be used because
instance recovery cannot be performed (since all the log files are lost).
If any of the unarchived log files are lost, crash recovery cannot be
performed and instead media recovery needs to be performed.
Simulation:
SQL> shutdown abort;
SQL> host rm /home/oracle/orahome1/oradata/ora1/*.log
Solution to Case 6 :
You would need to perform a Cancel base Incomplete recovery
Restore all the datafiles:
$cp /home/oracle/orahome1/backup/*.dbf
/home/oracle/orahome1/oradata/ora1/
SQL>connect internal
SQL> startup mount;
SQL>recover database until cancel;
(Cancel the recovery when oracle asks to apply the redo logs that are lost)
SQL>alter database open resetlogs;
SQL>shutdown
SQL>exit
$ls
(The online redo logs will be automatically created by Oracle as part of the
database open. This is required for normal operation of the database).
CASE 7
Scenario : Kevin is one of the DBAs of a Fortune 500 Financial Company,
and maintains one of the companys most crucial databases. A UNIX
machine is used to store a 500 gigabyte database using Oracle 8.1.6. The
database operates 24*7 with 200 to 250 concurrent users on the system at
any one time. There are 250 tablespaces and the backup procedure involves
keeping the tablespaces in hot backup mode and taking an online backup.
Each log file is 10MB. Between issuing the BEGIN BACKUP and END
BACKUP oracle generates about 50 archive log files.
Problem : On Friday afternoon, while taking hot backups, the machine
crashed bringing the database down. As this is a mission critical workshop,
Kevin needed to bring the database up as fast as possible. Once the machine
was booted, he tried to start the database and Oracle asked for media
recovery starting from log sequence number 2300. The current online log
file has a sequence number 2335, which means 35 log files needed to be
applied before the database could be opened.
Simulation:
SQL>connect internal
SQL>startup
SQL>archive log list
(Database is in archivelog mode, with automatic archiving enabled)
SQL>alter tablespace test begin backup;
SQL>host cp /home/oracle/orahome1/oradata/ora1/test1.dbf
/home/oracle/hbackup/test1.dbf
SQL> create table case 7 (c1 number) tablespace test;
SQL> insert into case7 values (7);
SQL>commit;
SQL> alter system switch logfile;
SQL>shutdown abort;
SQL> startup mount;
Solution to Case 7
Alter database datafile /home/oracle/orahome1/oradata/ora1/test1.dbf end
backup;
CASE 8
Scenario : Jane uses an Oracle 8i database for windows on her PC for her
home business. She maintains a small 20MB database and takes regular cold
backups. Her backup procedure involves shutting down the database and
copying the data files, log files and control file to floppy disks. She
maintains only one copy of the control file and doesnt mirror the control file
because she thinks mirroring the control file doesnt make sense since she
has only one hard disk.
Problem : Jane accidentally deleted her control file. Since she didnt have a
copy of the control file, she copied the backup control file and tried to start
up the database. While copying the database, Oracle complained that an old
control file was being used.
Simulation :
SQL> connect internal
SQL> startup open;
SQL> select name, status, enabled from v$datafile;
Name
Status
---------------/home/oracle/system01.dbf
SYSTEM
/home/oracle/rbs01.dbf
ONLINE
/home/oracle/tools01.dbf
ONLINE
/home/oracle/users01.dbf
ONLINE
/home/oracle/test1.dbf
ONLINE
/home/oracle/temp.dbf
ONLINE
Enabled
-------------------READ WRITE
READ WRITE
READ WRITE
READ WRITE
READ ONLY
READ WRITE
C1
---6
CASE 9
Scenario : Matt, the DBA of a financial firm administers a 100GB database
on an IBM mainframe running Oracle 8, release 8.1.7. Matt operates the
database in ARCHIVELOG mode. Every night, the system manager takes an
OS backup of the system. As part of this backup, all Oracle database files
are copied from DASD to tape. The Oracle database is shutdown before the
backups are taken. Matt takes a full database export every three months and
incremental exports once a month.
Problem : One day, while doing space management, Matt added a small
datafile to a tablespace, then decided that he really needed more space. He
didnt want to add another datafile, but instead decided to replace the smaller
datafile with a new, bigger datafile. Since a datafile cannot be dropped, he
merely took the new datafile offline and added a larger datafile to the same
tablespace. He deleted the datafile at the OS level, assuming Oracle would
never need the file since he hadnt added any data to it, and also because it
was offline. Shortly after he started running an application, he got the error:
ORA-00376 : file 6 cannot be read at this time
(file 6 is the same datafile that he had taken offline and deleted earlier)
Solution : Identify three methods in which you could recover from this
problem.
What would have been the most appropriate solution to the problem Matt
had ?
Solution to Case 9
When you take a datafile offline and open the database, you can apply one of
the following three methods.
a) Restore the datafile that was taken offline from a backup and do a data
file recovery.
ARCHIVELOG
ENABLED
/home/oracle/orahome1/archives
60
62
62
ARCHIVELOG
ENABLED
/home/oracle/orahome1/archives
63
65
65
SQL>shutdown abort
SQL>host rm /home/oracle/orahome1/oradata/ora1/*.dbf (Simulates
a loss of all datafiles)
SQL>host cp /home/oracle/orahome1/backup/*.dbf
/home/oracle/orahome1/oradata/ora1 (Restoring all the datafiles)
Solution : How would you recover from the above problem.
Solution to CASE 10
We present two recovery methods. The first method is the recovery
procedure used by Nancy in this example. The second method is a
better way of doing recovery, and is recommended by Oracle since the
log file(s) need to be applied only once.
Method 1
SQL>startup mount;
SQL> recover database;
(Applying the logs)
SQL>alter database open;
SQL>alter tablespace users online;
ORA-01113 : file 4 needs media recovery
ORA-01110 : data file 4 : /home/oracle/orahome1/oradata/ora1/users01.dbf
Method 2
SQL> startup mount;
SQL>select * from v$datafile;
SQL> select name, status, enabled from v$datafile;
Name
Status
---------------/home/oracle/system01.dbf
SYSTEM
/home/oracle/rbs01.dbf
ONLINE
/home/oracle/tools01.dbf
ONLINE
/home/oracle/users01.dbf
OFFLINE
/home/oracle/test1.dbf
ONLINE
/home/oracle/temp.dbf
ONLINE
Enabled
-------------------READ WRITE
READ WRITE
READ WRITE
DISABLED
READ ONLY
READ WRITE
Enabled
-------------------READ WRITE
READ WRITE
READ WRITE
DISABLED
READ ONLY
READ WRITE
TABLESPACE_NAME
-----------------------------SYSTEM
RBS
TOOLS
USERS
TEST
TEMP
STATUS
----------ONLINE
ONLINE
ONLINE
OFFLINE
ONLINE
ONLINE