Write down the steps to setup RMAN?
Steps to
Setup RMAN
This article
is tested in oracle10gR2. How do we setup the RMAN in oracle? There are couple
of ways, we can setup the RMAN. We can use control file to store backup catalog
info or we can have seperate database to store catalog info. Here i am using
seperate database to store backup catalog information.
You might
ask a question yourself, why would we need RMAN backup? Why do we need to setup
RMAN, since my traditional backups are already running fine.... I already
discussed this in another thread.. Please see this link to answer your
question. Click
I am using
windows OS. Please remember, the directories and folder might change based on
the operating system and environment. But the below steps are pretty much same
for any environmnet.
Here i am
using ORCL as primary database and CATDB as catalog database.
Step1
Enable the
archive log in ORCL database. I already discussed this in another thread.
Please refer this link to enable the database to archive log mode.
Step2
Create the
tablespace and user in catalog database to hold backup information.
SQL>
CONNECT sys/password@catdb AS SYSDBA
Connected.
SQL>
CREATE TABLESPACE RMAN
2 DATAFILE
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\CATDB\RMAN01.DBF' SIZE 6208K REUSE
3 AUTOEXTEND
ON NEXT 64K MAXSIZE 32767M
4 EXTENT
MANAGEMENT LOCAL
5 SEGMENT
SPACE MANAGEMENT AUTO;
Tablespace
created.
SQL>
CREATE USER rman IDENTIFIED BY rman
2 TEMPORARY
TABLESPACE temp
3 DEFAULT
TABLESPACE rman
4 QUOTA
UNLIMITED ON rman;
User
created.
Grant
succeeded.
SQL>
Step3
Create the recovery catalog in catalog
database.
C:\>rman
catalog=rman/rman@catdb
Recovery
Manager: Release 10.2.0.1.0 - Production on Thu May 21 09:59:26 2009
Copyright
(c) 1982, 2005, Oracle. All rights reserved.
connected to
recovery catalog database
RMAN>
create catalog tablespace "RMAN";
recovery
catalog created
RMAN>
exit
Recovery
Manager complete.
C:\>
Step4
Register the database with Catalog
database. Each database should be registered to catalog database to run RMAN
backup.
C:\>rman
catalog=rman/rman@catdb target=sys/password@orcl
Recovery
Manager: Release 10.2.0.1.0 - Production on Thu May 21 10:02:01 2009
Copyright
(c) 1982, 2005, Oracle. All rights reserved.
connected to
target database: ORCL (DBID=1215124933)
connected to
recovery catalog database
RMAN>
register database;
database
registered in recovery catalog
starting full
resync of recovery catalog
full resync
complete
RMAN>
exit
Recovery
Manager complete.
C:\>
Step5
Configure
the persistent parameters.
C:\>rman
catalog=rman/rman@catdb target=sys/password@orcl
Recovery
Manager: Release 10.2.0.1.0 - Production on Tue May 19 18:46:40 2009
Copyright
(c) 1982, 2005, Oracle. All rights reserved.
connected to
target database: ORCL (DBID=1215054467)
connected to
recovery catalog database
RMAN>
configure retention policy to recovery window of 2 days;
new RMAN
configuration parameters:
CONFIGURE
RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
new RMAN
configuration parameters are successfully stored
starting full
resync of recovery catalog
full resync
complete
RMAN>
configure default device type to disk;
new RMAN
configuration parameters:
CONFIGURE
DEFAULT DEVICE TYPE TO DISK;
new RMAN
configuration parameters are successfully stored
starting full
resync of recovery catalog
full resync
complete
RMAN>
configure controlfile autobackup on;
new RMAN
configuration parameters:
CONFIGURE
CONTROLFILE AUTOBACKUP ON;
new RMAN
configuration parameters are successfully stored
starting full
resync of recovery catalog
full resync
complete
RMAN>
configure channel device type disk format 'C:\rmanbackup\Backup%d_DB_%U_%S
_%P';
new RMAN
configuration parameters:
CONFIGURE
CHANNEL DEVICE TYPE DISK FORMAT 'C:\rmanbackup\Backup%d_DB_%U_%S_%P'
;
new RMAN
configuration parameters are successfully stored
starting full
resync of recovery catalog
full resync
complete
RMAN>
Step 6
Take
database full backup. The full database backup should be taken first time.
Afterwards, archivelog backup will be taken.
C:\>rman
catalog=rman/rman@catdb target=sys/password@orcl
Recovery
Manager: Release 10.2.0.1.0 - Production on Thu May 21 10:16:09 2009
Copyright
(c) 1982, 2005, Oracle. All rights reserved.
connected to
target database: ORCL (DBID=1215124933)
connected to
recovery catalog database
RMAN> run{
2> backup
database plus archivelog;
3> delete
noprompt obsolete;
4> }
starting full
resync of recovery catalog
full resync
complete
Starting
backup at 21-MAY-09
current log
archived
allocated
channel: ORA_DISK_1
channel
ORA_DISK_1: sid=144 devtype=DISK
channel
ORA_DISK_1: starting archive log backupset
channel
ORA_DISK_1: specifying archive log(s) in backup set
input
archive log thread=1 sequence=2 recid=1 stamp=687435222
input
archive log thread=1 sequence=3 recid=2 stamp=687435237
input
archive log thread=1 sequence=4 recid=3 stamp=687435270
input
archive log thread=1 sequence=5 recid=4 stamp=687435279
input
archive log thread=1 sequence=6 recid=5 stamp=687435420
channel
ORA_DISK_1: starting piece 1 at 21-MAY-09
channel
ORA_DISK_1: finished piece 1 at 21-MAY-09
piece
handle=C:\RMANBACKUP\BACKUPORCL_DB_01KFIRKU_1_1_%S_%P tag=TAG20090521T1017
01
comment=NONE
channel
ORA_DISK_1: backup set complete, elapsed time: 00:00:16
Finished
backup at 21-MAY-09
Starting
backup at 21-MAY-09
using
channel ORA_DISK_1
channel
ORA_DISK_1: starting full datafile backupset
channel
ORA_DISK_1: specifying datafile(s) in backupset
input datafile
fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
input datafile
fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
input datafile
fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
input datafile
fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DB
F
channel
ORA_DISK_1: starting piece 1 at 21-MAY-09
channel
ORA_DISK_1: finished piece 1 at 21-MAY-09
piece
handle=C:\RMANBACKUP\BACKUPORCL_DB_02KFIRLF_1_1_%S_%P tag=TAG20090521T1017
19
comment=NONE
channel
ORA_DISK_1: backup set complete, elapsed time: 00:01:06
Finished
backup at 21-MAY-09
Starting
backup at 21-MAY-09
current log
archived
using
channel ORA_DISK_1
channel
ORA_DISK_1: starting archive log backupset
channel
ORA_DISK_1: specifying archive log(s) in backup set
input
archive log thread=1 sequence=7 recid=6 stamp=687435506
channel
ORA_DISK_1: starting piece 1 at 21-MAY-09
channel
ORA_DISK_1: finished piece 1 at 21-MAY-09
piece
handle=C:\RMANBACKUP\BACKUPORCL_DB_03KFIRNJ_1_1_%S_%P tag=TAG20090521T1018
27
comment=NONE
channel
ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished
backup at 21-MAY-09
Starting
Control File and SPFILE Autobackup at 21-MAY-09
piece
handle=C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\C-1215124933-20090521-00 com
ment=NONE
Finished
Control File and SPFILE Autobackup at 21-MAY-09
RMAN
retention policy will be applied to the command
RMAN
retention policy is set to recovery window of 2 days
using
channel ORA_DISK_1
no obsolete
backups found
RMAN>
exit
Recovery
Manager complete.
C:\>
Now the RMAN
setup is completed successfully. Here are the info about RMAN.
Primary DB =
ORCL
Catalog DB =
CATDB
RMAN Backup
location = c:\rmanbackup.
Now the full
backup is taken. Every day, the below script should run and backup the new
archive log files.
C:\>rman
catalog=rman/rman@catdb target=sys/password@orcl
Recovery
Manager: Release 10.2.0.1.0 - Production on Thu May 21 10:25:40 2009
Copyright
(c) 1982, 2005, Oracle. All rights reserved.
connected to
target database: ORCL (DBID=1215124933)
connected to
recovery catalog database
RMAN> run{
2> delete
noprompt obsolete;
3> backup
archivelog all;
4> }
RMAN retention
policy will be applied to the command
RMAN
retention policy is set to recovery window of 2 days
allocated
channel: ORA_DISK_1
channel
ORA_DISK_1: sid=133 devtype=DISK
no obsolete
backups found
Starting
backup at 21-MAY-09
current log
archived
using
channel ORA_DISK_1
channel
ORA_DISK_1: starting archive log backupset
channel
ORA_DISK_1: specifying archive log(s) in backup set
input
archive log thread=1 sequence=2 recid=1 stamp=687435222
input
archive log thread=1 sequence=3 recid=2 stamp=687435237
input
archive log thread=1 sequence=4 recid=3 stamp=687435270
input
archive log thread=1 sequence=5 recid=4 stamp=687435279
input
archive log thread=1 sequence=6 recid=5 stamp=687435420
input
archive log thread=1 sequence=7 recid=6 stamp=687435506
input
archive log thread=1 sequence=8 recid=7 stamp=687435975
channel
ORA_DISK_1: starting piece 1 at 21-MAY-09
channel
ORA_DISK_1: finished piece 1 at 21-MAY-09
piece
handle=C:\RMANBACKUP\BACKUPORCL_DB_05KFIS68_1_1_%S_%P tag=TAG20090521T1026
15
comment=NONE
channel
ORA_DISK_1: backup set complete, elapsed time: 00:00:16
Finished
backup at 21-MAY-09
Starting
Control File and SPFILE Autobackup at 21-MAY-09
piece
handle=C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\C-1215124933-20090521-01 com
ment=NONE
Finished
Control File and SPFILE Autobackup at 21-MAY-09
RMAN> exit
Recovery
Manager complete.
C:\>
How do we
schedule the daily backup in Windows OS?
We need to
write two script, one is batch file(named as daily_backup.bat) which should
contain the following command.
rman
catalog=rman/rman@catdb target=sys/password@orcl cmdfile daily_backup.sql
Another one
is text file(named as daily_backup.sql) which should contain the following
code.
run
{
backup archivelog
all;
delete
noprompt obsolete;
}
The batch file(daily_backup.bat)
can be run manually, by double-clicking on it, or scheduled using the Scheduled
Tasks Wizard (Start > Programs > Accessories > System Tools >
Scheduled Tasks). The above two windows scripts are tested in windows
environment and works well.
How do we
schedule the daily backup in Unix?
Here we need
to write shell script and schedule the shell script in unix scheduler(crontab).
The shell
script content should be like this....... Please remember, the below shell
script is not tested in unix environment. Please do test yourself in unix
environment.... This is sample shell script...
export
ORACLE_HOME=/usr/app/oracle/product/10.2.0
export
ORACLE_SID=orcl
export ALIAS=orcl
cd
=/usr/app/oracle/product/10.2.0/bin
rman
catalog=rman/rman@catdb target=sys/password@orcl <<
run
{
backup archivelog
all;
delete
noprompt obsolete;
}
exit
EOF
0 comments:
Feel free to contact the admin for any suggestions and help.