Connecting to Target Database
Now we have a recovery catalog we need to register the target database (database to be backed up) with the catalog to get the target databases controlfile information. Since RMAN will need to connect to be the recovery catalog database AND the target database simultaneously, at least one of the database connections MUST be remote. As mentioned earlier, prior to the next step be sure that all listener.ora, tnsnames.ora, and sqlnet.ora files are properly setup. Also be sure that the Oracle listener process is running. In the example below, we are connecting locally to a target database of PROD and a catalog database of RCAT
Prior to any backups, a target database must first be registered with the recovery catalog database. This is done using the REGISTER DATABASE command under RMAN.
$ export ORACLE_SID=PROD
$ rman target / RCVCAT rman/rman@RCAT
Recovery Manager: Release 8.1.5.2.0 - Production
RMAN-06005: connected to target database: PROD
RMAN-06008: connected to recovery catalog database
RMAN> register database;
RMAN> list incarnation of database;
RMAN-03022: compiling command: list
RMAN-06240: List of Database Incarnations
RMAN-06241: DB Key Inc Key DB Name DB ID CUR Reset SCN Reset Time
RMAN-06242: ------ ------- -------- ---------- --- ----- --------------
RMAN-06243: 1 2 PROD 3351020544 YES 1 10-AUG-99
RMAN Command Syntax
Most commands under RMAN must be entered in Run{} Loops. These loops resemble fragments of object-oriented code. Unfortunately, most of the syntax is non-intuitive. The best way to write these scripts is to look at existing, working code.
We will present several examples later.
RMAN Channels
Prior to doing any backups or restores, a channel must be opened. A channel is a write stream to either disk or tape. using the ALLOCATE CHANNEL command inside a RUN {} loop. For parallelism, RMAN allows the use of multiple channels during backups and restores to improve performance. Allocating two channels to an RMAN backup, for example, will cause RMAN to simultaneously write to two files for the database backup. However, keep in mind that multiple channels will not always improve performance, especially when writing to the same disk. Once the backup or restore is complete, a channel(s) is then released to close the write stream. The general syntax for backup and recovery scripts in RMAN is shown below.
Backup Script
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
;
release channel c2;
release channel c1;
}
|
Restore Script
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
;
release channel c2;
release channel c1;
}
|
