RMAN备份/恢复

 

RMAN备份是指使用Recovery Manager备份数据文件控制文件归档日志SPFILE的方法。

 

         并且因为RMAN备份是由Target Database的服务器进程来完成,所以当使用RMAN执行备份操作时,Target Database必须处于MOUNTOPEN状态。

 

         当使用RMAN执行备份操作时,必须分配通道,并且RMAN备份是由通道所对应的服务器进程来完成的。

 

3.1Create Backup Set

 

DatabaseFullBackup Set

 

RMAN>backupdatabaseformat = ‘/home/oracle/rman/’;

 

Tablespace Backup Set

 

RMAN>backuptablespace[name] format= ‘/home/oracle/rman/%n_%s.bak’;

 

Datafile Backup Set

 

RMAN>backupdatafile[n] format= ‘/home/oracle/rman/’;

 

Controlfile Backup Set

 

RMAN>backupcurrent controlfileformat= ‘/home/oracle/rman/%d_%s.ctl’;

 

e.g. [include current controlfile];

 

SPFILE Backup Set

 

RMAN>backupspfileformat='/home/oracle/rman/%d_%s.ora';

 

Archivelog Backup Set

 

RMAN>backup format='/home/oracle/rman/%d_%s.arc'

 

2>archivelogfrom time='sysdate-1' until time='sysdate';

 

RMAN>run{

 

2>allocate channel c1 type disk;

 

3>sql 'alter system archive log current';

 

4>backup archivelog all

 

5>format='/home/oracle/rman/arch_%d_%s_%p_%t';

 

6>}

 

e.g. [plus archivelog];

 

RMAN> list backupset of archivelog all;

 

Parallelization Backup Set

 

 

 

 

 

Duplexed Backup Sets

 

RMAN>backup copies [n]tablespace[name]

 

                   2>format= ‘/u01/bak1/%N_%s.dbf’,’/u01/bak2/%N_%s.dbf’,

 

3>’/u01/bak3/%N_%s.dbf’;

 

 

 

RMAN> backup backupset [n] format = ‘/u01/bak1/%N_%s.dbf’;

 

 

 

         RMAN> configure channel device type [name]

 

                   2> maxpiecesize 4G;

 

         RMAN> backup device type [name] format ‘’

 

RMAN恢复

 

 

 

4.2 Password File的恢复

 

         [oracle@localhost ~]$orapwdfile=password=entries=[n];

 

4.3 Spfile的恢复

 

         [oracle@localhost ~]$rmantarget /

 

         RMAN>shutdown immediate;

 

         RMAN>startupnomount;

 

         RMAN>set dbid [n]--select dbid, name from v$database

 

         RMAN>restorespfile from autobackup;

 

         RMAN>shutdown immediate;

 

         -- RMAN> set dbid [n]

 

         RMAN>startup;

 

4.4 Control File的恢复

 

         --SQL> shutdown abort;

 

RMAN>startupnomount;

 

         RMAN>restorecontrolfile from autobackup;

 

--2>[’/flash_recovery_area/SGTMS/autobackup/o1_mf_s_788832460_80b3sy7t_.bkp’]

 

         RMAN>alter database mount;

 

         RMAN>recoverdatabase; --ControlfileSCNdatafile

 

         RMAN>alter database openresetlogs; --ControlfileSequenceRedo Logs

 

4.5 Redolog File的恢复

 

         SQL>shutdown immediate;

 

         SQL>startupmount;

 

         SQL>recoverdatabase until cancel;

 

         SQL>alter database openresetlogs;

 

4.6 Data File/Tablespace的恢复

 

         [oracle@localhost ~]$rman target /

 

         RMAN>report schema;

 

RMAN>sql‘alter database datafile [n] offline[immediate]’;

 

RMAN>restoredatafile [n];

 

RMAN>recoverdatafile [n];

 

RMAN>sql‘alter database datafile [n] online’;

 

tablespace [name] = datafile [n]

 

 

你可能感兴趣的:(rman)