Sie sind auf Seite 1von 5

Set up of RMAN (Recovery Manager)

1. To setup RMAN we should also know the name/s of the database/s to be


backed up and also the name of the database where catalog database needs
to be created.

2. In this scenario the TARGET database is OTH1 and catalog database is


TPS1.Steps for setting up RMAN are :

i. Create a tablespace & user to hold the recovery catalog:


CONNECT sys/password@TPS1 AS SYSDBA

ii. Create tablespace to hold repository


CREATE TABLESPACE RMAN
DATAFILE ' /u07/oradata/TPS1/data/rman_01.dbf' SIZE 10M
AUTOEXTEND ON NEXT 10K MAXSIZE 2000M;

iii. Create rman schema owner


CREATE USER rman IDENTIFIED BY rman
FAULT TABLESPACE RMAN
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON RMAN

iv. Grant permissions to user rman


GRANT connect, resource, recovery_catalog_owner TO rman;

v. Create the recovery catalog:

[oracle@ds01acsc rman]$ rman catalog=rman/rman@TPS1

Recovery Manager: Release 9.2.0.3.0 - Production


Copyright (c) 1995, 2002, Oracle Corporation. All rights
reserved.

connected to recovery catalog database


recovery catalog is not installed

RMAN> create catalog tablespace "RMAN";

recovery catalog created

RMAN> exit

Recovery Manager complete.

vi. Register Database

Each database to be backed up by RMAN must be registered:

[oracle@ds01acsc rman]$ rman catalog=rman/rman@TPS1


target=sys/password@<target_db_name>

1
Recovery Manager: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: W2K2 (DBID=1371963417)


connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog


starting full resync of recovery catalog
full resync complete

RMAN>

3. To take the backup of the database following steps needs to be performed

4. First we configure several following parameters before starting backup:

RMAN> configure retention policy to recovery window of 7


days;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;

Full Backup :

Next we perform a Full database backup every Sunday using the following
Shell script:

rman <<EOF
connect target sys/oth1quin@OTH1
connect catalog rman/rman@TPS1
run { allocate channel d1 type disk;
backup full tag backup_1 filesperset 2
format '/u07/oradata/TPS1/bkp_rman/rman_BACKUP_
%d_%t.%p.%s.%c.%n.%u.bus'
database plus archivelog;
release channel d1;
}
EOF

Explanation :

• Create a shell script say rmanFullbkp.sh and copy the above


commands in it and save it. Provide the shell script with proper
execute permissions using i.e. chmod +x rmanFullbkp.sh.

• Then execute the script ./ rmanFullbkp.sh

• As the OTH1 have 7 datafiles the backup sets created would be 5 (4


for datafiles & 1 for controlfile) having two files per backup set as
mentioned in above command.

• The control file backup set is created in the dbs directory of the target
database i.e. /u01/app/oracle/product/9.2.0/dbs/ and the bacjup sets
are created on the path specified in the format.

2
Incremental Backups (cumulative type)

For taking the incremental backups the following scripts needs to be set up in
cronjob.
The very first incremental would be of Level 0 i.e. on Monday and after that
Level 1 incremental backup would be taken from Tuesday till Saturday.

For Level 0 type of incremental backup the script is:

rman <<EOF
connect target sys/oth1quin@OTH1
connect catalog rman/rman@TPS1
run { allocate channel d1 type disk;
backup incremental level 0
filesperset 2
format '/u07/oradata/TPS1/bkp_rman/rman_LVL0_%d.
%t.%p.%c.bus'
database plus archivelog;
release channel d1;
}
EOF

For level 1 type of incremental backup the script is:

rman <<EOF
connect target sys/oth1quin@OTH1
connect catalog rman/rman@TPS1
run { allocate channel d1 type disk;
backup incremental level 1
filesperset 2
format '/u07/oradata/TPS1/bkp_rman/rman_LVL1_%d.%t.%p.%c.bus'
database plus archivelog;
release channel d1;
}
EOF

5. The most important task after every backup taken using RMAN is to resync
the catalog database with the target database and this can be achieved by
the following command ,
RMAN> resync catalog;
The same can be set in cronjob but keeping in mind that it is run after the
incremental or full backup completes for that day.

6. Useful queries in getting the information from RMAN catalog database:

• Run the following in SQL prompt from rman login to the catalog database:

• Select DB_ID,stamp,backup_type,incremental_level,pieces,start_time,
controlfile_included from RC_BACKUP_SET;

• To Check the backup progress run the following query ( it shows output if
the backup operation is too long due to the big size of the target
database):
select sid, serial#, context,
round(sofar/totalwork*100,2) "% Complete",

3
substr(to_char(sysdate,'yymmdd hh24:mi:ss'),1,15) "Time Now"
from v$session_longops;

This will produce an output such as:

SID SERIAL# CONTEXT % Complete Time Now


---------- ---------- ------------- --------------- -------------------

• The following commands need to run from RMAN prompt


i. To see the backups in catalog database
list backup;

ii. To list all of the archivelogs backed up.


list backupset of archivelog all;

iii. Using date as a range specifier. i.e. list archives older then 3 days.
list backupset of archivelog until time "sysdate - 3";

iv. List how many incarnations of the database and the key numbers.
list incarnation of database;

v. List backupsets or a backupset from the target database.


list backupset of database;
or
list backupset of database until time "sysdate-14";

vi. List backups of the tablespaces i.e. USERS.


list backupset of tablespace 'USERS';

vii. List backups by datafile number.


list backupset of datafile 5;

viii. To report what has not had a backup for 5 days or more for the database.
report need backup days 5 database;

ix. Report which backupsets are not consistent and cannot be used for
recovery.
report unrecoverable database;

x. To find the backup sets for last 7 days in order to find backupsets that
can be removed from the catalog use:
report obsolete redundancy 7;

xi. To report all the datafiles and tablespaces in the target.


report schema;

xii. To report files that will require the application of 5 incremental backups
to recover the database.

report need backup incremental 5 database;

xiii. To report the database schema a month ago:

report schema at time "TO_DATE('08/29/05','MM/DD/YY')";

4
7. Problems / Issues and Solutions:

• If below mentioned error is faced then we need to check the init.ora file
on target database server for the following parameter and it should be set to
EXCLUSIVE i.e. “remote_login_passwordfile=EXCLUSIVE”

[oracle@ds01acsc commands]$ rman catalog=rman/rman@TPS1


target=sys/utftstquin@UTFTST

Recovery Manager: Release 9.2.0.3.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

RMAN-00571:
==========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
==========================================================
=
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-01031: insufficient privileges

• At present the backupsets are created on the target database server


including the (control files , datafiles, archive logs).It would be more beneficial of
using RMAN if the backup sets are created on the destination other than target
database server.

Das könnte Ihnen auch gefallen