Read Pro Oracle Database 11g Administration Online

Authors: Darl Kuhn

Tags: #Oracle DBA

Pro Oracle Database 11g Administration (82 page)

BOOK: Pro Oracle Database 11g Administration
12.62Mb size Format: txt, pdf, ePub
ads

RMAN> backup incremental level 1 datafile 4;


Tip
Use the RMAN REPORT SCHEMA command to list tablespace, datafile name, and datafile number information.

Backing up the Control File

The most reliable way to back up the control file is to configure the autobackup feature: RMAN> configure controlfile autobackup on;

This command ensures that the control file is automatically backed up when a BACKUP or COPY

command is issued. I usually enable the autobackup of the control file feature and then never worry 491

CHAPTER 18 ■ RMAN BACKUPS AND REPORTING

about explicitly issuing a separate command to back up the control file. When in this mode, the control file is always created in its own backup set and backup piece after the datafile backup pieces have been created.

If you need to manually back up the control file, you can do so like this: RMAN> backup current controlfile;

The location of the backup is either a default operating system location, the FRA (if using), or a manually configured location. As shown in Chapter 17, I prefer to set the location of the control file backup piece to the same location as the datafile backups:

RMAN> configure controlfile autobackup format for device type disk to

'/ora01/O11R2/rman/rman_ctl_%F.bk';

Backing up the Spfile

If you have enabled the autobackup of the control file feature, the spfile will be backed up automatically (along with the control file) anytime a BACKUP or COPY command is issued. If you need to manually back up the spfile, use the following command:

RMAN> backup spfile;

The location of the file that contains the backup of the spfile is dependent on what you have configured. By default, if you don't use a FRA and you haven't explicitly configured a location via a channel, then for Linux/Unix servers the backup goes to the ORACLE_HOME/dbs directory.


Note
RMAN can only back up the spfile if the instance was started using a spfile.

Backing up Archive Redo Logs

I don't usually back up the archive redo logs separately from the database backups. As mentioned earlier, I normally back up the database files and the archive redo log files by using the following command:

RMAN> backup incremental level=0 database plus archivelog;

However, you will occasionally find yourself in a situation where you need to take a special one off backup of the archive redo logs. You can issue the following command to back up the archive redo logs files:

RMAN> backup archivelog all;

If you have a mount point that is nearly full and you determine that you want to back up the archive redo logs (so that they exist in a backup file) but then you want to immediately delete the archive redo log files (that were just backed up) from disk, you can use the following syntax to back up the archive redo logs and then have RMAN delete them from the storage media:

RMAN> backup archivelog all delete input;

Listed next are some other ways in which you can back up the archive redo log files: RMAN> backup archivelog sequence 300;

492

CHAPTER 18 ■ RMAN BACKUPS AND REPORTING

RMAN> backup archivelog sequence between 300 and 400 thread 1;

RMAN> backup archivelog from time "sysdate-7" until time "sysdate-1"; If an archive redo log has been removed from disk manually via an operating system delete command, RMAN will throw the following error when attempting to back up the non-existent archive redo log file:

RMAN-06059: expected archived log not found, loss of archived log compromises recoverability In this situation, first run a CROSSCHECK command to let RMAN know which files are physically available on disk:

RMAN> crosscheck archivelog all;

Backing up Fast Recovery Area

If you use a fast recovery area, one nice RMAN feature is that you can back up all of the files in that location with one command. If you're using a media manager and have a tape backup channel enabled, you can back up everything in the fast recovery area to tape like this: RMAN> configure channel device type sbt_tape parms 'ENV=(OB_MEDIA_FAMILY=RMAN-DB11R2)'; RMAN> backup device type sbt_tape recovery area;

You can also back up the fast recovery area to a location on disk. Use the TO DESTINATION command to accomplish this:

RMAN> backup recovery area to destination '/ora01/O11R1/fra_back'; RMAN will automatically create directories as required beneath the directory specified by the TO

DESTINATION command.


Note
The format of the subdirectory under the directory is

/backupset_.

RMAN will back up full backups, incremental backups, control file autobackups, and archive redo log files. Keep in mind that flashback logs, online redo log files, and the current control file are not backed up.

