Read Pro Oracle Database 11g Administration Online

Authors: Darl Kuhn

Tags: #Oracle DBA

Pro Oracle Database 11g Administration (79 page)


Note
RMAN can also create backup sets using true binary compression. This is the type of compression you get from an OS compression utility (such as zip). Oracle supports several levels of binary compression. The BASIC

compression algorithm is available without an additional license. Oracle provides further compression features with the Oracle Advanced Compression option (see the later section in this chapter for details on how to enable binary compression).

When you create a backup as a backup set, the binary backup piece files can only be manipulated by RMAN processes. Some DBAs view this as a disadvantage because they must use RMAN to back up and 474

CHAPTER 17 ■ CONFIGURING RMAN

restore these files (you have no direct access to or control over the backup pieces). But these perceptions aren’t warranted. Unless you hit a rare bug, RMAN is dependable and works reliably in all backup and restore situations.

Contrast the backup set to an image copy. An image copy creates a byte-for-byte identical copy of each datafile. The advantages of creating an image copy are that (if necessary) you can manipulate the image copy without using RMAN (as with an OS copy utility). Additionally, in the event of a media failure, an image copy is a fast method of restoring datafiles, because RMAN has to copy the file back from the backup location (there is no reconstructing of the datafile, because it’s an exact copy).

I almost always use backup sets for database backups, rather than image copies. Usually, I require some form of RMAN compression (block skipping). The size of the backup to disk is almost always a concern. Backup sets are more efficient regarding disk-space consumption. Because backup sets can take advantage of RMAN compression, there is also less I/O involved with a backup set compared to an image copy. In many environments, reducing the I/O so as not to impact other applications is a concern.

But if you feel that you need direct control over the backup files that RMAN creates, or you’re in an environment in which the speed of the restore process is paramount, consider using image copies.

17. Using Incremental Backups

For most of the databases I’m responsible for, I run a daily level 0 backup. I usually don’t implement any type of incremental backup strategy.

Incremental backup strategies are appropriate for large databases where only a small portion of the database blocks change from one backup to the next. If you’re in a data-warehouse environment, you may want to consider an incremental backup strategy, because it can greatly reduce the size of your backups. For example, you may want to run a weekly level 0 backup and then run a daily level 1

incremental backup.


Note
See Chapter 18 for details on how to back up a database using incremental backups.

18. Using Incrementally Updated Backups

Incrementally updated backups are an efficient way to implement an image-copy backup strategy. This technique instructs RMAN to first create image copies of datafiles; then, the next time the backup runs, instead of creating a fresh set of image copies, RMAN makes an incremental backup (changes to blocks since the image copy was created) and applies that incremental backup to the image copies.

If you have the disk space available for full image copies of your database, and you want the flexibility to be able to directly use the image copies in the event of a media failure, consider this backup strategy.

One potential disadvantage of this approach is that if you’re required to restore and recover to some point in the past, you can only restore and recover to the point where the image copies were last updated with the incremental backup.


Note
See Chapter 18 for details on how to back up a database using incrementally updated backups.

475

CHAPTER 17 ■ CONFIGURING RMAN

19. Using Block-Change Tracking

This feature keeps track of when a database block changes. The idea is that if you’re using an incremental backup strategy, you can enhance performance by implementing this feature so that RMAN

doesn’t have to scan each block (under the high-water mark) in the datafiles to determine whether a block needs to be backed up. Rather, RMAN only has to access the block-change tracking file to determine which blocks have changed since the last backup and directly access blocks that have been identified as changed. If you work in a large data-warehouse environment and are using an incremental backup strategy, consider enabling block-change tracking to enhance performance.


Note
See Chapter 18 for details on how to implement block-change tracking.

20. Configuring Binary Compression

You can configure RMAN to use true binary compression when generating backup sets. You can enable compression in one of two ways:

• Specify AS COMPRESSED BACKUPSET with the BACKUP command.

• Use a one-time CONFIGURE command.

Here’s an example of backing up with compression when issuing the BACKUP command: RMAN> backup as compressed backupset database;

