五個級別:0(完全),1,2,3,4,5.級別越大,備份的數(shù)據(jù)塊相對越小
1.增量備份
?? 例如:周日---0(完全)
????????? 周一---2(周一變化的所有數(shù)據(jù)塊)
????????? 周二---2(周二變化的所有數(shù)據(jù)塊)
????????? 周三---1(周一到周三間變化的所有數(shù)據(jù)塊)
????????? 周四---2(周四變化的所有數(shù)據(jù)塊)
????????? 周五---2(周五變化的所有數(shù)據(jù)塊)
?????????? 周六---2(周六變化的所有數(shù)據(jù)塊)
??? backup incremental level 0 format='d:\backup\%d_%s.dbf' tablespace users;
??? backup incremental level 2 format='d:\backup\%d_%s.dbf' tablespace users;
??? backup incremental level 1 format='d:\backup\%d_%s.dbf' tablespace users;
2.累積備份
?? 例如:周日---0(完全)
????????? 周一---2(周一變化的所有數(shù)據(jù)塊)
????????? 周二---2(周日到周二變化的所有數(shù)據(jù)塊)
????????? 周三---1(周日到周三間變化的所有數(shù)據(jù)塊)
????????? 周四---2(周三到周四變化的所有數(shù)據(jù)塊)
????????? 周五---2(周三到周五變化的所有數(shù)據(jù)塊)
?????????? 周六---2(周三到周六變化的所有數(shù)據(jù)塊)
???? backup incremental level 0 format='d:\backup\%d_%s.dbf' tablespace users;
??? backup incremental level 2 format='d:\backup\%d_%s.dbf' tablespace users;
??? backup incremental level 2 cumulative format='d:\backup\%d_%s.dbf' tablespace users;
???? backup incremental level 1 format='d:\backup\%d_%s.dbf' tablespace users;
-----------------------------------------------------------------------------
準(zhǔn)備工作:
創(chuàng)建恢復(fù)目錄
1、在目錄數(shù)據(jù)庫中創(chuàng)建恢復(fù)目錄所用表空間
SQL> create tablespace rmants datafile 'c:\oracle\oradata\cc\rmants.ora' size 20M ;
表空間已創(chuàng)建。
2、在目錄數(shù)據(jù)庫中創(chuàng)建RMAN 用戶并授權(quán)
SQL> create user rman identified by rman default tablespace rmants temporary tablespace temp quota
unlimited on rmants;
用戶已創(chuàng)建
SQL> grant recovery_catalog_owner to rman ;
授權(quán)成功。
3、在目錄數(shù)據(jù)庫中創(chuàng)建恢復(fù)目錄
C:\>rman catalog rman/rman
恢復(fù)管理器:版本8.1.7.0.0 - Production
RMAN-06008:連接到恢復(fù)目錄數(shù)據(jù)庫
RMAN-06428:未安裝恢復(fù)目錄
RMAN>create catalog tablespace rmants;
RMAN-06431:恢復(fù)目錄已創(chuàng)建
4、注冊目標(biāo)數(shù)據(jù)庫到恢復(fù)目錄
注意哦,這里我的目標(biāo)數(shù)據(jù)庫使用的服務(wù)名稱是rman,意思為要使用RMAN 進(jìn)行備份的數(shù)據(jù)庫,而目錄
數(shù)據(jù)庫使用的服務(wù)名稱是CC。
C:\>rman target sys/sys@rman
恢復(fù)管理器:版本8.1.7.0.0 - Production
RMAN-06005:連接到目標(biāo)數(shù)據(jù)庫:RMAN (DBID=1303772234)
RMAN>connect catalog rman/rman@cc
RMAN-06008:連接到恢復(fù)目錄數(shù)據(jù)庫
RMAN>register database;
RMAN-03022:正在編譯命令:register
RMAN-03023:正在執(zhí)行命令:register
RMAN-08006:注冊在恢復(fù)目錄中的數(shù)據(jù)庫
RMAN-03023:正在執(zhí)行命令:full resync
RMAN-08002:正在啟動全部恢復(fù)目錄的resync
RMAN-08004:完成全部resync
好了,到此為止前面的準(zhǔn)備工作都做好了,下面就可以使用RMAN 來進(jìn)行備份和恢復(fù)了。
每半年做一個數(shù)據(jù)庫的全備份(包含只讀表空間)
每個月做一次零級備份(不包含只讀表空間)
每個星期做一次一級備份
每天做一個二級備份
數(shù)據(jù)庫全備份腳本:
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup full tag 'dbfull' format '/backup/ncfc/full%d_%p_%t' database ;
sql 'alter system archive log current' ;
backup format /backup/ncfc/dbL0/dbL0%d_%p_%t.arc' filesperset 5 archivelog all delete input;
release channel c1;
release channel c2;
release channel c3;
}
零級備份腳本(只讀表空間除外)
run {
allocate channel c1 type disk maxpiecesize =;
allocate channel c2 type disk maxpiecesize =;
allocate channel c3 type disk maxpiecesize =;
backup incremental level 0 filesperset 10 tag 'dbL0' format '/backup/ncfc/dbL0/dbL0%u_%p_%c ' database skip readonly;
sql 'alter system archive log current' ;
backup format '/backup/ncfc/dbL0/arch%u_%p_%c.arc' filesperset 5 archivelog from time "sysdate-1" all;
release channel c1;
release channel c2;
release channel c3;
}
一級備份腳本
run {
allocate channel c1 type disk maxpiecesize =;
allocate channel c2 type disk maxpiecesize =;
allocate channel c3 type disk maxpiecesize =;
backup incremental level 1 filesperset 5 tag 'dbL1' format '/backup/ncfc/dbL1/dbL1%d_%p_%t ' ddatabase skip readonly;
sql 'alter system archive log current' ;
backup format '/backup/ncfc/dbL1/dbL1%d_%p_%t.arc' filesperset 5 archivelog from time "sysdate-1" all;
release channel c1;
release channel c2;
release channel c3;
}
二級備份腳本
run {
allocate channel c1 type disk maxpiecesize =;
allocate channel c2 type disk maxpiecesize =;
allocate channel c3 type disk maxpiecesize =;
backup incremental level 2 filesperset 5 tag 'dbL2' format '/backup/ncfc/dbL2/dbL2%u_%p_%c' ddatabase skip readonly;
sql 'alter system archive log current' ;
backup format '/backup/ncfc/dbL2/dbL2%d_%p_%t.arc' filesperset 5 archivelog from time "sysdate-1" all;
release channel c1;
release channel c2;
release channel c3;
}
歸檔文件備份腳本
run {
??? allocate channel dev1 type disk maxpiecesize =;
??? allocate channel dev2 type disk maxpiecesize =;
??? allocate channel dev3 type disk maxpiecesize =;
??? sql 'alter system archive log current' ;
??? backup format '/backup/ncfc/arc/arch%u_%p_%c ' archivelog from time "sysdate-1" all;
??? release channel dev1;
??? release channel dev2;
??? release channel dev3;
}
表空間備份腳本(以users表空間為例)
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup tag 'tabsp' format '/backup/ncfc/tabsp/tabsp%u_%p_%c' tablespace users;
sql 'alter system archive log current' ;
backup format 'e:\oradata\%d_%p_%t.arc' filesperset 5 archivelog all delete input;
release channel c1;
release channel c2;
release channel c3;
}
則每天所需要備份的數(shù)據(jù)量只有一天的改變量。而做恢復(fù)時最多只要恢復(fù)當(dāng)月的一個零級備份+三個一級備份+6個二級備份+當(dāng)天的歸檔文件。如果不能接受這樣的恢復(fù)時間,就只能夠減少零級備份之間的時間間隔(如可以每個星期做一個零級備份,這樣恢復(fù)時最多只需要恢復(fù)一個星期的數(shù)據(jù)量)。
備份CATALOG數(shù)據(jù)庫(數(shù)據(jù)庫邏輯輸出)
exp pafile=exp.dat
其中exp.dat如下
userid=rman/rman
file=rmanexp.dmp
------------------------------------------
用filesperset控制備份集的尺寸
當(dāng)指定filesperset參數(shù)時,rman比較filesperset與自動計算出來的值(對每個已分配通道的文件數(shù)目)并取其中較小的那個值來保證所有的通道被使用。
如果指定或者通過組合backupSpec語句暗示的文件數(shù)目比filesperset要大,那么rman創(chuàng)建多個備份集來維護(hù)正確的速率(ratio);
如果沒有指定filesperset,rman比較計算出來的值(文件數(shù)目除以已分配的通道)和默認(rèn)值64,并取其中較小的那個值來保證所有通道可用。
Rman通常嘗試創(chuàng)建足夠的備份集以使所有已分配的通道有事可做。一個例外是通道比要備份的文件還要多
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
