You are on page 1of 25

Oracle DBA on Unix and Linux

Michael Wessler

Oracle DBA on Unix and Linux


Chapter 9
Backup and Recovery

Oracle DBA on Unix and Linux


ESSENTIALS
• The first principal of database administration is data
protection, which directly equates to backup and
recovery. This is the most critical skill for a DBA.
• Oracle provides many features that can be used to
implement a solid backup and recovery policy.
• The choice between ARCHIVELOG and
NOARCHIVELOG mode will greatly impact your backup
and recovery options.
• The type of damage your database suffers will also
determine your method of recovery.
• No matter what policies you implement, they must
actually be tested before you can rely on them.
Oracle DBA on Unix and Linux
Chapter Outline

• Importance of Backups
• Backup Types
• Incurring Damage on the Database
• Performing Backups and Recoveries
• Comprehensive Planning and Testing

Oracle DBA on Unix and Linux


Importance of Backups

• If the DBA mess up and lose a database, he/ she will


likely get fired.
• Those dependent on the data will suffer.
• The coworkers are also facing unemployment.
• The owners of the business face a financial loss.

Oracle DBA on Unix and Linux


Backup Types

Logical Backups
• Logical backups are the processes of backing up the raw data via
Oracle’s export utility.
• They are used to recover from accidentally deleted or modified data.
Limitation:
• In large schemas if there is so much data that the export cannot finish
in time(overnight), the export might be impractical as well as the
import.
• If the data itself is changing too fast or is highly entwined, the export
might not be useful.
• Because an export represents the database at a previous point in
time, it might not be valid if transactions have occured since that time.

Oracle DBA on Unix and Linux


Backup Types (ext.)
Physical Backups

• Physical backups are the processes of copying the Oracle database,


configuration, and software files.
• They are used to recover a database when a media failure, such as a
bad disk, occurs. They are the primary form of database protection in
the Unix/Linux.

Oracle DBA on Unix and Linux


Backup Types (ext.)
Physical Backups

Three distinct stages:


• Backup – backups are the act of copying the database files,
database parameter files, and Oracle software installation files to
disk, tape, or optical media.
• Restore – Restore is the process of copying files from a previous
backup to disk.
• Recover – Once the files are restored to disk, Oracle needs to be
restarted and recovered so that it accepts the restored files.
Depending on the backup method used, the database will either exist
as it did at the time of the backup, or it will recover itself to the time of
the failure.

Oracle DBA on Unix and Linux


Incurring Damage on the Database
Impact on the Database
File Type Expected Impact

System Instance crash as soon as it is “noticed” by Oracle.


Control Instance crash as soon as it is “noticed” by Oracle. Multiplexing conrol
files does not prevent a crash, but they do allow for a much easier and
faster recovery.
Online Depends on whether redo log files are multiplexed and whether the file
Redo Log is part of the active group.
If multiplexed, an error message will be issued but the dtabase
instance will survive.
If not multiplexed, the instance will crash and any data in that file will
be lost if it has not be archived.
Rollback If there is only one non-SYSTEM rollback tablespace, the database
instance will crash. As long as at least one rollback tablespace is
available, the instance should survive, but performance will suffer. If
there were active transactions, data can be lost.

Oracle DBA on Unix and Linux


Incurring Damage on the Database
(ext.)
Impact on the Database (continued)
File Type Expected Impact
Temp Database instance will continue to exist, but any operations requiring a
disk sort will fail.

Data Loss of access to objects in that tablespace. (USER, TOOLS, DRSYS


are treated as data files.)

Index Loss of performance and capability to create / update primary or


unique keys on corresponding table. Data will be accessible, but any
DML requiring an index will fail.

Oracle DBA on Unix and Linux


Incurring Damage on the Database
(ext.)
Adding Fault Tolerance

The practices that you can take to make the database more
fault-tolerance:
• Multiplex Control Files
• Multiplex Online Redo Logs
• Automatic Database Startup

Oracle DBA on Unix and Linux


Incurring Damage on the Database
(ext.)
Multiplex Control Files
• Multiplexing control files means maintaining several identical control
files for the same database. Oracle will read from the first control file
created, but will write to all the control files just as if there were only
one file.
• The database will still crash if any control file is lost, but recovery is
greatly simplified.
• the database-creation assistant and most scripts will automatically
create the database with control files: configSID.ora or initSID.ora
files.

Oracle DBA on Unix and Linux


Incurring Damage on the Database
(ext.)
Multiplex Control Files
The steps for adding additional control files after the database has been
created:
1. Shut down the database normally.
2. Edit the configSID.ora or initSID.ora files to have the new control
filename and location.
3. Copy one good, preexisting control file to the location specified and
give it the appropriate name.
4. Restart the database and verify that Oracle “sees” it by querying
V$CONTROLFILE.

Oracle DBA on Unix and Linux


Incurring Damage on the Database
(ext.)
Multiplex Online Redo Logs
The key difference between Multiplex Control Files and Multiplex Online
Redo Logs is that the loss of multiplexed redo log file will generate an
error message, but the database instance will still survive. No data
will be lost.
The steps to multiplex a redo log group:
1. Use V$LOG and V$LOGFILE to identify the members of each group
and to identify which is the active group.
2. Add a new member to the non-active redo groups.
3. Use ALTER SYSTEM SWITCH LOGFILE to move to the next group.
Then add the new member to the remaining non-active redo group.
4. Perform several log switches to remove the INVALID or STALE status
for each new member, which can be seen via V$LOGFILE.