Excluding Tablespaces from Backups

Suppose you have a tablespace that contains non-critical data and you don't ever want to back it up.

RMAN can be configured to exclude such tablespaces from the backup. To determine if RMAN is currently configured to exclude any tablespaces, run this command:

RMAN> show exclude;

RMAN configuration parameters for database with db_unique_name O11R2 are: RMAN configuration has no stored or default parameters

Use the EXCLUDE command to instruct RMAN which tablespaces to not back up: RMAN> configure exclude for tablespace users;

493

CHAPTER 18 ■ RMAN BACKUPS AND REPORTING

Now for any database level backups, RMAN will exclude the datafiles associated with the USERS

tablespace. You can instruct RMAN to back up any excluded tablespaces with this command: RMAN> backup database noexclude;

You can clear the exclude setting via the following command:

RMAN> configure exclude for tablespace users clear;

Backing up Datafiles Not Backed Up

Suppose you have just added several datafiles to your database and you want to ensure that you have a backup of them. You can issue the following command to instruct Oracle to back up datafiles that have not been backed up yet:

RMAN> backup database not backed up;

You can also specify a time range for files that haven't been backed up yet. Suppose you discover that your backups haven't been running for the last several days and you want to back up everything that hasn't been backed up within the last 24 hours. The following command backs up all datafiles that have not been backed up within the last day:

RMAN> backup database not backed up since time='sysdate-1';

This command is also useful if your backups aborted for some reason, such as a power failure in the data center or your backup directory became full during backups. After you have resolved the issue that caused your backup job to fail, you can issue the previous command and RMAN will only back up the datafiles that haven't been backed up in the specified time period.

Skipping Read-Only Tablespaces

Since data in read-only tablespaces can't change while in read-only mode, you may only want to back up read-only tablespaces once and then skip them in subsequent backups. Use the SKIP READONLY

command to achieve this:

RMAN> backup database skip readonly;

Keep in mind that when you skip read-only tablespaces, you’ll need to keep available a backup that contains these tablespaces. You don't want to find yourself in the situation where you haven't backed up a read-only tablespace for six months and then have a media failure.

Skipping Offline or Inaccessible Files

Sometimes datafiles become corrupt. You know that you don't need this datafile for anything so you take it offline, like so:

SQL> alter database datafile '/ora01/INVDEV/sysaux01.dbf' offline for drop; Now, suppose you attempt to run an RMAN backup:

RMAN> backup database;

The following error is thrown when RMAN encounters a datafile that it can't back up: RMAN-03002: failure of backup command at 09/14/2010 13:24:04

494

CHAPTER 18 ■ RMAN BACKUPS AND REPORTING

RMAN-06056: could not access datafile 3

In this situation, you'll have to instruct RMAN to exclude the offline datafile from the backup. The SKIP OFFLINE command instructs RMAN to ignore datafiles with an offline status: RMAN> backup database skip offline;

If a file has gone completely missing, use SKIP INACCESSIBLE to instruct RMAN to ignore files that are not available on disk. This might happen if the datafile was deleted using an operating system command. Here's an example of excluding inaccessible datafiles from the RMAN backup: RMAN> backup database skip inaccessible;

You can skip read-only, offline, and inaccessible datafiles with one command: RMAN> backup database skip readonly skip offline skip inaccessible; When dealing with offline and inaccessible files, you should figure out why the files are offline or inaccessible and try to resolve any issues.

Backing Up Large Files in Parallel

Normally, RMAN will only use one channel to back up a single datafile. When you enable parallelism, it allows RMAN to spawn multiple processes to back up multiple files. However, even when parallelism is enabled, RMAN will not use parallel channels simultaneously to back up one datafile, but starting with Oracle Database 11g, you can instruct RMAN to use multiple channels to back up one datafile in parallel.

This is known as a
multisection backup
. This feature can speed up the backups of very large datafiles.

Use the SECTION SIZE parameter to make a multisection backup. The following example configures two parallel channels to back up one file:

RMAN> configure device type disk parallelism 2;

