Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • Lesson 5 – Oracle RMAN Channels (Gaining a complete understanding of RMAN channels.)
  • Author: Dave Anderson, SkillBuilders
  • www.skillbuilders.com
  • Last Update: October 17, 2007

  • This lesson will cover the following topics:
  • Channel concepts and What is a channel?
  • Manually allocating a channel
  • Employing parallelism
  • Allocating multiple channels for a job
  • Oracle9i (and above) automatic allocation of channels

Other Text:
(Examples or comments displayed on slide, if any).

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • After completing this lesson, you will understand exactly what an RMAN channel is and how to allocate channels (manually and automatically).

Other Text:
(Examples or comments displayed on slide, if any).

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • RMAN uses the concept of a channel to perform work (backup, restore, recover, etc.) on the target database. Channels are critical because at least one channel must be allocated to perform backup and restore/recovery operations.
  • Each channel is, in essence, a connection to a single server session on the target database. This server session reads and writes to a single disk or tape device.
  • Channels are allocated manually - via the ALLOCATE CHANNEL command, or, in Oracle9i automatically. See the section “Automatic Channel Allocation” later in this lesson for more information.

Other Text:
(Examples or comments displayed on slide, if any).

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • A session is started on the target database for each channel that is allocated (via ALLOCATE command or 9i automatic channel allocation). These server sessions perform the work – the reading and writing, etc. – necessary for backup and recovery. The server session on the target database is created when the channel is allocated. To prevent the need to recreate sessions on the target database, the server session persists for even after the channel is freed (until the RMAN session exits), waiting for another RMAN job.
  • RMAN also starts one additional session (a “polling” session) that monitors the status of the sessions doing the backup or recover.
  • These sessions are dedicated server sessions – they cannot be shared server sessions. The tnsname.ora service description can be used to force a dedicated connection:
  • (CONNECT_DATA =
    • (SERVER = DEDICATED)
    • (SERVICE_NAME = dave)

Other Text:
(Examples or comments displayed on slide, if any).

Query V$SESSION to see channels<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • Channels can be manually allocated by executing the ALLOCATE CHANNEL command. This command must be enclosed within a RUN block, as shown in the example above.
  • This example includes the use of the optional FORMAT parameter, which allows us to control the format and location of the backup piece(s) (a backup piece is an OS file in RMAN format; see the lesson Backup with RMAN for more information.) The location of the backup piece can be any device that is a valid location for a datafile. As the Oracle RMAN manual states, “if the statement CREATE TABLESPACE tablespace-name DATAFILE ‘filename’ works, then ‘filename’ is a valid backup path name.”
  • The RMAN message from the ALLOCATE CHANNEL command shows the SID of the server session (see “sid=16”) and the type of device connected to this session (disk).

  • Notes for this slide continue on the next page…

Other Text:
(Examples or comments displayed on slide, if any).

RMAN> run { <br>2> allocate channel d1 type disk <br>3> format 'c:\oracle\backup\%d.%T.%s.%p'; <br>4> backup tablespace tools; } <br> <br>allocated channel: d1 <br>channel d1: sid=16 devtype=DISK <br> <br>Starting backup at 23-MAY-05<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • Command Syntax:
      • ALLOCATE CHANNEL channel-id TYPE {DISK | SBT}
      • [ FORMAT ‘path and format’ ]
  • The channel-id is used to refer to the channel in later RMAN commands.
  • The TYPE specifies that the device type of the output. It can be a tape (SBT) if a Media Management Library is installed on the target database. (Legato is an example of a vendor that supplier MML).
  • FORMAT – specify the path and filename of the backup set. Incorporate the RMAN variables such as %s and %p (THESE VARIABLES ARE CASE SENSITIVE). Some of the supported substitution variables are:
    • %s – Unique backup set number stored in the control file.
    • %p – Backup piece number within the backup set. Starts at one and incremented by 1 for each piece.
    • %d – Database name
    • %T  – Year, month, and day in the following format: YYYYMMDD
    • %c – Integer representing copy number of backup piece when duplexing. Required when the COPIES option is use to create multiple copies of a backup set. See the section on duplexing in the lesson titled Backup with RMAN.
    • %u – Generated string (Oracle states this is a “compressed representation of the backup set number and time … created”.
    • %U – Default. A unique string created with %u_%p_%c
  • Note the example above uses the variables %d.%T.%s.%p. This provides backup pieces (OS files that contain the backed up blocks) where the name contains the database name, date of the backup, unique set number and piece name (the latter two required if the backup creates more that one set or piece within the set). For example, the piece created by the example shown above created was named DAVE1.20050523.80.1.

Other Text:
(Examples or comments displayed on slide, if any).

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • We can easily see the server sessions created on behalf of the ALLOCATE CHANNEL command by querying V$SESSION. Refer to the previous page and note the SID in the ALLOCATE CHANNEL message output. Now look at the output of this query. SID 8 is associated with SERIAL# 332.

  • This information is helpful when:
    • Terminating an RMAN command with the ALTER SYSTEM KILL SESSION command.
    • Querying V$SESSION_WAIT to determine why a RMAN job is hanging. For example, the catalog database response could be delayed because of a problem on the catalog database or the SQL*Net connection.

Other Text:
(Examples or comments displayed on slide, if any).

SELECT sid, serial#, username FROM v$session; <br> <br> SID SERIAL# USERNAME <br>---------- ---------- ------------ <br> ... <br> 7 1 <br> 8 332 SYS <br> 11 50 SYSTEM <br> 12 299 SYS <br> 13 9 SYS<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • When multiple channels are allocated, RMAN will parallelize the operation. Maximum throughput can be achieved be parallelizing operations. This means that each channel:
    • Starts a server session on the target database.
    • Executes a copy of the BACKUP command concurrently.
    • Backs up a share of the files as determined by the FILESPERSET parameter. See the next Parallel Backup example for an example of the FILESPERSET parameter.
    • Creates a backup set containing one or more backup pieces as determined by the MAXPIECESIZE parameter of the ALLOCATE CHANNEL or CONFIGURE CHANNEL commands.

  • Notes continue on the next page…

Other Text:
(Examples or comments displayed on slide, if any).

RMAN> run { <br>2> allocate channel d1 type disk <br>3> format 'c:\oracle\backups\%d.%s.%p' ; <br>4> allocate channel d2 type disk <br>5> format 'c:\oracle\backups\%d.%s.%p'; <br>6> backup database tag='july14a'; } <br> <br>using target database controlfile instead of recovery ca <br>allocated channel: d1 <br>channel d1: sid=18 devtype=DISK <br> <br>allocated channel: d2 <br>channel d2: sid=16 devtype=DISK<br>Tag can be used in RMAN commands<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • The output of the LIST BACKUP command shows the effect of the multiple channels – each channel created a backup set. Use the TAG parameter on the BACKUP command and on the LIST command to limit the result to just the desired backup. (Refer to the Scripting and Reporting lesson for more information on the LIST BACKUP command.)

Other Text:
(Examples or comments displayed on slide, if any).

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • By default, RMAN will balance the workload over the multiple channels. However, you can also limit the files per channel with the FILESPERSET parameter as shown in this example.
  • FILESPERSET limits the number of datafiles in a backup set. The default FILESPERSET is the lesser of 64 or the number of datafiles divided by the number of channels. In this example I override the default – and limit FILESPERSET to 2. So, each channel can have a maximum of 2 files. However, the actual number can be greater than datafiles / FILESPERSET. Oracle uses an undocumented internal balancing algorithm. So, even though the limit is two files per set, RMAN may choose to put only 1 file in the set.
  • Don’t worry about the INCREMENTAL backups now; you will learn about those types of backups later in the Backup with RMAN lesson.
  • .

Other Text:
(Examples or comments displayed on slide, if any).

run { <br>allocate channel d1 type disk <br>format 'c:\oracle\backups\weekly_level_0.%d.%T.%s'; <br>allocate channel d2 type disk <br>format 'c:\oracle\backups\weekly_level_0.%d.%T.%s'; <br>allocate channel d3 type disk <br>format 'c:\oracle\backups\weekly_level_0.%d.%T.%s'; <br>backup incremental level 0 TAG 'Weekly Level 0' database filesperset 2; <br>}<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • When a command is executed that requires a channel (such as BACKUP), and you have not executed an ALLOCATE CHANNEL command, Oracle9i will automatically allocate a channel for you.

Other Text:
(Examples or comments displayed on slide, if any).

RMAN> backup database;<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • RMAN 9i supplies a pre-configured (default) disk channel. (Oracle8i will issue an error message.) However, a manually allocated channel always overrides an automatic channel.
  • The SHOW ALL command displays all the pre-configured settings from RMAN. (“# default” indicates a default setting.) You can see from the output of this command that there are many configuration settings that we can affect, more than just the default channel. I have highlighted the settings related to the channel:
  • RMAN> show all;
  • RMAN configuration parameters are:
  • CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
  • CONFIGURE BACKUP OPTIMIZATION OFF; # default
  • CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
  • CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
  • CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
  • # default
  • CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
  • CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
  • CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
  • CONFIGURE MAXSETSIZE TO UNLIMITED; # default
  • CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'C:\ORACLE\ORA81\DATABASE\SNCFPROD.ORA'; # default

Other Text:
(Examples or comments displayed on slide, if any).

RMAN> SHOW ALL; <br>CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default <br>CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default<br>Excerpt from SHOW ALL command output<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • Automatic channel allocation (ACA) is controlled by the following commands:

    • CONFIGURE DEFAULT DEVICE TYPE TO {DISK | SBT} - Controls the type of device that RMAN automatically allocates. So if you execute the following command: BACKUP DATABASE; without manually allocating a channel, RMAN allocates the pre-configured channel for you. The default device type can be overridden on individual backup and restore commands. For example:
      • BACKUP DEVICE TYPE sbt DATABASE;
    • CONFIGURE DEVICE TYPE {DISK | SBT} PARALLELISM n - Controls the number of channels RMAN will allocate for the specified device type. When multiple locations (devices ) are available, parallelism can increase backup performance considerable. Test!
    • CONFIGURE CHANNEL DEVICE TYPE {DISK | SBT} FORMAT ‘location/filename’ - Controls the generic configurations for all automatic allocations of the specified device.
    • CONFIGURE CHANNEL n DEVICE TYPE {DISK | SBT} FORMAT 'location/filename' - Controls the configuration for the automatic channel specified by “n”. See the Oracle9i Recovery Manager Reference for a complete list of parameters.
  • Note that RMAN executes a RESYNC CATALOG command during the execution on a CONFIGURE command to update the recovery catalog with the new configuration information.

Other Text:
(Examples or comments displayed on slide, if any).

RMAN> configure default device type to disk; <br>RMAN> configure device type disk parallelism 2; <br>RMAN> configure channel 1 device type disk format '/opt/backup/%U'; <br>RMAN> configure channel 2 device type disk format '/opt/backup/%U';<br>CONFIGURE DEFAULT DEVICE TYPE clear; <br>CONFIGURE DEVICE TYPE DISK clear;<br>

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • In this lesson you learned:
    • What a channel is
      • A channel is a connection to a server session
      • A channel is a connection to an I/O device
    • The syntax of the ALLOCATE CHANNEL command so that you can manually allocate channels
    • How to use Parallelism in RMAN operations by allocating multiple channels
    • How to use the CONFIGURE command to automatically allocate channels (Oracle9i and above)


Other Text:
(Examples or comments displayed on slide, if any).

Slides © 2004-2007 SkillBuilders.

Instructor's Notes

(If applicable)

  • RMAN Channels Workshop
    1. Perform a full backup using 2 disk channels. Allocate the channels manually. Check the repository to determine the location, name and number of backup sets created. How many backup sets were created? Why?
      • Note: Use the following command to see information about the backup sets created:
      • RMAN> list backup of database tag=test1;
      • Refer to the lesson Scripting and Reporting for more information on the LIST BACKUP command.
    1. Use automatic channel allocation (i.e. do not code the ALLOCATE CHANNEL commands) to backup the database using two channels. Limit the backup pieces (files) per backupset to 2.

Other Text:
(Examples or comments displayed on slide, if any).