restore:還原 recover恢複
先用restore database命令通過備份檔案還原到備份點,然後使用recover database命令通過歸檔記錄檔恢複到介質損壞時的時間點。
RMAN的體繫結構
RMAN串連上後有2個預設串連polling和default。還可以有rcvcat串連用於串連儲存備份資訊的recovery catalog DB,備份資訊還可放在目標資料庫的控制檔案裡,RMAN可分配任意多的channel(一個通道為一個串連)用於讀目標資料庫資料寫到磁碟或磁帶上。
control_file_record_keep_time 控制檔案重用需要的天數
rman串連本機資料庫
rman target / nocatalog
串連遠程目標資料庫
rman target sys/sys@XWX1 nocatalog;
寫RMAN輸出到一個記錄檔
rman target sys/sys log d:/rman.log append
rman啟動執行指令碼
rman target sys/sys log d:/rman.log append
@'d:/my_rman_script.rcv'
最簡單的指令碼(here document技術:Here Documents的用處是將後面的內容作為命令的輸入自動提供給前面的命令)
rman rman target / nocatalog <<!
show all;
exit;
!
RMAN>show all;查看配置資訊
自動channel分配:
1.設定channel的預設裝置類型
RMAN>configure default device type to sbt;指定為磁帶
RMAN>configure default device type clear;清除設定,還原到預設值
2.設定並發度
RMAN>configure device type disk parallelism 3;
3.設定備份目錄
RMAN>configure channel device type disk format='d:/backup/rman/%U';%U檔案名稱自動編號唯一
4.設定最大備份片大小
RMAN>configure channel device type disk maxpiecesize 2G;
5.configure backup potimazation on; ----設定備份最佳化;
6.configure retention policy to
recovery window of 7 days; ----設定保留備份策略視窗7天;
7.configure retention policy to
redundancy 4; ----設定冗餘度為4,儲存4個備份組;
8.configure datafile backup copies for
device type disk to 2; ----如果備份到磁碟,則同時作2個拷貝的備份;
9.同時備份控制檔案
configure controlfile autobackup on;
手動channel分配
RMAN>run {
allocate channel c1 type disk
format='d:/backup/rman/user20110627.bak';
backup datafile 'd:/Oracle/oradata/users01.dbf';
sql 'alter database archive log current';
}
串連的類型
與目標資料庫
與recovery catalog database
與auxiliary database:standby database、duplicate database、TSPITR instance。
串連一個機器的不同執行個體需要
UNIX:oracle_sid=orcl;export oracle_sid;
window:set oracle_sid=orcl
backup是RMAN備份特有,copy是普通cp命令拷貝的
list命名
1.列出資料庫所有檔案的備份
RMAN>list backup of database;
2.列出資料庫某檔案的備份
report schema; 資料檔案資訊,複製datafile目錄
RMAN>list backup of datafile "d:/oracle/oradata/users01.dbf";
列出資料表空間的所有copies或backup
RMAN>list copy of tablespace "SYSTEM";
RMAN>list backup of tablespace "SYSTEM";
REPORT命令
1.report need backup需要備份的資料檔案
report need backup incremental 3;需要3個或更多增量備份的檔案
report need backup days 3;3天內沒備份的檔案
report need backup redundancy 2;冗餘小於2的檔案