Here’s an example of configuring compression for the disk device:

RMAN> configure device type disk backup type to compressed backupset; If you need to clear the device-type compression, issue this command: RMAN> configure device type disk clear;

I’ve found the default compression algorithm to be quite efficient. For a typical database, the backups are usually about four to five times smaller than the regular backups. Of course, your compression results may vary depending on your data.

Why not compress all backups? Compressed backups consume more CPU resources and take a longer time to create and restore from, but they result in less I/O spread out over a longer time. If you have multiple CPUs and the speed of making a backup isn’t an issue, then you should consider compressing your backups.

You can view the type of compression enabled using the SHOW command:

RMAN> show compression algorithm;

Here’s some sample output:

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT'

OPTIMIZE FOR LOAD TRUE ; # default

The basic compression algorithm doesn’t require an extra license from Oracle. If you’re using Oracle Database 11
g
release 2 or higher, and if you have a license for the Advanced Compression Option, then you have available three additional configurable levels of binary compression. For example: RMAN> configure compression algorithm 'HIGH';

476

CHAPTER 17 ■ CONFIGURING RMAN

RMAN> configure compression algorithm 'MEDIUM';

RMAN> configure compression algorithm 'LOW';

You can query V$RMAN_COMPRESSION_ALGORITHM to view details regarding the compression algorithms available for your release of the database. To reset the current compression algorithm to the default of BASIC, use the CLEAR command:

RMAN> configure compression algorithm clear;

21. Configuring Encryption

You may be required to encrypt backups. Some shops especially require this for backups that contain sensitive data and that are stored offsite. To use encryption when backing up, you must use the Oracle Enterprise Edition, possess a license for the Advanced Security Option, and use Oracle Database 10
g
release 2 or higher.

If you’ve configured a security wallet (see the
Oracle Advanced Security Administrator’s Guide
for details, available on Oracle’s OTN website), you can configure transparent encryption for backups as shown:

RMAN> configure encryption for database on;

Any backups you make will now be encrypted. If you need to restore from a backup, it’s automatically unencrypted (assuming the same security wallet is in place as when you encrypted the backup). To disable encryption, use the CONFIGURE command:

RMAN> configure encryption for database off;

You can also clear the encryption setting with CLEAR:

RMAN> configure encryption for database clear;

You can query V$RMAN_ENCRYPTION_ALGORITHMS to view details regarding the encryption algorithms available for your release of the database.

22. Configuring Miscellaneous Settings

RMAN provides a flexible number of channel-configuration commands. You occasionally need to use them depending on special circumstances and requirements for your database. Here are some of the options:

• Maximum backup-set size

• Maximum backup-piece size

• Maximum rate

• Maximum open files

By default, the maximum backup-set size is unlimited. You can use the MAXSETSIZE parameter with the CONFIGURE or BACKUP command to specify the overall maximum backup-set size. Make sure the value of this parameter is at least as large as the largest datafile being backed up by RMAN. Here’s an example: RMAN> configure maxsetsize to 2g;

477

CHAPTER 17 ■ CONFIGURING RMAN

Sometimes you may want limit the overall size of a backup piece due to physical limitations of storage devices. Use the MAXPIECESIZE parameter of the CONFIGURE CHANNEL or ALLOCATE CHANNEL

command do this. For example:

RMAN> configure channel device type disk maxpiecesize = 2g;

If you need to set the maximum number of bytes that RMAN reads each second on a channel, you can do so using the RATE parameter. This configures the maximum read rate for channel 1 to 200MB per second:

configure channel 1 device type disk rate 200M;

If you have a limit on the number of files you can have open simultaneously, you can specify a maximum open files number via the MAXOPENFILES parameter:

RMAN> configure channel 1 device type disk maxopenfiles 32;

You may need to configure any of these settings when you need to make RMAN aware of some OS or hardware limitation. You’ll rarely need to use these parameters but should be aware of them.

Segueing from Decisions to Action

Now that you have a good understanding of what types of decisions you should make before implementing RMAN, it’s instructional to view a script that implements some of these components. I mainly work with Linux/Unix servers. In these environments, I use shell scripts to automate the RMAN

