--建表
create table sales
(
? product_id number(10),
? sales_date date,
? sales_cost number(10,2),
? status???? varchar2(20)
);
--插數(shù)據(jù)
insert into sales values (1,sysdate-90,18.23,'inactive');
commit;
--啟用rman做全庫(kù)備份
? 運(yùn)行D:\autobackup\rman\backup_orcl.bat
? 生成日志文件D:\autobackup\rman\logs\2011-04-29.log
? 從日志文件中看出:
????? Control File and SPFILE:D:\AUTOBACKUP\RMAN\C-1275904369-20110429-00
????? 數(shù)據(jù)文件:D:\AUTOBACKUP\RMAN\DATA_20110429_1DMB01T6_1_1
????? 日志文件:D:\AUTOBACKUP\RMAN\DATA_20110429_1CMB01T2_1_1 和 D:\AUTOBACKUP\RMAN\DATA_20110429_1EMB022O_1_1
??? 備份正查完成。
--再插數(shù)據(jù)???
insert into sales values (2,sysdate-60,18,'inactive');
commit;
--切換日志(手動(dòng)觸發(fā)檢查點(diǎn))
connect sys/orcl as sysdba;
alter system switch logfile;
--繼續(xù)插數(shù)據(jù)?
insert into sales values (3,sysdate-30,88.23,'inactive');
commit;
--全庫(kù)恢復(fù)
1.連接rman
rman target /
2.啟動(dòng)數(shù)據(jù)庫(kù)到加載狀態(tài)
rman> shutdown immediate;
rman> startup mount;
3.執(zhí)行修復(fù)、恢復(fù)操作
rman> restore database;
rman> recover database;
4.打開(kāi)數(shù)據(jù)庫(kù)(恢復(fù)完成退出rman)
rman> alter database open;
rman> exit;
5.校驗(yàn)
SQL> select * from sales;
PRODUCT_ID SALES_DATE?? SALES_COST STATUS
---------- ----------- ----------- --------------------
1????????? 2011-1-29 1????????? 18 inactive
2????????? 2011-2-28 1????????? 18 inactive
3????????? 2011-3-30 1????????? 88 inactive
三條數(shù)據(jù)齊全,說(shuō)明數(shù)據(jù)庫(kù)在恢復(fù)時(shí)啟用日志文件對(duì)數(shù)據(jù)進(jìn)行了恢復(fù)。
增量備份已現(xiàn)多余,檢查點(diǎn)也無(wú)需用戶(hù)手動(dòng)觸發(fā),
oracle在備份前會(huì)歸檔一次日志文件,在備份后也會(huì)歸檔一次日志文件,這也是為什么備份時(shí)生成兩個(gè)日志文件的原因。
6.恢復(fù)完成后馬上做一次全庫(kù)備份
? 運(yùn)行D:\autobackup\rman\backup_orcl.bat
7.本測(cè)試的不足
? 本測(cè)試并未模擬災(zāi)難環(huán)境,如突然斷電導(dǎo)致的數(shù)據(jù)庫(kù)崩潰,
? 此時(shí),最后一次檢查點(diǎn)至崩潰時(shí)刻間的數(shù)據(jù)沒(méi)有歸檔,將會(huì)丟失。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元

