How to configure RMAN to work with Netbackup for Oracle
NOTE: In the images and/or the document content below, the user information and environment data used
represents fictitious data from the Oracle sample schema(s),Public Documentation delivered with an Oracle
database product or other training material. Any similarity to actual environments, actual persons, living or
dead, is purely coincidental and not intended in any manner.
For the purposes of this document, the following fictitious environment is used as an example to describe
the procedure:
Catalog database: RCAT1
Instance Name = inst1
Tablespace=CATTBS,TEMP,ROLLBACK
Schema=RMAN
Directory = /usr,/u01,/u02/oradata and all subdirectories
Solution:
=========
Steps for configuring Netbackup for Oracle :
1. First of all we need to decide whether we want to use Recovery
catalog or not. Recovery catalog stores critical backup information
that is required for doing a database restore. It stores information
about
a. Datafiles and archived redolog, backupset and backuppiece
information
b. Datafile copy information
c. Archived redo logs and their copy information
d. Tablespaces and datafiles on the target database information
e. Stored scripts
We can also use RMAN without a recovery catalog wherein all these
information, except the scripts, are stored in the control files
of the database. Moredetails about this, is given in the
Oracle 8i Backup and Recovery Guide.
Oracle recommends the use of a Recovery catalog if you have more than 20
datafiles in an instance. Since you find critical information in this,
we need to keep this catalog away from the target database, because if
it's on the same database and in the same disk where we have the
datafiles, if the database crashes or the disk gets corrupted, it's
very difficult to restore the database. So Oracle recommends that in
case we need to backup 2 databases on 2 servers.
2. Create a database for housing the recovery catalog. Lets' call
this instance as RCAT1. The typical disk space requirements depends on
the number of databases this catalog monitors, the number and size of
the stored scripts and it grows as the number of archived logs and
backups grow. The typical requirement for 1 year is :
SYSTEM TABLESPACE : 100 MB (depends on the Oracle release)
TEMP TABLESPACE : 5 MB
ROLLBACK SEGMENT : 5 MB
ONLINE REDO LOG : 1 MB for each
RECOVERY CATALOG : 10 MB
You can create this database using the dbassist command in Oracle.
3. Create a tablespace called "cattbs" for holding the recovery catalog.
$ sqlplus sys/@RCAT1
SQL> create tablespace cattbs DATAFILE '' SIZE 10M;
SQL> exit
4. Create a user for using the recovery catalog.
$ sqlplus sys/@RCAT1
SQL > create user rman identified by
temporary tablespace temp
default tablespace cattbs
quota unlimited on cattbs;
where cattbs -> is the name of the recovery catalog's tablespace.
SQL> grant RECOVERY_CATALOG_OWNER to rman;
SQL> grant connect, resource to rman;
5. Now the user has been created try testing the connection as the user RMAN.
$ sqlplus rman/@RCAT1
This should work fine.
6. Now create the RMAN catalog tables in the tablespace CATTBS .
$ rman catalog rman/@RCAT1
RMAN> create catalog tablespace cattbs;
This command takes some time when the tables are created. Query this,
to see if the tables have been created or not .
$ sqlplus rman/@rcat1
SQL > select table_name from user_tables ;
This should list all the table names from the catalog .
7. Now you need to register the target database with the recovery
catalog. Before this, if the database is running in MTS mode, make
sure that RMAN gets a dedicated server connection when connecting. For
this create an entry in $ORACLE_HOME/network/admin/tnsnames.ora file
Inst1_ded =
(description =
(address = (protocol = TCP) (host = ) (port = 1521))
(connect_data = (service_name = inst1) (server = dedicated))
)
You can test this connection to see if it's a dedicated server
connection or not ..
$ sqlplus sys/@inst1_ded
SQL> select server from v$session
where sid = (select distinct sid from v$mystat);
Here you should get DEDICATED .
8. Register the target database .
$ rman target sys/@inst1_ded catalog rman/@RCAT1
RMAN> register database;
Please note that RMAN connects to the target database using a user who
has a SYSDBA privilege defined in the target.
9. Now you are all set to use the catalog for storing the backup
information. A recovery catalog can store information for multiple
target databases. So it needs to be backed up frequently. In case this
catalog is lost, we can reconstruct the catalog partially from the
current control file or it's copies. The recovery catalog should be run
in ARCHIVELOG mode.
10. The recovery catalog can be backed up using any appropiate backup
scenario like, export command, cold or hot backup strategy.
Export :
$ exp rman/@rcat1 file = RCAT1_backup.dmp owner=rman
Oracle recommends for Oracle9i :
- Run the recovery catalog database in ARCHIVELOG mode so that you
can do point-in-time recovery is needed.
- Set the retention policy to a REDUNDANCY value greater than 1.
- Back up the database onto two separate media (for example, disk and tape).
You can specify BACKUP COPIES 2 when making backups.
- Run BACKUP DATABASE PLUS ARCHIVELOG at regular intervals, to a media
manager if available or just to disk.
- Do not use another recovery catalog as the repository for the backups.
- Configure the control file autobackup feature to ON.
11. Now the Netbackup server must have already been configured and
the Oracle server must have been configured as a Netbackup client. Load
the Netbackup for Oracle CD into the Oracle server and mount it.
# cd /cdrom/cdrom0
# ./install
Answer the prompts accordingly.
After the installation is complete , do
# cd /usr/openv/netbackup/dbext
# ./install_dbext
12. Prior to Oracle9i, by default a backup API library has been supplied with
Oracle. This needs to be disabled and we need to use the library that's
supplied with Netbackup. Otherwise we get all sorts of error messages ..
Please follow the steps mentioned in the Netbackup for Oracle manual on
doing this .
For 8.1.6 , the following steps need to be done .
# su – oracle
Shutdown all the Oracle instances on the server .
$ svrmgrl
SVRMGR> connect internal
SVRMGR> shutdown
SVRMGR> exit
$ cd $ORACLE_HOME/lib
$ mv libobk.so libobk.so.orig
$ ln –s /usr/openv/netbackup/bin/libobk.so.1 libobk.so
$ cd $ORACLE_HOME/bin
$ cp oracle oracle.orig
$ cd $ORACLE_HOME/rdbms/lib
$ make –f ins_rdbms.mk ioracle
Start the instances again .
$ svrmgrl connect internal
SVRMGR> startup
SVRMGR> exit
13. Now the database has been configured to use the Netbackup API
library for backing up.
14. There are some sample scripts given by Netbackup for backing up
the Database, tablespace and restoring them. It's present in
/usr/openv/netbackup/ext/db_ext/oracle/samples/rman/ directory. We need
to customize these scripts according to our requirement.
15. Go to the Netbackup Primary server and setup classes for the
Oracle backup.
Start the xbpadm window using
# /usr/openv/netbackup/bin/xbpadm &
Actions -> New -> Classes
Class type : Oracle
Class name : Daily_oracle
Volume Pool : Specify the Volume pool where the Oracle backups
are stored in.
Clients : Specify the client names and their Hardware and OS
version ( e.g. : Solaris / Solaris 2.6 )
Schedules : Specify 2 schedules. By default a backup policy is
created.
- Backup type : Oracle
- Schedule type : backup policy
- Retention period , Frequency and times
Refer to the Netbackup for Oracle manual for more information.
Create another backup schedule with the schedule type as : Automatic
full backup / differential incremental / Cumulative incremental (
depending on requirement ). All the other things are same as the backup
policy.
File list : Specify the path of the Database backup script in the
client machine.
For e.g. : /u01/app/oracle/product/8.1.6/backup_scripts/hot_db_backup.sh
Basically during backup, the backup server initiates these commands on
the client machine during the backup window, so that the client runs
the RMAN commands and sends the backup to the Netbackup server and
finally to the Tape library. This script is basically a customized
version of the sample script found in
/usr/openv/netbackup/ext/db_ext/oracle/samples/rman/ directory.
The scripts have detailed information on what needs to be customised
for the particular environment.
Now save the class, terminate the media manager request daemon BPRD and
restart the same again, so that the change takes into effect
immediately. For killing the BPRD daemon,
Xbpadm -> File -> Terminate the Request daemon.
For starting the daemon again,
# /usr/openv/netbackup/bin/initbprd
16. Now you can check the status of the backup from the Job Monitor
of Netbackup or you can view the text file which is the one where the
output of the hot_database_backup.sh script is written.
# tail –f $ORACLE_HOME/backup_scripts/hot_db_backup_level0.out
Some useful commands in RMAN:
1. Starting a database from RMAN.
RMAN> startup mount pfile=/u01/app/oracle/product/8.1.6/dbs/init.ora
2. To see a database schema:
RMAN> report schema;
3. To copy a Datafile to say another disk.
RMAN> run {
Allocate channel c1 type disk ;
Copy Datafile 1 to '/u02/oradata/backup/datafile1.bak';
}
4. To backup a tablespace :
RMAN> run {
Allocate channel c1 type 'SBT_TAPE';
Backup tablespace system ;
}
5. Listing the backups :
RMAN> list backup;
6. Validate the backup, so that it does a test run and checks if
the backup can be restored successfully. Run the LIST command to find
the primary key for the backup set.
RMAN> list backup;
RMAN> run {
Allocate channel c1 type 'SBT_TAPE';
Validate backup set 3; # This validates the entire backup set
Restore controlfile validate; # This does for a control file
Restore tablespace system validate; # for a tablespace "SYSTEM"
Restore archivelog all validate; # For all archivelog
}
7. Use the list and report commands for querying the recovery catalog.
LIST – This command queries the catalog / control file to produce a
listing of its contents.
$ rman target sys/@PROD1 catalog rman/@RCAT1
RMAN> list copy of database archivelog all;
RMAN> list backup;
For particular objects :
RMAN> list backup of database; # all files in the database
RMAN> list copy of Datafile '/u01/oracle/dbs/tbs1.dbf';
RMAN> list copy of archivelog all;
RMAN> list backup of tablespace 'SYSTEM';
RMAN> list backup of control file;
REPORT – This command is used for getting a detailed information from
the catalog like
a. Which files need a backup
b. Which files haven't been backed up recently
c. Which files are listed unrecoverable
d. Which backup sets are obsolete and can be deleted
e. Which copies are on disk and which are on tape
To identify which datafiles need a backup :
RMAN> report need backup days = 7 database;
RMAN> report need backup days = 30 tablespace system;
Where days = x , is the number of days of archive logs required to
recover the database safely.
Types of Oracle backups :
1. Full -> It backs up all the used datablocks in a Datafile. It's
not the same as a Incremental Level 0 backup.
2. Incremental -> It backs up only all the data blocks that have
changed since the last incremental backup.
During a restore we need to have a level-0 backup also.
3. Open -> Backup of any part of target database when it is open
4. Closed -> When the database is mounted, but closed.
5. Consistent -> The database is mounted but not open. The
database must have been shutdown cleanly before this step.
The checkpoint SCNs in the datafile headers must match the
corresponding SCNs in the datafile records in the control file,
and the datafiles must not be fuzzy..
This backup can be restored without recovery.
6. Inconsistent -> The backup of the database when it is open, when it crashed
lasttime, when it was mounted or after a shutdown abort
before backup. It requires a database recovery.
Reference
=========
Oracle8i backup and recovery guide
Netbackup 3.2 Administrator's guide
Netbackup 3.2 media manager's guide
Netbackup for Oracle installation guide
Note.209117.1 : How to Install, Configure, Check and Troubleshoot
VERITAS NetBackup 4.5 for Oracle
Additional Keywords
===================
Solaris; Configure Netbackup; VOS
Note:
=====
This document was written by VOS JEC
(Veritas Oracle Sun Joint Escalation Cente