RMAN> configure channel 1 device type disk format '/ora01/O11R2/rman/r1%U.bk'; RMAN> configure channel 2 device type disk format '/ora02/O11R2/rman/r2%U.bk'; RMAN> backup section size 2500M datafile 10;

When this code runs, RMAN will allocate two channels to back up datafile 10 in parallel.


Note
If you specify a section size greater than the size of the datafile, RMAN will not back up the file in parallel.

Adding RMAN Backup Information to the Repository

Another scenario is when you need to populate the control file with information regarding RMAN

backups. For example, say you had to recreate your control file, and now the control file no longer contains any information regarding RMAN. In this situation, use the CATALOG command to populate the control file with RMAN metadata. For example, if all of the RMAN backup files are kept in the

/ora01/O11R2/rman directory, you can make the control file aware of these backups files in this directory like this:

RMAN> catalog start with '/ora01/O11R2/rman';

495

CHAPTER 18 ■ RMAN BACKUPS AND REPORTING

This causes RMAN to look for any backup pieces, image copies, control file copies, or archive redo logs in the specified directory, and if found, populate the control file with the appropriate metadata. For this example, two backup piece files are found in the given directory: searching for all files that match the pattern /ora01/O11R2/rman

List of Files Unknown to the Database

=====================================

File Name: /ora01/O11R2/rman/r1otlns90o_1_1.bk

File Name: /ora01/O11R2/rman/r1xyklnrveg_1_1.bk

Do you really want to catalog the above files (enter YES or NO)?

If you enter YES, then metadata regarding the backup files will be added to the control file. In this way, the CATALOG command allows you to make the RMAN repository (control file and recovery catalog) aware of files that RMAN can work with for backup and recovery.

You can also instruct RMAN to catalog any files in the recovery area that the control file isn't currently aware of like this:

RMAN> catalog recovery area;

You can also catalog specific files. This example instructs RMAN to add metadata to the control file for a specific backup piece file:

RMAN> catalog backuppiece '/ora01/O11R2/rman/r1xyklnrveg_1_1.bk';

Creating Incremental Backups

RMAN has three separate and distinct incremental backup features:


Incremental level backups


Incrementally updating backups


Block change tracking

With incremental level backups, RMAN only backs up the blocks that have been modified since a previous backup. Incremental backups can be applied to the entire database, tablespaces, or datafiles.

This is the most commonly used incremental feature with RMAN.

Incrementally updating backups is an entirely different feature from incremental level backups.

These backups take image copies of the datafiles and then use incremental backups to update the image copies. This gives you an efficient way to implement and maintain image copies as part of your backup strategy. You only take the image copy backup once, and then use incremental backups to keep the image copies updated with the most recent transactions.

Block change tracking is another feature designed to speed up the performance of incremental backups. The idea here is that an operating system file is used to record which blocks have changed since the last backup. RMAN can use the block change tracking file to quickly identify which blocks need to be backed up when performing incremental backups. This feature can greatly improve the performance of incremental backups.

496

CHAPTER 18 ■ RMAN BACKUPS AND REPORTING

Taking Incremental Level Backups

RMAN implements incremental backups through levels. Starting with Oracle Database 10
g
, there are only two documented levels of incremental backups: level 0 and level 1. Prior versions of Oracle offer five levels, 0 through 4. These levels (0 through 4) are still available in Oracle Database 10g and 11g, but are not specified in the Oracle documentation. You must first take an incremental level 0 backup to establish a baseline, after which you can take a level 1 incremental backup.


Note
A full backup backs up the exact same blocks as a level 0 backup. However, you can't use a full backup with incremental backups. You have to start an incremental backup with a level 0 backup. If you attempt to take a level 1 backup and no level 0 exists, RMAN will automatically take a level 0 backup.

BOOK: Pro Oracle Database 11g Administration
12.62Mb size Format: txt, pdf, ePub
ads

Other books

Pile of Bones by Bailey Cunningham
Dear Digby by Carol Muske-Dukes
Persona Non Grata by Timothy Williams
Star Struck by Laurelin Paige
Summerlong by Dean Bakopoulos
The Conquering Sword of Conan by Robert E. Howard
Coming of Age by Timothy Zahn