Understanding RMAN
Recovery manager (RMAN) is an oracle tool for backing up, restoring and recovering oracle databases. The major task of an oracle dba is to make sure data is available for use anytime and everytime the need arise. Availability and reliability is the key responsibility of a dba.
Connection
Logging into RMAN is very easy. Use this command “RMAN TARGET /” or “rman target my_db”
set ORACLE_SID=orcl
C:\Users\kelebute>rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Dec 21 11:48:33 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1328927802)
RMAN>
or
rman
RMAN> connect target sys/****@orcl
You don't have to specify the "as sysdba" because it is silently implied when you log into RMAN.
To view all the configurations in rman for a particular database, you can use “show all” command.
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # 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 ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOA
D TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'C:\APP\KELEBUTE\PRODUCT\11.2.0\DBHOME_1\
DATABASE\SNCFORCL.ORA'; # default
checking your configuration
v$rman_configuration
This view provides the summary of RMAN configuration. You could also use show all to retrieve RMAN configuration.
SQL> SELECT * FROM V$RMAN_CONFIGURATION;
CONF# NAME VALUE
---------- ------------------------------ ------------------------
1 RETENTION POLICY TO REDUNDANCY 3
2 BACKUP OPTIMIZATION ON
3 DEFAULT DEVICE TYPE TO Disc
4 CONTROLFILE AUTOBACKUP ON
5 DEVICE TYPE DISK PARALLELISM 1
Backing up a database in noarchivelog mode
rman target /
run {
shutdown immediate;
startup mount;
backup database;
alter database open;
shutdown immediate;
}
Backing up a database in archivelog mode
man target /
RMAN> backup database plus archivelog;
Backup with archivelog delete input
backup database plus archivelog delete input;
Deleting archivelogs
delete expired archivelog all;
or
CROSSCHECK ARCHIVELOG ALL;
delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-5';
You can change the date as you want.
incremental backup every night Mon - Sat
This is for updates on only the blocks that changed since last backup.
RMAN> backup incremental level 0 database tag="SUNDAY";
RMAN> backup incremental level 3 database tag="MONDAY";
RMAN> backup incremental level 3 database tag="TUESDAY";
RMAN> backup incremental level 3 database tag="WEDNESDAY";
RMAN> backup incremental level 2 database tag="THURSDAY";
RMAN> backup incremental level 3 database tag="FRIDAY";
RMAN> backup incremental level 3 database tag="SATURDAY";
According to Oracle documentation, RMAN is still the best way to backup database and also restore it. We will talk about restoring and recovery databases next time.
Here is the script I presently use. You can adapt to whatever will suit you. Remember to change the ORACLE_SID and location.
script for rman
set ORACLE_SID=ORCL
export ORACLE_SID
RMAN target / log=/home/oracle/rman.log
run{
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '$ORACLE_BASE/backups/datafiles/%d_%T_s%s_s%p' MAXPIECESIZE 4G;
crosscheck backup;
CROSSCHECK ARCHIVELOG ALL;
delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-7';
delete noprompt expired backup;
delete noprompt expired archivelog all;
sql 'alter system switch logfile';
backup database plus archivelog delete all input format '/disk1/backup/full_%U.bkp';
delete noprompt obsolete;
BACKUP VALIDATE DATABASE ARCHIVELOG ALL;
}
Thanks for visiting!
This comment has been removed by a blog administrator.
ReplyDeleteClara,
ReplyDeleteThanks for stopping by and dropping a comment. RMAN is a great tool I love working with. I will be sharing more info on RMAN later. Thanks again!
Kunle
very nice
ReplyDeleteThanks Intek. Glad you like it.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete