Advantage Of RMAN

RMAN

Incremental where only modified data blocks will be copied
Integrity check for the data block in case they are corrupted
Can do parallelism instead of sequential
It automatically manages the backup files without DBA intervention.
It automatically deletes unnecessary backup datafiles and archived redo log files both from disk and tape.
Only RMAN provides the ability to perform encrypted backups.
RMAN manages the delete archivelog policy.RMAN Backup and Recovery


Figure: RMAN Channel allocation

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence 17

Next log sequence to archive 19

Current log sequence 19

SQL> create table b(name varchar2(100));

Table created.

SQL> insert into b values(‘**** INSERT BEFORE BACKUP *****’);

1 row created.

SQL> commit;

Commit complete.

H:>set oracle_sid=dba20

H:>rman

RMAN> connect target sys/sys

connected to target database: DBA20 (DBID=847839442)

RMAN> run{

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

backup database;

}

SQL> insert into b values(‘**** INSERT AFTER BACKUP *****’);

1 row created.

SQL> commit;

Commit complete.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

Delete USERS.DBF/SYSTEM.DBF

SQL> startup;

ORACLE instance started.

Total System Global Area 167772160 bytes

Fixed Size 1247876 bytes

Variable Size 71304572 bytes

Database Buffers 88080384 bytes

Redo Buffers 7139328 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 1 – see DBWR trace file

ORA-01110: data file 1: ‘C:\ORACLE\PRODUCT\10.2.0\ORADATA\DBA20\SYSTEM01.DBF’

RMAN> run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

restore database;

recover database;

}

SQL> alter database open;

Database altered.

SQL> select * from b;

NAME


**** INSERT BEFORE BACKUP *****

**** INSERT AFTER BACKUP *****

===================================================================================================

Block Change Tracking Enable /Disable
Enable block change tracking:

SQL> alter database enable block change tracking using

file ‘C:\oracle\product\10.2.0\flash_recovery_area\DBA20\Block Track\block_change_log.log’;

Database altered.

The REUSE option tells Oracle to overwrite any existing file with the specified name.

SQL> alter database enable block change tracking using

file ‘C:\oracle\product\10.2.0\flash_recovery_area\DBA20\Block Track\block_change_log.log’ reuse;

Database altered.

Now that we have enabled block change tracking a new background process called CTWR (change track writer) is started.

To disable block change tracking:

SQL>ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;

SQL> SELECT * FROM V$BLOCK_CHANGE_TRACKING;

Another Procedure:

SQL> show parameter db_create_file_dest;

NAME TYPE VALUE


db_create_file_dest string

SQL> alter system set db_create_file_dest=’C:\oracle\product\10.2.0\flash_recovery_area\DBA20\Block Track’;

System altered.

SQL> show parameter db_create_file_dest;

NAME TYPE VALUE


db_create_file_dest string C:\oracle\product\10.2.0\flash_recovery_area\DBA20\Block TraCk

SQL> alter database enable block change tracking;

Database altered.

To determine whether change tracking is enabled:

SQL> COL STATUS FORMAT A8

SQL> COL FILENAME FORMAT A60

SQL> SELECT STATUS, FILENAME FROM V$BLOCK_CHANGE_TRACKING;

STATUS FILENAME


ENABLED C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\DBA20\BLOCK TRACK\BLOCK_CHANGE_LOG.LOG

Size of the Block Change Tracking File:

The size of the change tracking file depends on the size of the database and not the frequency of updates. Oracle states that the size of the block tracking file is 1/30,000 the size of all the database data blocks being tracked by Change Tracking. Oracle also states that the file is created in 10 MB increments. For databases up to one terabyte, the size of the change tracking file will be 10MB, 2 terabyte databases will require 20MB and so on.

==========================================================================================================

Catalog Database
SQL> create tablespace rman_cat datafile ‘C:\oracle\product\10.2.0\oradata\cat\rman_cat01.DBF’ SIZE 100M;

Tablespace created.

SQL> create user munna

       identified by munna

      default tablespace rman_cat

      temporary tablespace temp;

User created.

SQL> grant connect,resource,recovery_catalog_owner to munna;

Grant succeeded.

RMAN> connect catalog munna/[email protected]

connected to recovery catalog database

RMAN> create catalog tablespace rman_cat

recovery catalog created

C:>rman target sys/[email protected] catalog munna/[email protected]

Recovery Manager: Release 10.2.0.1.0 – Production on Mon Jul 12 16:08:21 2010

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: DBA20 (DBID=847839442)

connected to recovery catalog database

RMAN> run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup database;

}

RMAN> report schema;

RMAN> resync catalog;

starting full resync of recovery catalog

full resync complete

If any physical structure changes in target database then this command required for resynchronization.

RMAN> reset database;

database incarnation already registered

This command required only when incomplete recovery occurred in target database.

SQL> shutdown immediate;

Database closed.

Database dismounted.

Delete some Datafile

SQL> startup;

ORACLE instance started.

Total System Global Area 167772160 bytes

Fixed Size 1247876 bytes

Variable Size 75498876 bytes

Database Buffers 83886080 bytes

Redo Buffers 7139328 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 1 – see DBWR trace file

ORA-01110: data file 1: ‘C:\ORACLE\PRODUCT\10.2.0\ORADATA\DBA20\SYSTEM01.DBF’

C:>rman target sys/[email protected] catalog munna/[email protected]

RMAN> run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

restore database;

recover database;

}

SQL> alter database open;

Database altered.

=======================================================================================