Monday, 23 May 2011

RMAN referance



RMAN
BackUp
$export ORACLE_SID = Test
$rman target /
Rman >backup database;
Rman >backup tablespace data,users;
Rman >backup datafile 10,12;
Rman>backup current control file;
Rman>backup archivelog all;
Rman>backup archivelog all delete input;
Rman>backup spfile;
Rman>backup archivelog until ‘sysdate – 1’ delete input;
Rman>backup archivelog skip inaccessible;

RECOVERY

\
Rman>sql ’alter database datafile 10 offline drop;
Rman>restore datafile 10 ;
Rman>recover datafile 10;
Rman>sql ‘ alter database datafile 10 online’;
/


\

Rman>run {
sql ’alter database datafile 10 offline drop;
restore datafile 10 ;
recover datafile 10;
sql ‘ alter database datafile 10 online’;
}
/
Recover tablespace
\
Rman >run  {
Sql ‘alter tablespace data offline’;
Restore tablespace data;
Recover tablespace data;
Sql ‘alter tablespace data online’;
}
/
Read only Tablespace corrupted (recover)
\
Rman>run {
Sql ‘alter tablespace data offline’;
Restore tablespace data;
Sql ‘alter tablespace data online’;
}
/

System/Undo/ Tablespace corrupted (recover)
\
Startup mount
Rman> run {
Restore tablespace system;
Recover database;
Open database;
}
/
Database corrupted (recover)
\
Startup mount
Rman> run {
Restore database;
Recover database;
Open database;
}
/

Catalog Database
/
$ export ORACLE_SID = apps
sql>create tablespace rmanths datafile ‘/opt /oracle/rman 01.dbf’ size 100m;
sql>create user rman identified by rman default tablespace rmanths temporary tablespace temp;
sql> grant connect ,resource to rman;
sql>grant recovery_catalog_owner to rman;
 $ export ORACLE_SID = test
$ rman target / catalog  rman/rman@apps123
Rman>create catalog ;
Rman>register database;
Rman>backup database plus archivelog include current control file;
Rman>resync database; or rman>resync catalog;

Control file recovery
$ export ORACLE_SID = test
Rman>restore controlfile from ‘/opt/oracle/aXX ‘ ;
Rman>alter database mount ;
Rman>recover database ;
Rman>open database;
Control file recovery  (Catalog database )
Startup no mount
$ export ORACLE_SID = test
$ rman target / catalog rman/rman@apps123
Rman> restore controlfile;
Rman> alter database mount;
Rman> recover database;
Rman> open database;

Incremental Backup
Rman> backup database; (level 0 backup)
Rman> backup incremental level 1 database;
Rman> backup incremental level 1 cumulative database;
RMAN Script
Rman> create script level1db
{
Backup incremental level 1 database;
Backup archivelog all delete input;
Backup current control file;
Backup spfile;
}
Rman> run { execute script level1db;}
Rman> print level1db;( display script content)
Rman> delete level1db;
SCN based (recover) database:

Rman > run {
Set until SCN ‘137’;
Retore database;
Recover database;
Open resetlogs database;
}
TIME based (recover) database:

Rman > run {
Set until TIME =  ‘DD-MM-YY HH24:MI:SS’;
Retore database;
Recover database;
Open resetlogs database;
}

Log sequence based (recover) database:

Rman > run {
Set until log seq 1313 thread 1;
Retore database;
Recover database;
Open resetlogs database;
}
Restore in different location
Rman > run {
set until logseq 1313 thread 1;
set newname for datafile 1 to ‘ /U01/oracle/system01.dbf’;
set newname for datafile 2 to ‘ /U01/oracle/undo.dbf’;
set newname for datafile 3 to ‘ /U01/oracle/sysaux.dbf’;
set newname for datafile 4 to ‘ /U01/oracle/users.dbf’;
retore database;
switch datafile all;
recover database;
open resetlogs database;
}
Backup Options
Rman>backup database format ‘ /backup/rman_%d_%s_%p_%u’;
Maxset size:
Rman>backup database maxsetsize = 100m;
MAXpicesize
Rman>backup database maxpicesize = 100m;
Fileperset
Rman>backup database fileperset = 3;
Rate:
Rman>backup database rate 1m; ( 1mb data will be retrieved from 1 second)
Backup set identification:
Rman> backup database tag =’full_backup_412’;
Rman>restore database from tag ’full_backup_412’;
RMAN configuration:
Rman> Show all;
Rman> configuration retention policy to redundancy 3;
Rman> configuration retention policy to recovery window of 10 days;
Rman> report obsolete;(check whether retention (of 3 backup or 10 days backup ))
Rman> delete obsolete ;
Rman > report need backup;
Rman> configure default device type to disk;
Rman> configure default device type to ‘sbt’;
Rman> allocate channel for maintenance type disk (or) ‘sbt’;
Rman>configure channel device type disk format '/oracle/rman_bk/rmanbk_bk_%d_%u_%s_%p';
\
Rman>configure device type disk parallelism 5; (allocating channels)
 Example:
Rman> run {
Allocate channel c1 type disk format ‘/opt/rman_%u;
Allocate channel c2 type disk format ‘/u2/rman_%u;
Allocate channel c3 type disk format ‘/u3/rman_%u;
Backup database;
Release channel c1;
Release channel c2;
Release channel c3;
}
/
Rman>configure controlfile autobackup on;
Rman>configure controlfile autobackup format for device type disk to ‘/backup/control_%f’;
Rman>configure device type disk backup type to backupset;
Rman>configure device type backup type to copy;(image copy backup)
Rman>configure device type backup type to compressed backupset;
Rman>comfigure backup optimization on; (only once take archive log)
Rman>configure for exclude tablespace users; (not take backup for users)
Rman> select * from v$ tablespace;
Output;  name = users , Inc (include) = no
Rman> backup database noexclude;
Rman>configure for exclude tablespace users clear;
Rman>backup database skip offline skip read only;
Rman>backup archivelog all skip inaccessible;
Rman>validate backup database;(Wont take backup only verify it)
Rman>validate restore database;
Rman>list backup of database;
Rman>crosscheck backup;(check corrupted or proper)
Rman> crosscheck backup of database;
Rman>delete expired backup;
Block change tracking
Sql>alter database enable block change tracking using file ‘/opt/bcff.chg’;
Block recover
Rman>block recover datafile 10 block 121;
Rman>run{
Set maxcorrupt =3;
Backup database;
}
check only catalog users
\
Sql>conn rman/rman;
Sql>select * from rc_backup_datafile;
Sql>select * from rc_backup_redolog;
Sql>select * from rc_backup_spfile;
Sql>select * from rc_controlfile_copy;
Sql>select * from rc_backup_block_corruption;
Sql>select * from rc_resync;
Sql>select * from re_rman_configuration;
Sql> select * from rc_stored_script;
Sql>select * from rc_stored_script_line;

No comments:

Post a Comment