Ready to be sorted
--==========================
--creation and use of RMAN catalog
--==========================
First, create a recovery directory
Creating a recovery directory is generally divided into three main steps
Create a database that holds the recovery directory (or use an existing database)
Create the owner of the recovery catalog
Create a Recovery Catalog
To create a database, refer to: Oralce 10g Creating a database using DBCA
Create a table space in the database where the recovery catalog is stored to store the recovered directory schema and recover directory data (this article uses the database catadb that you have created to store the recovery directory)
sql> Create tablespace tbs_rman datafile '/u01/app/oracle/oradata/catadb/tbs_rman01.dbf '--Creating Rman Recovery directory tablespace
2 size 200m autoextend on;
Sql> create user Rman identified by Rman--Creating an Rman schema
2 Temporary Tablespace Temp
3 Default Tablespace Tbs_rman
4 Quota unlimited on Tbs_rman;
Sql> Grant Recovery_catalog_owner to Rman; --Role Grant
Sql> Conn Rman/rman
Sql> select * from Session_privs;
PRIVILEGE
----------------------------------------
CREATE SESSION
ALTER SESSION
CREATE TABLE
CREATE CLUSTER
CREATE synonym
CREATE VIEW
CREATE SEQUENCE
CREATE DATABASE LINK
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
Sql> select * from Session_roles;
ROLE
------------------------------
Recovery_catalog_owner
Rman> Connect catalog Rman/[email protected]--Connect to the recovery directory
Connected to Recovery Catalog database
rman> Create catalog Tablespace Tbs_rman; --Create a recovery directory
Recovery Catalog Created
[[email protected] ~]$ Rman target sys/[email protected] catalog Rman/[email protected]--connect to target database and recover directory
Connected to target DATABASE:ORCL (dbid=1260850162)
Connected to Recovery Catalog database
rman> Register database; --Registering the target database with the recovery directory
Database registered in Recovery catalog
Starting full resync of recovery catalog
Full Resync Complete
Second, backup based on recovery directory
1. View related information
rman> list incarnation;
List of Database incarnations
DB Key Inc key DB Name db ID STATUS reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 8 ORCL 1260850162 PARENT 1 30-jun-05
1 2 ORCL 1260850162 current 446075 22-oct-10
----------------------------------------------------------------------------------------------------
rman> crosscheck copy; --Verifying copy
rman> Delete expired copy; --Delete the expired copy
2. Fully prepared
Rman> run{
2> Allocate channel CH1 device type disk;
3> Backup as Compressed backupset
4> database plus Archivelog Delete input
5> format= '/u01/app/oracle/bk/rmbk/whole_%d_%u '
6> tag= ' Whole_bak ';
7> release channel Ch1;}
3. Incremental backup (Level 0)
Rman> run{
2> Allocate channel CH1 device type disk;
3> Allocate channel CH2 device type disk;
4> Backup as Compressed backupset
5> Incremental Level 0
6> database plus Archivelog Delete input
7> format= '/u01/app/oracle/bk/rmbk/inc_0_%d_%u '
8> tag= ' inc_0 ';
9> release channel CH1;
10> release channel CH2;}
Rman> list Backup summary;
4. Incremental backup (Level 1)
Rman> run{
2> Allocate channel CH1 device type disk;
3> Allocate channel CH2 device type disk;
4> Backup as Compressed backupset
5> Incremental Level 1 database
6> format= '/u01/app/oracle/bk/rmbk/inc_1_%d_%u '
7> tag= ' inc_1 ';
8> release channel CH1;
9> release channel CH2;}
Rman> list backup by file;
5. Cumulative incremental backup (Level 1)
Rman> run{
2> Allocate channel CH1 device type disk;
3> Backup as Compressed backupset
4> Incremental Level 1 cumulative database
5> format '/u01/app/oracle/bk/rmbk/cum_1_%d_%u '
6> tag= ' cum_1 ';
7> release channel Ch1;}
6. Backing Up table spaces
Rman> run{
2> Allocate channel CH1 device type disk;
3> Backup as Compressed backupset
4> tablespace users,example
5> format= '/u01/app/oracle/bk/rmbk/tbs_%d_%u '
6> tag= ' TBS ';
rman> list backupset Tag=tbs;
7. Backing up data files
Rman> run{
2> Allocate channel CH1 device type disk;
3> Backup as Compressed backupset
4> datafile 3
5> format= '/u01/app/oracle/bk/rmbk/df_%d_%u '
6> tag= ' DF ';
7> release channel Ch1;}
8. Backing Up archive logs
Before backing up the archive log, it is recommended that you check the crosscheck first
Crosscheck is usually used to check if the backup is deleted and will be deleted if deleted.
Rman> crosscheck Archivelog All;
Allocated Channel:ora_disk_1
Channel ora_disk_1:sid=148 Devtype=disk
Validation succeeded for archived log
Archive Log Filename=/u01/app/oracle/oradata/orcl/arch/log_1_117_733069427.arc recid=111 stamp=733171369
Crosschecked 1 Objects
Rman> SQL ' alter system switch logfile ';
SQL Statement:alter System Switch logfile
Rman> SQL ' alter system switch logfile ';
SQL Statement:alter System Switch logfile
rman> list Archivelog all;
List of archived Log Copies
Key thrd Seq S Low Time Name
------- ---- ------- - --------- ----
465 1 117 A 22-oct-10/u01/app/oracle/oradata/orcl/arch/log_1_117_733069427.arc
553 1 118 A 23-oct-10/u01/app/oracle/oradata/orcl/arch/log_1_118_733069427.arc
569 1 119 A 23-oct-10/u01/app/oracle/oradata/orcl/arch/log_1_119_733069427.arc
9. Backing up archive logs based on SCN
Rman> run{
2> Allocate channel CH1 device type disk;
3> Backup as Compressed backupset
4> Archivelog from SCN 848043
5> format= '/u01/app/oracle/bk/rmbk/arc_%d_%u '
6> tag= ' arc ';
7> release channel CH1;
8>}
10. Mirrored Backup
Rman> run{
2> Allocate channel CH1 device type disk;
3> Backup as Copy datafile 1,4
4> format '/u01/app/oracle/bk/rmbk/df_%d_%u '
5> tag ' Copybak ';
6> release channel Ch1;}
11. Other
Rman> Crosscheck backupset;
rman> Change Backupset 1
Rman> Validate Backupset
Rman> Validate Backupset 635;
Rman_ Study notes 3_rman Catalog Recovery Directory