Professional Documents
Culture Documents
Backup and Recovery - 252
Backup and Recovery - 252
1.What are the types of incomplete media recovery available in oracle database?
Following were the types of incomplete media recovery available in oracle database. we will see each of the
in detail in respective posts.
Time based recovery
Log sequence recovery
Change based recovery (SCN)
Cancel based recovery
Following are the different questions and answers regarding Backup and Recovery (RMAN) of Oracle
Database.
Process failure Session failure due to network or abnormal termination of oracle server process.
Failure of database functioning like SGA and background process are unable
Instance failure
continue functioning in the server due server problem
27. What are the different tools are available for hot backup? Is it preferable to take it manually all the time or
it depends on the size of the database?
- hot backup(online backup): A backup of one or more data files taken while a database is open and the
datafiles are online
- user-managed backup while the database is open: first must put the tablespace in backup mode by issuing an
ALTER TABLESPACE BEGIN BACKUP command
- RMAN backup: do not need to put the tablespace in backup mode
- OEM
- (cited): if the database size in TB the RMAN backup will take more than 10 hours to complete
- special backup techniques which are given by vendors like TIVOLI and Netbackup:
Business content Volume Sync which copies a snapshot of the primary data to another place and backup the
database from one SAN to another within 15 min for 2TB of database and is the preferable method for big
company
6
28. What is the difference between media recovery and crash recovery
Ans: Media recovery is the application of redo or incremental backups to a restored backup datafile or
individual data block to bring it to a specified time.
- Datafile media recovery always begins at the lowest SCN recorded in the datafile headers.
- when perform media recovery, you an recover:
* The whole database
* A tablespace
* A datafile
* A set of blocks within a datafile
- Typically, you perform media recovery after a media failure damages some or all of the database files
crash recovery is the automatic application of online redo records to a database after either a single-instance
database crashes or all instances of an Oracle Real Application Cluster configuration crash. Crash recovery
only requires redo from the online logs: archive redo logs are not required
run {
set newname for datafile 1 to '/ORADATA/u01/system01.dbf';
set newname for datafile 2 to '/ORADATA/u02/undotbs01.dbf';
set newname for datafile 3 to '/ORADATA/u03/users01.dbf';
set newname for datafile 4 to '/ORADATA/u03/indx01.dbf';
set newname for datafile 5 to '/ORADATA/u02/example01.dbf';
49.Can one restore RMAN backups without a CONTROLFILE and RECOVERY CATALOG?
Details of RMAN backups are stored in the database control files and optionally a Recovery Catalog. If both
these are gone, RMAN cannot restore the database. In such a situation one must extract a control file (or other
files) from the backup pieces written out when the last backup was taken. Let's look at an example:
Let's take a backup (partial in our case for ilustrative purposes):
$ rman target / nocatalog
Recovery Manager: Release 10.1.0.2.0 - 64bit Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
14
connected to target database: ORCL (DBID=1046662649)
using target database controlfile instead of recovery catalog
Now, let's see if we can restore it. First we need to start the databaase in NOMOUNT mode:
'/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_ncsnf_TAG20040820T153256_0lczfrx8_.bkp';
v_pieceName(2) :=
'/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_nnndf_TAG20040820T153256_0lczd9tf_.bkp';
v_maxPieces := 2;
-- CFNAME mist be the exact path and filename of a controlfile taht was backed-up
DBMS_BACKUP_RESTORE.restoreControlFileTo(cfname=>'/app/oracle/oradata/orcl/control01.ctl');
Database altered.
Database altered.
57. Where should you place Archive logfiles, in the same disk where DB is or another disk?
Other disk
58. Can you take online backup of a Control file if yes, how?
RMAN> backup current controlfile;
17
59. What is a Logical Backup?
A logical backup (import/export) of a database exports the database objects independent of the physical
location of those objects. In other words, a logical backup exports the data stored in a table regardless of the
location of the table (such as tablespace or datafile).
60. Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?
Yes
61. Why do you take tablespaces in Backup mode?
SQL>alter system tablespace offline;
62. What is the advantage of RMAN utility?
Make backup when the database is running
63. How RMAN improves backup time?
Scheduler task with file rcv
64. Can you take Offline backups using RMAN?
No.
65. How do you see information about backups in RMAN?
RMAN>show all;
66. What is a Recovery Catalog?
Backup caltalog
67. Should you place Recovery Catalog in the Same DB?
No
68. Can you use RMAN without Recovery catalog?
Yes
69. Can you take Image Backups using RMAN?
No
70. Can you use Backupsets created by RMAN with any other utility?
No
71. Where RMAN keeps information of backups if you are using RMAN without Catalog?
RMAN>show all;
72. You have taken a manual backup of a datafile using o/s. How RMAN will know about it?
RMAN catalog
73. You want to retain only last 3 backups of datafiles. How do you go for it in RMAN?
RMAN>configure retention policy to redundancy 3;
74. Which is more efficient Incremental Backups using RMAN or Incremental Export?
Incremental backup with posibilites level 0 & 1
18
75. Can you start and shutdown DB using RMAN?
Yes
76. How do you recover from the loss of datafile if the DB is running in NOARCHIVELOG mode?
RMAN>startup nomount; RMAN> SQL ‘alter database datafile6 offline; RMAN>recover datafile6;
77. You loss one datafile and it does not contain important objects. The important objects are there in other
datafiles which are intact. How do you proceed in this situation?
RMAN> restore datafile5;
78. You lost some datafiles and you don’t have any full backup and the database was running in
NOARCHIVELOG mode. What you can do now?
SQL> startup mount; SQL>flashback database to timestamp sysdate -1/24; or SQL>flashback to scn
(ex.436982938)…; SQL> alter database open resetlogs;
79. How do you recover from the loss of datafile if the DB is running in ARCHIVELOG mode?
RMAN> startup mount RMAN> restore database; with the last full backup
80. You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1
week old and partial backup of this datafile which is just 1 day old. From which backup should you restore
this file?
RMAN>startup mount; RMAN> restore database; RMAN> recover database;
81. You loss controlfile how do you recover from this?
RMAN> restore current controlfile; RMAN> restore spfile;
82. The current logfile gets damaged. What you can do now?
RMAN> alter database open restlogs;
83. What is a Complete Recovery?
RMAN> restore database; full restore database
84. What is Cancel Based, Time based and Change Based Recovery?
- A cancel-based recovery is a type of user-managed incomplete recovery that is performed by specifying
the UNTIL CANCEL clause with the RECOVER command (a SQL*Plus command that is used to recover a
database). The UNTIL CANCEL clause specifies that the recovery process will continue until the user
manually cancels the recovery process issuing the CANCEL command.
-Time-Based, Change-Based, or SCN-based Incomplete Recovery
Incomplete recovery uses a backup to produce a non-current version of the database. In other words, you
do not apply all of the redo records generated after the most recent backup.
You usually perform incomplete recovery of the whole database in the following situations:
Media failure destroys some or all of the online redo logs.
A user error causes data loss, for example, a user inadvertently drops a table.
You cannot perform complete recovery because an archived redo log is missing.
You lose your current control file and must use a backup control file to open the database.
To perform incomplete media recovery, you must restore all datafiles from backups created prior to the time to
which you want to recover and then open the database with the RESETLOGS option when recovery
completes. The RESETLOGS operation creates a new incarnation of the database; in other words, a database
with a new stream of log sequence numbers starting with log sequence 1.
19
85. Some user has accidentally dropped one table and you realize this after two days. Can you recover this
table if the DB is running in ARCHIVELOG mode?
SQL>flashback table name to timestamp to scn (ex. 436982938);
86. Do you have to restore Datafiles manually from backups if you are doing recovery using RMAN?
Yes
87. A database is running in ARCHIVELOG mode since last one month. A datafile is added to the database
last week. Many objects are created in this datafile. After one week this datafile gets damaged before you can
take any backup. Now can you recover this datafile when you don’t have any backups?
Yes
88. How do you recover from the loss of a controlfile if you have backup of controlfile?
RMAN>restore current controlfile;
89. Only some blocks are damaged in a datafile. Can you just recover these blocks if you are using RMAN?
Yes
90. Some datafiles were there on a secondary disk and that disk has become damaged and it will take some
days to get a new disk. How will you recover from this situation?
RMAN>restore datafile6;
91. Have you faced any emergency situation. Tell us how you resolved it?
Restore database with dump file
92. At one time you lost parameter file accidentally and you don’t have any backup. How you will recreate a
new parameter file with the parameters set to previous values.
Restore complet machime with image ghost.
95. What are the steps to performing complete recovery on the whole database?
Mount the database
Ensure that all datafiles you want to recover are online
Restore a backup of the whole database or the files you want to recover
Apply online or archived redo logs, or a combination of the two
99. What is a tablespace?
A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related
logical structures together.
102. What is schema?
A schema is collection of database objects of a user.
112. What is a synonym?
A synonym is an alias for a table, view, sequence or program unit.
133. What is an extent?
An extent is a specific number of contiguous data blocks, obtained in a single allocation and used to store a
specific type of information.
134. What is a segment?
A segment is a set of extents allocated for a certain logical structure.
141. What is a datafile?
Every Oracle database has one or more physical data files. A database's data files contain all the database data.
The data of logical database structures such as tablesand indexes is physically stored in the data files allocated
for a database.
148. Explain the difference between a hot backup and a cold backup and the benefits associated with each.
A hot backup is basically taking a backup of the database while it is still up and running and it must be in
archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require
being in archive log mode. The benefit of taking a hot backup is that the database is still available for use
while the backup is occurring and you can recover the database to any ball in time. The benefit of taking a
cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you
are taking cold backups the database does not require being in archive log mode and thus there will be a slight
performance gain as the database is not cutting archive logs to disk.
149. You have just had to restore from backup and do not have any control files. How would you go about
24
bringing up this database?
I would create a text based backup control file, stipulating where on disk all the data files where and then
issue the recover command with the using backup control file clause.
150. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and
disadvantages to each.
ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that
have occurred in the database so that you can recover to any ball in time. NOARCHIVELOG mode is
basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any
ball in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an
archive log and thus increases the performance of the database slightly.
151. What command would you use to create a backup control file?
Alter database backup control file to trace.
152. What is the purpose of the IMPORT option IGNORE? What is it default setting?
The IMPORT IGNORE option tells import to ignore "already exists" errors. If it is not specified the tables that
already exist will be skipped. If it is specified, the error is ignored and the tables data will be inserted. The
default value is N.
153. You are using hot backup without being in archivelog mode, can you recover in the event of a failure?
Why or why not
We are unable to take hot backup in noarchive mode. You can’t use hot backup without being in archivelog
mode. So no, you couldn’t recover.
154. How many redo logs should you have and how should they be configured for maximum recoverability
You should have at least three groups of two redo logs with the two logs each on a separate disk spindle
(mirrored by Oracle). The redo logs should not be on raw devices on UNIX if it can be avoided.
155. Users aren’t being allowed on the system. The following message is received: ORA-00257 archiver is
stuck. Connect internal only, until freed : What is the problem
The archive destination is probably full, take backup of archivelogs and remove them . archiver process will
re-start.
156. You get a call from you backup DBA while you are on vacation. He has corrupted all of the control files
while playing with the ALTER DATABASE BACKUP CONTROLFILE command. What do you do
As long as all datafiles are safe and he was successful with the BACKUP controlfile command you can do the
following:
CONNECT sys as sysdba STARTUP MOUNT (Take any read-only tablespaces offline before next step
ALTER DATABASE DATAFILE .... OFFLINE;) RECOVER DATABASE USING BACKUP
CONTROLFILE ALTER DATABASE OPEN RESETLOGS; (bring read-only tablespaces back online)
Shutdown and backup the system, then restart If they have a recent output file from the ALTER DATABASE
BACKUP CONTROL FILE TO TRACE; command, they can use that to recover as well. If no backup of the
control file is available then the following will be required: CONNECT INTERNAL STARTUP NOMOUNT
CREATE CONTROL FILE .....;
However, they will need to know all of the datafiles, logfiles, and settings for MAXLOGFILES,
MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the database to use the command.
157. What are the steps involved in Database Startup ?
Start an instance, Mount the Database and Open the Database.
If you do not have a backup of Control file creation statement. Then you have to manually give the CREATE
CONTROL FILE statement. You have to write the file names and sizes of all the datafiles. You will lose any
datafiles which you do not include.
Refer to "Managing Control File" topic for the CREATE CONTROL FILE statement.
Recovering Database when the database is running in ARCHIVELOG Mode.
Recovering from the lost of Damaged Datafile.
If you have lost one datafile. Then follow the steps shown below.
STEP 1. Shutdown the Database if it is running.
STEP 2. Restore the datafile from most recent backup.
STEP 3. Then Start sqlplus and connect as SYSDBA.
28
$sqlplus
Enter User:/ as sysdba
SQL>Startup mount;
SQL>Set autorecovery on;
SQL>alter database recover;
If all archive log files are available then recovery should go on smoothly. After you get the "Media Recovery
Completely" statement. Go on to next step.
STEP 4. Now open the database
SQL>alter database open;
Recovering from the Lost Archived Files:
If you have lost the archived files. Then Immediately shutdown the database and take a full offline backup.
Time Based Recovery (INCOMPLETE RECOVERY).
Suppose a user has a dropped a crucial table accidentally and you have to recover the dropped table.
You have taken a full backup of the database on Monday 13-Aug-2007 and the table was created on Tuesday
14-Aug-2007 and thousands of rows were inserted into it. Some user accidently drop the table on Thursday
16-Aug-2007 and nobody notice this until Saturday.
Now to recover the table follow these steps.
STEP 1. Shutdown the database and take a full offline backup.
STEP 2. Restore all the datafiles, logfiles and control file from the full offline backup which was taken on
Monday.
STEP 3. Start SQLPLUS and start and mount the database.
STEP 4. Then give the following command to recover database until specified time.
SQL> recover database until time '2007:08:16:13:55:00'
using backup controlfile;
STEP 5. Open the database and reset the logs. Because you have performed a Incomplete Recovery, like this
SQL> alter database open resetlogs;
STEP 6. After database is open. Export the table to a dump file using Export Utility.
STEP 7. Restore from the full database backup which you have taken on Saturday.
STEP
Open the
database and
Import the
table.
The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery
process. In addition, since you are taking cold backups the database does not require being in archive log
mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.
You have just had to restore from backup and do not have any control files. How would you go about bringing
up this database?
I would create a text based backup control file, stipulating where on disk all the data files where and then
issue the recover command with the using backup control file clause.
199.Give two examples of how you might determine the structure of the table DEPT.
Use the describe command or use the dbms_metadata.get_ddl package.
200.Where would you look for errors from the database engine?
In the alert log.
31
203.Give the two types of tables involved in producing a star schema and the type of data they hold.
Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain
data that will help describe the fact tables.
206.A table is classified as a parent table and you want to drop and re-create it. How would you do
this without affecting the children tables?
Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key
constraint.
207.Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits
and disadvantages to each.
ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that
have occurred in the database so that you can recover to any point in time.
NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not
being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to
write transactions to an archive log and thus increases the performance of the database slightly.
209.Give the stages of instance startup to a usable state where normal users may access it.
STARTUP NOMOUNT - Instance startup. STARTUP MOUNT - The database is mounted. STARTUP OPEN -
The database is opened
210.what column differentiates the V$ views to the GV$ views and how?
The INST_ID column which indicates the instance in a RAC environment the information came from.
212.How would you go about increasing the buffer cache hit ratio?
Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a
change was necessary then I would use the alter system set db_cache_size command.
213.Explains an ORA-01555
You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the
undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application
getting the error message.
32
216.How will you rectify if one of the rollback segments gets corrupted
The only option available is to restore and recover the database followed by opening the database with
resetlogs. In this case you will lose the entire prior database backup so must make fresh backup.
217.How many days, we are going to retain the data after taking the backup. For example the data
which backed up today that will get expire in 90 days. That means, it is 90 days retention policy for
backup
You can configure retention policy command to create a persistent and automatic backup retention policy.
When a backup retention policy is in effect RMAN considers backups of datafiles and control files as
obsolete that is no longer needed for recovery according to criteria that you specify in the CONFIGURE
command. You can then use the REPORT OBSOLETE command to view obsolete files and DELETE
OBSOLETE to delete them. That means it is 90 days retention policy for backup
218.What kind of backup you take Physical / Logical? Which one is better and Why?
Logical backup means backing up the individual database objects such as tables, views , indexes using the
utility called EXPORT, provided by Oracle. The objects exported in this way can be imported into either same
database or into any other database. The backed-up copy of information is stored in a dumpfile, and this file
can be read only using another utility called IMPORT. There is no other way you can use this file. In this
backup Oracle Export utility stores data in Binary file at OS level.
Physical backups rely on the Operating System to make a copy of the physical files like data files, log files,
control files that comprise the database.In this backup physically CRD (datafile, controlfile, redolog file) files
are copied from one location to another (disk or tape)
We don't preferred logical backup. It is very slow and recoveries are almost not possible.
220.What are the name of the available VIEW in oracle used for monitoring database is in backup
mode (begin backup).
V$backup : Status column of this view shows whether a tablespace is in hotbackup mode. The status
'ACTIVE' shows the datafile to be in backup mode.
V$datafile_header : The fuzzy column also helps a dba to monitor datafile which are in backup mode.
The fuzzy ‘NO’ indicates that the datafile is in hotbackup 9begin backup) mode.
NOTE : The database doesn't startup when a datafile is in backup mode. So put datafile back in the normal
mode before shutting down the database.
230.In your database some blocks of particular datafile are corrupted. What statement will you issue
to know how many blocks are corrupted?
You can check the " Select * from V$DATABASE_BLOCK_CORRUPTION; " view to determine the corrupted
blocks.
231.What is a flash back query? This feature is also available in 9i. What are the difference between 9i
and 10g (related to flash back query).
Oracle 9i flashback 10g enhancement
Flashback query:
Flashback version query
Flashback_Transactional_query view
10g new Features:
Flashback Table
Flashback database
Setup for new feature:
AUM
Flash Recovery Area
233.How can the problem be resolved if a SYSDBA, forgets his password for logging into enterprise
manager?
There are two ways to do that:
1. Login as SYSTEM and change the SYS password by using ALTER USER.
2. Recreate the password file using orapwd and set remote_password_file exclusive and then restart the
instance.
1. Also you can enter as ‘/ as sysdba’ and then after change the password “Alter user sys identified by xxx”;
234.How many maximum number of columns can be part of primary key in a table in 9i and 10g.
You can set primary key in a single table up to 16 columns of table in oracle 9i and 10g.
235.What is RAC?
RAC stands for Real Application Cluster. In previous versions, it is known as PARALLEL SERVER. RAC is a
mechanism that allows multiple instances (on different hosts/nodes) to access the same database. The
benefits: It provides more memory resources, since more hosts are being used; If one host gets down, then
other host assumes it's work load.
237.What is Data Migration?
Data migration is actually the translation of data from one format to another format or from one storage
device to another storage device. Data migration is necessary when a company upgrades its database
or system software, either from one version to another or from one program to an entirely different program.
249.What would you use to improve performance on an insert statement that places millions of rows
into that table?
Drop the indexes and recreate after insert.
DML Triggers to be DISABLED and then ENABLED once the insert completed.
DISABLE the Clustered Index and then ENABLED once the insert completed.
250.If Monday take full backup and Tuesday it was cumulative backup and Wednesday we taken
incremental backup, Thursday some disaster happen then what type of recovery and how it will take?
Restore the Monday full backup + Tuesday cumulative backup + Wednesday Incremental backup.
37
Becausecumulative and incremental clears the archives every backup
251.What is the difference between local managed Tablespace & dictionary managed Tablespace ?
The basic diff between a locally managed tablespace and a dictionary managed tablespace is that in the
dictionary managed tablespace every time a extent is allocated or deallocated data dictionary is updated
which increases the load on data dictionary while in case of locally managed tablespace the space
information is kept inside the datafile in the form of bitmaps every time a extent is allocated or deallocated
only the bitmap is updated which removes burden from data dictionary. The Tablespaces that record extent
allocation/deallocation in the dictionary are called dictionary managed tablespaces and tablespaces that
record extent allocation in the tablespace header are called locally managed tablespaces.
252.While installing the Oracle 9i ( 9.2) version, automatically system takes the space of
approximately 4 GB. That is fine.... Now, if my database is growing up and it is reaching the 4GB of
my database space...Now, I would like to extend my Database space to 20 GB or 25 GB... what are the
things i have to do?
Following steps can be performed:
1. First check for available space on the server.
2. You can increase the size of the datafiles if you have space available on the server and also you can make
auto extend on. So that in future you don't need to manually increase the size.
The alternative better idea is that make the autoextend off and add more datafiles to the Tablespace. Making
a single datafile to a bigger size is risky. By making autoextend off you can monitor the growth of the
tablespace schedule a growth monitoring script with a threshold of 85 full.