一: 備份; 1:連接目標數(shù)據(jù)庫: rman rman>connect target / ---當?shù)貦C器連接形式
進入歸檔模式切換: sqlplus /nolog sql>conn / as sysdba; sql>archive log list;---查看是否歸檔模式 進行歸檔模式的切換 sql>alter database archivelog; 再啟動即可,; 2:查詢目標數(shù)據(jù)庫的配置情況; RMAN> SHOW ALL; 修改成如下配置: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default 如果CONFIGURE CONTROLFILE AUTOBACKUP OFF; 執(zhí)行下面語句: RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON; 3:備份控制和數(shù)據(jù)文件 RMAN>backup database; 4:備份日志文件; rman>backup archivelog all delete input; 二: 恢復(fù): 1:先將數(shù)據(jù)庫工作在'已裝載'模式下; sql>shutdown immediate; sql>startup mount; sql>select status from v$instance;--open 2:rman>restore database; 3:rman>recover database; 數(shù)據(jù)庫恢復(fù)成功; sql>alter database open; OK; <二>:表空間的備份與恢復(fù);數(shù)據(jù)庫要工作在歸檔日志模式下; 1:表空間的備份; rman>backup (tablespace users include current controlfile); 2:備份歸檔日志; rman>backup (archivelog all delete input); 3:表空間恢復(fù); 3.1:表空間的脫機; rman> sql'alter tablespace users offline immediate'; 3.2:表空間所屬數(shù)據(jù)文件還原; rman>restore(tablespace users); 3.3:表空間恢復(fù)過程; rman>recover tablespace users; 3.4:表空間聯(lián)機的過程; rman>sql'alter tablespace users online'; <三>:數(shù)據(jù)文件的備份恢復(fù);數(shù)據(jù)庫要工作在歸檔日志模式下; 1:備份數(shù)據(jù)文件; rman>backup (datafile 'd:oracleoradatadbnameusers01.dbf'); 2:備份所有歸檔日志文件; rman>backup (archivelog all delete input); 3:數(shù)據(jù)文件的恢復(fù); 3.1:將數(shù)據(jù)文件所屬的表空間users脫機; rman>sql'alter tablespace users offline immediate'; 3.2:將數(shù)據(jù)文件還原的過程; rman>restore (datafile 'd:oracleoradatadbnameusers01.dbf') ; 3.3:數(shù)據(jù)文件的恢復(fù)過程; rman>recover datafile 'd:oracleoradatadbnameusers01.dbf'; 3.4數(shù)據(jù)文件所屬的表空間的聯(lián)機; rman>sql'alter tablespace users online'; OK; <四>數(shù)據(jù)整庫備份與恢復(fù)備份命令(示例) 只備份數(shù)據(jù)文件 (如果configure controlfile autobackup on; 將自動包括控件文件,SPFILE) 4.1備份 RMAN> backup database; 同時備份歸檔日志,然后將備份后的歸檔日志刪除 RMAN> backup database plus archivelog delete input; 明確指定同時備份控件文件: RMAN> run{ allocate channel ch1 type disk; sql 'alter system archive log current'; backup full database include current controlfile tag 'db_full_controlfile_%T' format '/user/oracle/rmanback/full_%u_%s_%p';---'d:\oracle\rman\full_%u_%s_%p'; sql 'alter system archive log current'; release channel ch1; } 4.2恢復(fù)(完全恢復(fù)) 目標數(shù)據(jù)庫必須是mount狀態(tài) rman target / RMAN> startup mount RMAN> restore database; RMAN> recover database; RMAN> alter database open; -----(recover database until cancel;)--sqlplus ----- alter database open resetlogs; |
|