Oracle DBA on Unix and Linux


Incurring Damage on the Database
(ext.)
Automatic Database Starup
The steps to implement automatic startup and shutdown processes:
1. Edit $ORACLE_HOME/bin/dbshut to use SHUTDOWN IMMEDIATE.
2. Create (as root) a file: /etc/init.d/dbshut.
3. Assign dbshut permissions 755.
4. Create (as root) a soft link for /etc/rc0.d/K01dbshut to
/etc/init.d/dbshut.
5. Create (as root) a file: /etc/init.d/dbstart.
6. Assign dbstart permissions 755.
7. Create (as root) a soft link for /etc/rc2.d/S99dbstart to
/etc/init.d/dbstart.

Oracle DBA on Unix and Linux


Performing Backups and Recoveries
Cold Backups and Recoveries

• Cold backups (aka offline backups) are conceptually the simplest


form of physical backup.
• Simply shut down the normal database and then copy all the control,
online redo log, and data files to another location.
• Databases should be shut down normally to guarantee the cold
backup will be valid. Any other form of shut down (transactional,
immediate, and especially abort) leaves doubt as to the validity of the
backup.

Oracle DBA on Unix and Linux


Performing Backups and Recoveries
(ext.)
Cold Backups and NOARCHIVELOG Mode
• Databases in NOARCHIVELOG mode can only be backed up and
restrored by full cold backups.
• If any data or online redo log file is lost or damaged and the database
needs recovery, every file on the database must be restored.
• If you lose only a control file and still have a valid copy, you don’t
have to restore the entire database.
Performing a recovery :
• Delete all the control files, online redo log files, and data files of the
damaged database.
• Restore all the control files, online redo log files, and data files from
the same backup to the exact same locations.
• Simply start SQL*Plus, connect internal, and start the database.

Oracle DBA on Unix and Linux


Performing Backups and Recoveries
(ext.)
Cold Backups in ARCHIVELOG Mode

• Shut down the database normally.


• Copy all the data and control files to the backup location. But do not
copy the online redo log files of the database in ARCHIVELOG mode.
• Restore those files that are damaged or lost. Oracle will recognize
that the files restored from the backup have an earlier timestamp and
will apply archived redo logs to bring those files up to date.
• Restart the database once all the files have been copied.

Backup Y/N Control Files Data Files Redo Log Files


NOARCHIVELOG Mode Yes Yes Yes
ARCHIVELOG Mode Yes Yes No

Oracle DBA on Unix and Linux


Performing Backups and Recoveries
(ext.)
Hot Backups and Recoveries

• Putting a Database into ARCHIVELOG Mode


• Putting a Database in Hot Backup Mode
• Recovering from a Crash During Hot Backups
• Recovering from a Lost Data File
• Recovering from a Lost Temporary or Index Tablespace
• Recovering from a Lost Redo Log Member
• Recovering from Lost Control Files
• Recovering from a Combination of Lost Files

Oracle DBA on Unix and Linux


Performing Backups and Recoveries
(ext.)
Backup of Software and Parameter Files

• The SA can back up Oracle software and database parameter files


(such as tnsnames.ora) as part of a normal server backup.

For example: assume that OFA is followed and /u01 is lost. The SA can
replace the disk and copy /u01 restore from any valid backup. The
DBA simply restarts the database and no special database recovery
should be needed.

Oracle DBA on Unix and Linux


Comprehensive Planning and
Testing
Planning

Use logical backups:


• If the system has developers or users with access to SQL*Plus.

Not to use logical backups:


• The systems are so large
• The systems are changing so fast

Oracle DBA on Unix and Linux


Comprehensive Planning and
Testing (ext.)
Planning
Whether to choose ARCHIVELOG mode or NOARCHIVELOG mode.

NOARCHIVELOG ARCHIVELOG
Mode Mode
Online Redo Logs Archived No Yes
Overhead of Maintaining Archive Log No Yes
Files
Point In Time Recovery Possible? No Yes
Cold (offline) Backups Yes Yes
Hot (online) Backuups No Yes
Suitable for Production Systems? No Yes
Suitable for Non-Production Systems Yes Yes

Oracle DBA on Unix and Linux


Comprehensive Planning and
Testing (ext.)
Planning
Backup schedule:

Day Cold Backup Hot Backup Schema Export


Sunday Yes: 9 PM No No
Monday No Yes: 9 PM Yes: 12:30AM
Tuesday No Yes: 9 PM Yes: 12:30AM
Wednesday No Yes: 9 PM Yes: 12:30AM
Thursday No Yes: 9 PM Yes: 12:30AM
Friday No Yes: 9 PM Yes: 12:30AM
Saturday No Yes: 9 PM Yes: 12:30AM

Oracle DBA on Unix and Linux


Comprehensive Planning and
Testing (ext.)
Testing

• Testing is the way a system should be prepared. That level of testing


is normally not possible because it is rare to be on site before a
system is live. Furthermore, the system, the requirements, and
technical staff change over time so your backup and recovery
procedures need to be continually updated and tested.
• Testing is the only way to verify that a backup and recovery plan is
valid.

Oracle DBA on Unix and Linux


END

Oracle DBA on Unix and Linux

You might also like