backups. These shell scripts are automated through a scheduling utility such as cron.

This section contains a typical shell script for RMAN backups. The shell script has line numbers in the output for reference in the discussion of the architectural decisions I made when writing the script.

(If you copy the script, take out the line numbers before running it.) Following is the script. Table 17–2 details every RMAN architectural decision point covered in this chapter, how it’s implemented (or not) in the shell script, and the corresponding line number in the shell script. The script doesn’t cover every aspect of how to use RMAN. If you use the script, be sure to modify it to meet the requirements and RMAN standards for your own environment: 1 #!/bin/bash

2 HOLDSID=${1} # SID name

3 PRG=`basename $0`

4 USAGE="Usage: ${PRG} "

5 if [ -z "${HOLDSID}" ]; then

6 echo "${USAGE}"

7 exit 1

8 fi

9 #----------------------------------------------

10 # source environment variables (see Chapter 2 for details on oraset) 11 . /var/opt/oracle/oraset $HOLDSID

12 BOX=ùname -a | awk '{print$2}'`

13 MAILX='/bin/mailx'

14 MAIL_LIST='[email protected]'

15 NLS_DATE_FORMAT='dd-mon-yy hh24:mi:ss'

16 date

17 #----------------------------------------------

18 LOCKFILE=/tmp/$PRG.lock

19 if [ -f $LOCKFILE ]; then

20 echo "lock file exists, exiting..."

21 exit 1

478

CHAPTER 17 ■ CONFIGURING RMAN

22 else

23 echo "DO NOT REMOVE, $LOCKFILE" > $LOCKFILE

24 fi

25 #----------------------------------------------

26 rman nocatalog <

27 connect target /

28 set echo on;

29 show all;

30 # Synchronize RMAN with files on OS

31 crosscheck backup;

32 crosscheck copy;

33 crosscheck archivelog all;

34 # Configure environment, redundant to run each time, but ensures set correctly.

35 configure controlfile autobackup on;

36 configure controlfile autobackup format for device type disk to

'/oradump01/DWREP/rman/rman_ctl_%F.bk';

37 configure retention policy to redundancy 1;

38 configure device type disk parallelism 5;

39 configure channel 1 device type disk format '/ora08/DWREP/rman/rman1_%U.bk'; 40 configure channel 2 device type disk format '/ora08/DWREP/rman/rman2_%U.bk'; 41 configure channel 3 device type disk format '/ora08/DWREP/rman/rman3_%U.bk'; 42 configure channel 4 device type disk format '/ora09/DWREP/rman/rman4_%U.bk'; 43 configure channel 5 device type disk format '/ora09/DWREP/rman/rman5_%U.bk'; 44 # Backup datafiles, archive redo logs, and control file

45 backup as compressed backupset incremental level=0 database plus archivelog; 46 # Delete obsolete backups and archive logs as defined by retention policy.

47 delete noprompt obsolete;

48 EOF

49 #----------------------------------------------

50 if [ $? -ne 0 ]; then

51 echo "RMAN problem..."

52 echo "Check RMAN backups" | $MAILX -s

"RMAN issue: $ORACLE_SID on $BOX" $MAIL_LIST

53 else

54 echo "RMAN ran okay..."

55 fi

56 #----------------------------------------------

57 sqlplus -s /nolog <

58 connect / as sysdba;

59 alter database backup controlfile to trace;

60 COL dbid NEW_VALUE hold_dbid

61 SELECT dbid FROM v\$database;

62 exec dbms_system.ksdwrt(2,'DBID: '||TO_CHAR(&hold_dbid));

63 EXIT

64 EOF

65 #----------------------------------------------

66 if [ -f $LOCKFILE ]; then

67 rm $LOCKFILE

68 fi

69 #----------------------------------------------

70 date

71 exit 0

Other books

Tiger's Curse by Houck, Colleen
Mercy by David L Lindsey
Flare by Roberts, Posy
Sheikh's Command by Sophia Lynn
The time traveler's wife by Audrey Niffenegger