Wednesday, January 5, 2011

RMAN Essentials

  • RMAN script to take database backup
Here is an RMAN script to take cold backup. The two input parameters are degree of parallelism and the diskgroup on which you want to take the backup :

setenv ORACLE_SID
rman target /
shutdown immediate ;
startup mount ;

show all ;
configure device type disk parallelism <degree of parallelism> backup type to  backupset
configure channel device type disk format  '<diskgroupname>';

backup database ;
alter database open;
  • Set timestamp for RMAN backup

Before invoking RMAN, set the NLS_DATE_FORMAT and NLS_LANG environment variables. These variables determine the format used for the time parameters in RMAN commands such as RESTORE, RECOVER, and REPORT.
The following example shows typical language and date format settings:
  • NLS_LANG=american
  • NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'
If you are going to use RMAN to connect to an unmounted database and mount the database later while RMAN is still connected, then set the NLS_LANG environment variable so that it also specifies the character set used by the database.
A database that is not mounted assumes the default character set, which is US7ASCII. If your character set is different from the default, then RMAN returns errors after the database is mounted. For example, if the character set is WE8DEC, you can set the NLS_LANG parameter as follows:
  • NLS_LANG=american_america.we8dec
NLS_LANG and NLS_DATE_FORMAT must be set for NLS_DATE_FORMAT to be used.
  • Basic RMAN settings
Rman allows you to configure the following:
1) Device type on which to take the backup: the device type can be disk or tape.
  • You can set  device type to be disk as under:
    •  device type disk ;
2) Ability to compress the backup sets. 
  • You can take compressed backup sets by using the following clause:
    • as compressed backup
3) Backup tag: RMAN attaches a character string called tag to every backup it creates.
  • You can either accept the default tag or specify your own tag with TAG paramter s under
    • tag test_tag
4) Specify the type of backup (backup sets or image copies).
  • This can be specified as
    • as copy or as backupset clause
5) Location in the disk where you want to save backup: format 'filename'
  • To save in ASM diskgroup
    • configure channel device type disk format '+dgroup1';
  • To save the backup on disk
    • configure channel device type disk format '/backupP/bench/%U' ;
       (ensure that you have created /backupP/bench directory. %U will generate unique filenames)
6) Setting the environment:
  • Show all command shows the default setting.
  • You can change the default setting with the configure command. for eg, to take compressed backups on disk of type backupset :
    • configure device type disk backup type to compressed backupset;
7) Log file:
Where does rman stores log file : no where unless you specify log

Just clarifying -- Oracle docs show the following:

"LOG = Specifies the file where Recovery Manager will record RMAN output, that is, the commands that were processed and their results. If you do not specify this argument, then RMAN writes its message log file to standard output. "

That being said, if you don't specify a log then it appears your standard output is the terminal. (So no log -- sorry.)

You can specify the log file as under:

rman target sys@mydbt log=d:\rman.log

Additional info :
http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/rcmbckba.htm#i1006582

  • Configuring channels in RMAN:
RMAN channel is a connection to a database server session. You can use configure channel command to configure options for disk or tape channels.
  • Configure channel command sets setting for generic channels (all channels) 
  •  allocate channel command sets setting for particular channel.
By default RMAN allocates one disk channel for all operations, you can configure channel parallelism for disk and tapes.You can specify channel parallelism by configure device command as under:
  • configure device type disk parallelism 10 backup type to compressed backupset
  • Configuring the fast recovery area:
Enable the fast recovery area by setting the following parameters:
  • db_recovery_file_dest_size: <size of the fast recovery area>
  • db_recovery_file_dest:<location of fast recovery area>
Leaving db_recovery_file_dest empty disables the flash recovery area. Here is an example of disabling the flash recovery area by resetting the db_recovery_file_dest parameter:
  • alter system set db_recovery_file_dest=' ' scope=both;


  • Set database in archive mode: 
  • To restore the database
rman target /
run{
startup mount
restore database;
recover database;
alter database open resetlogs;
}

No comments:

Post a Comment