![oracle備份與恢復(fù)策略介紹_第1頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/3/adcf68e4-6cf5-4daa-8e94-0f0a6e38e893/adcf68e4-6cf5-4daa-8e94-0f0a6e38e8931.gif)
![oracle備份與恢復(fù)策略介紹_第2頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/3/adcf68e4-6cf5-4daa-8e94-0f0a6e38e893/adcf68e4-6cf5-4daa-8e94-0f0a6e38e8932.gif)
![oracle備份與恢復(fù)策略介紹_第3頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/3/adcf68e4-6cf5-4daa-8e94-0f0a6e38e893/adcf68e4-6cf5-4daa-8e94-0f0a6e38e8933.gif)
![oracle備份與恢復(fù)策略介紹_第4頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/3/adcf68e4-6cf5-4daa-8e94-0f0a6e38e893/adcf68e4-6cf5-4daa-8e94-0f0a6e38e8934.gif)
![oracle備份與恢復(fù)策略介紹_第5頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/3/adcf68e4-6cf5-4daa-8e94-0f0a6e38e893/adcf68e4-6cf5-4daa-8e94-0f0a6e38e8935.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、oracle備份與恢復(fù)案例by jack一.理解什么是數(shù)據(jù)庫恢復(fù)當(dāng)我們使用一個(gè)數(shù)據(jù)庫時(shí),總希望數(shù)據(jù)庫的內(nèi)容是可靠的、正確的,但由于計(jì)算機(jī)系統(tǒng)的故 障(碩件故障、軟件故障、網(wǎng)絡(luò)故障、進(jìn)程故障和系統(tǒng)故障)影響數(shù)據(jù)庫系統(tǒng)的操作,影響數(shù)據(jù) 庫中數(shù)據(jù)的正確件,甚至破壞數(shù)據(jù)庫,使數(shù)據(jù)庫中全部或部分?jǐn)?shù)據(jù)丟失。因此當(dāng)發(fā)生上述故障后, 希望能重構(gòu)這個(gè)完整的數(shù)據(jù)庫,該處理稱為數(shù)據(jù)庫恢復(fù)?;謴?fù)過程大致町以分為復(fù)原(restore) 與恢復(fù)(recover)過程。數(shù)據(jù)庫恢復(fù)可以分為以下兩類:實(shí)例故障的一致性恢復(fù)當(dāng)實(shí)例意外地(如掉電、后臺(tái)進(jìn)程故障等)或預(yù)料地(發(fā)出shutdoum abort語句)中止 時(shí)出現(xiàn)實(shí)例故障,
2、此吋需耍實(shí)例恢復(fù)。實(shí)例恢復(fù)將數(shù)據(jù)庫恢復(fù)到故障之而的事務(wù)一致狀態(tài)。如果 在在線后備發(fā)現(xiàn)實(shí)例故障,則需介質(zhì)恢復(fù)。在其它情況oracle在下次數(shù)據(jù)庫起動(dòng)時(shí)(對(duì)新實(shí) 例裝配和打開),口動(dòng)地執(zhí)行實(shí)例恢復(fù)。如果需耍,從裝配狀態(tài)變?yōu)榇蜷_狀態(tài),口動(dòng)地激發(fā)實(shí)例 恢復(fù),由下列處理:(1)為了解恢復(fù)數(shù)據(jù)文件中沒有記錄的數(shù)據(jù),進(jìn)行向前滾。該數(shù)據(jù)記錄在在線日志, 包括對(duì)回滾段的內(nèi)容恢復(fù)。(2)冋滾未提交的事務(wù),按步1重新生成冋滾段所指定的操作。(3)稗放在故障時(shí)正在處理事務(wù)所持有的資源。(4)解決在故障時(shí)正經(jīng)歷一階段提交的任何懸而未決的分布事務(wù)。1.2介質(zhì)故障或文件錯(cuò)誤的不一致恢復(fù)介質(zhì)故障是當(dāng)一個(gè)文件、一個(gè)文件的部分或
3、磁盤不能讀或不能寫吋出現(xiàn)的故障。文件錯(cuò)誤一 般指意外的錯(cuò)謀導(dǎo)致文件被刪除或意外出故導(dǎo)致文件的不一致。這種狀態(tài)下的數(shù)據(jù)庫都是不一致 的,需要dba手工來進(jìn)行數(shù)據(jù)庫的恢復(fù),這種恢復(fù)有兩種形式,決定于數(shù)據(jù)庫運(yùn)行的歸檔方式 和備份方式。(1)完全介質(zhì)恢復(fù)可恢復(fù)全部丟失的修改。一般情況下需要冇數(shù)據(jù)庫的備份且數(shù)據(jù)庫運(yùn)行在 歸檔狀態(tài)下并且有可用歸檔口志時(shí)才可能。對(duì)于不同類型的錯(cuò)謀,有不同類型的完全恢復(fù) 可使用,其決定于毀壞文件和數(shù)據(jù)庫的可用性。(2)不完全介質(zhì)恢復(fù)是在完全介質(zhì)恢復(fù)不可能或不要求時(shí)進(jìn)行的介質(zhì)恢復(fù)。重構(gòu)受損的數(shù)據(jù) 庫,使其恢復(fù)介質(zhì)故障前或用戶出錯(cuò)z前的一個(gè)事務(wù)一致性狀態(tài)。不完全介質(zhì)恢復(fù)有不同 類
4、型的使川,決定于需耍不完全介質(zhì)恢復(fù)的情況,有下列類型:基于撤消、基于時(shí)間和基 于修改的不完全恢復(fù)?;诔废╟ancel)恢復(fù):在某種情況,不完全介質(zhì)恢復(fù)必須被控制,dba可撤消在指定點(diǎn) 的操作。基于撤消的恢復(fù)地在一個(gè)或多個(gè)門志組(在線的或歸檔的)己被介質(zhì)故障所破壞,不能 用于恢復(fù)過程時(shí)使用,所以介質(zhì)恢復(fù)必須控制,以致在使用最近的、耒損的口志組于數(shù)據(jù)文件片 中止恢復(fù)操作。基于時(shí)間(time)和基于修改(scn)的恢復(fù):如果dba希望恢復(fù)到過去的某個(gè)指定點(diǎn),是一 種理想的不完全介質(zhì)恢復(fù),一般發(fā)生在恢復(fù)到某個(gè)特定操作z前,恢復(fù)到如意外刪除某個(gè)數(shù)據(jù)表第二章.數(shù)據(jù)庫恢復(fù)案例測(cè)試環(huán)境2.1數(shù)據(jù)庫環(huán)境以下
5、的所冇案例都是通過測(cè)試經(jīng)過,環(huán)境為:os: windows 2000 serverdb: oracle 816dbname: test數(shù)據(jù)文件:file#statusenabled1systemreadwrite2onlinereadwrite3onlinereadwrite4onlinereadwrite5onlinereadwrite6onlinereadwritenamesql> select file#,status,enabled,name from v$datafile;d:oracleoradatatestsystem01.dbf d:oracleoradatatestrb
6、s01.dbf d:oracleoradatatestusers01.dbfd:oracleoradatatesttemp01.dbf d:oracleoradatatesttools01.dbf d:oracleoradatatestindx01.dbf控制文件:sql> select * from v$controlfile;status named:oracleoradatatestcontrol01ectld:oracleoradatatestcontrol02.ctld:oracleoradatatestcontrol03.ctl聯(lián)機(jī)日志:sql> select * fr
7、om v$logfile;group# status member1 staled:oracleoradatatestredo01>log2 d:oracleoradatatestredo02.log3 staled:oracleoradatatestredo03.log2.2數(shù)據(jù)庫備份腳本冷備份腳木:remscript:coldbaksqlremcreater:chen j ipingremdmte:5.8.2003remdesc:offline full backup databaseconnect databaseconnect internal/password;shutdown
8、 databaseshutdown immediate;copy data file!xcopy d:oracleoradatates.dbf d:database/h/r;-copy control file!xcopy d:oracleoradatatest*-ct1 d:database/h/r; -copy log file!xcopy d:oracleoradatatest*.log d:database/h/r;startup database startup;說明:1、以上腳本在數(shù)據(jù)庫關(guān)閉狀態(tài)下備份數(shù)據(jù)庫所有的數(shù)據(jù)文件,聯(lián)機(jī)口志,控制文件(在一個(gè)日 錄下),如果成功備份,所冇文件
9、是一致的;2、沒冇備份參數(shù)文件,參數(shù)文件可以另外備份,沒冇必要每次都備份,只需要在改變?cè)O(shè)置后備 份一次;3、如果以上命令沒冇成功依次執(zhí)行,那么備份將是無效的,如連接數(shù)據(jù)庫不成功,那么肯定關(guān) 閉數(shù)據(jù)庫也不成功,那么備份則無效;4、冷備份建議下人工干預(yù)下執(zhí)行。數(shù)據(jù)庫os熱全備份卿本remscript:hotbaksqlremcreater:chenjipingremdate:582003rem desc:backup all database datafile in archiveconnect databaseconnect internal/password;-archivealter sys
10、tem archive log current;-startalter tablespace system begin backup;!xcopy d:oracleoradatatestsystem01dbf d:databak/h/r;alter tablespace system end backup;alter tablespace rbs begin backup;!xcopy d:oracleoradatatestrbs01.dbf d:databak/h/r;alter tablespace rbs end backup;alter tablespace users begin b
11、ackup;!xcopy d:oracleoradatatestusers01dbf d:databak/h/r;alter tablespace users end backup;alter tablespace tools begin backup;!xcopy d:oracleoradatatesttools01dbf d:databak/h/r;alter tablespace tools end backup;alter tablespace indx begin backup;!xcopy d:oracleoradatatestindx01.dbf d:databak/h/r;al
12、ter tablespace indx end backup;-end-bak control file-binaryalter database backup controlfile to 1d:databakcontrolbinbak.0001; -asciialter database backup controlfile to trace;alter system archive log current;說明:1、熱備份必須在數(shù)據(jù)庫歸檔方式下才可以運(yùn)行;2、以上腳本可以在數(shù)據(jù)庫運(yùn)行狀態(tài)下備份數(shù)據(jù)庫所有的數(shù)據(jù)文件(除了臨時(shí)數(shù)據(jù)文件),沒有 必要備份聯(lián)機(jī)口志;3、歸檔日志至少需要一次完整備
13、份之后的所有日志;4、如果以上命令沒有成功依次執(zhí)行,那么備份也是無效的,如連接數(shù)據(jù)庫不成功,那么備份則 無效。rman備份只講敘有恢復(fù)目錄的情況,如果沒有恢復(fù)目錄,情形人致相似。以下是rman的熱備 份全備份的腳本:# script:bakup.rev# creater:chenjiping# date:582003# desc:backup all database datafile in archive with rman# connect databaseconnect reveat rman/rman0back;connect target internal/virpure;# sta
14、rt backup databaserun allocate channel cl type disk;backup full tag 1dbfull1 format 1d:backupfull%u_%s_%p1 database include current controlfile;sql f alter system archive log current1;release channel cl;# end說明:1、數(shù)據(jù)庫必須運(yùn)行在歸檔模式下;2、rman將臼動(dòng)備份數(shù)據(jù)文件,運(yùn)行可靠;3、歸檔口志另外備份處理,但至少需要保存一次備份來的口志;4、沒有必耍用rman做冷備份,效果不好。以上
15、舉例說明了數(shù)據(jù)庫的恢復(fù)案例的測(cè)試環(huán)境與部分備份測(cè)試腳本,英它的備份腳本可以根 據(jù)以上腳本演變而來或在案例中加以說明。數(shù)據(jù)庫的白動(dòng)實(shí)例將不加以說明,這里只舉例說明媒體錯(cuò)誤或人為錯(cuò)誤造成的恢復(fù)町能。 以上包括以下案例都是在wind0ws+0racle816±測(cè)試驗(yàn)證的,在不同的操作系統(tǒng)與不同的數(shù) 據(jù)庫版木中略有差別。第三章.了解與恢復(fù)相關(guān)的信息1>理解報(bào)警日志文件報(bào)警日志文件一般記載了數(shù)據(jù)庫的啟動(dòng)/關(guān)閉信息,歸檔信息,備份信息,恢復(fù)信息,常見 錯(cuò)誤信息,部分?jǐn)?shù)據(jù)庫修改記錄等。一*般令名規(guī)則為<sid>alrt. log或alrt<sid> . log, 如我
16、的測(cè)試數(shù)據(jù)庫的報(bào)警口志文件的名稱為testalrt.logo報(bào)警日志文件的路徑是根據(jù)初始化參數(shù)background_dump_dest來決定的,如在我的機(jī) 器上,該參數(shù)值為d : oracleadmintestbdump,那么,你就可以在該路徑下找到該文 件。2、后臺(tái)進(jìn)程跟蹤文件后臺(tái)進(jìn)程跟蹤文件的路徑與報(bào)警h志文件的路徑一致,在某些情況下,你可以通過后臺(tái)跟蹤 文件的信息了解更多的需要恢復(fù)的信息。如在數(shù)據(jù)庫需要恢復(fù)的時(shí)候,報(bào)警門志文件中常有這樣 的語句:errors in file d:oracleadmintestbdumptestdbwo.trc:ora-01157: cannot iden
17、tify/lock date file 1 - see dbwr trace file通過提示的dbwr跟蹤文件,可以查詢到更詳細(xì)的信息。3、v$recover_f ile 與 v$recovery_log這是兩個(gè)動(dòng)態(tài)性能視圖,可以在mount下查看,通過這兩個(gè)視圖,你可以了解詳細(xì)的需要 恢復(fù)的數(shù)據(jù)文件與需要使用到的歸檔li志。第四章.數(shù)據(jù)庫恢復(fù)案例4.1非歸檔模式下的備份與恢復(fù)備份方案:采用os冷備份1. 連接數(shù)據(jù)庫并創(chuàng)建測(cè)試表sql> connect internal/password as sysdba;connectedsql> create table test (a i
18、nt);table createdsql> insert into test values (1);1 row insertedsql> commit;commit complete2. 備份數(shù)據(jù)庫sql 0coldbak . sql 或在 dos 下 svrmgrl coldbak . sql3. 再插入記錄sql> insert into test values(2);1 row insertedsql> commit;commit completesql select * from test;a 124. 關(guān)閉數(shù)據(jù)庫sql> shutdown immedia
19、te;database closed.database dismountedoracle instance shut down.5. 毀壞一個(gè)或多個(gè)數(shù)據(jù)文件,如刪除userol.dbfc:>del d:oracleoradatatestusers01.dbf 模擬媒體毀壞。6. 重新啟動(dòng)數(shù)據(jù)庫,會(huì)發(fā)現(xiàn)如下錯(cuò)誤sql> startuporacle instance started.total system globalfixed sizevariable sizedetabase buffersredo buffersdatabase mountedarea 102020364 by
20、tes 70924 bytes 85487616 bytes 16384000 bytes 77824 bytesora-01157: cannot identify/lock data file 3 - see dbwr trace fileora-01110: data file 3: d:oracleoradatatestusers01dbf'在報(bào)警文件中,會(huì)有更詳細(xì)的信息errors in file d:oracleadmintestbdumptestdbwotrc:ora-01157: cannot identify/lock data file 3 - see dbwr t
21、race fileora-01110: data file 3: 'd:oracleoradatatestusers01.dbf'ora-27041: unable to open fileosd-04002: unable to open fileo/s-error: (os 2)系統(tǒng)找不到指定的文件。7. 拷貝備份復(fù)原到原來位置(restore過程)c:>xcopy d:database*.* d:oracleoradatatest/h/r/s8. 打開數(shù)據(jù)庫,檢查數(shù)據(jù)sql> alter database open;database altered.sql&g
22、t; select * from test;a 1這里可以發(fā)現(xiàn),數(shù)據(jù)庫恢復(fù)成功,但在備份z后與崩潰z前的數(shù)據(jù)丟失了。說明:1、非歸檔模式下的恢復(fù)方案可選性很小,一般情況下只能冇一種恢復(fù)方式,就是數(shù)據(jù)庫的冷備 份的完全恢復(fù),僅僅需要拷貝原來的備份就町以(restore),不需要recover;2、這種情況下的恢復(fù),可以完全恢復(fù)到備份的點(diǎn)上,但是可能是丟失數(shù)據(jù)的,在備份z后與崩 潰z前的數(shù)據(jù)將全部丟失;3、不管毀壞了多少數(shù)據(jù)文件或是聯(lián)機(jī)口志或是控制文件,都町以通過這個(gè)辦法恢復(fù),因?yàn)檫@個(gè) 恢復(fù)過程是restore所有的冷備份文件,而這個(gè)備份點(diǎn)上的所有文件是一致的,與最新的 數(shù)據(jù)庫沒有關(guān)系,就好比把數(shù)
23、據(jù)庫乂放到了一個(gè)以前的“點(diǎn)”上;4、對(duì)于非歸檔模式下,最好的辦法就是采用os的冷備份,建議不-要用rman來作冷備份,效 果不好,因?yàn)閞man不備份聯(lián)機(jī)日志,restore不能根本解決問題;5、如果沒有備份聯(lián)機(jī)日志,如rman的備份,就需要利川不完全恢復(fù)(until cancel)的方法 來重新創(chuàng)建聯(lián)機(jī)口志文件。4.2歸檔模式下丟失或損壞一個(gè)數(shù)據(jù)文件 4.2.1 os備份方案在歸檔方式下?lián)p壞或丟失一個(gè)數(shù)據(jù)文件,如果存在相應(yīng)的備份與該備份以來的歸檔i志 恢復(fù)還是比較簡(jiǎn)單的,可以作到盡量少的down機(jī)時(shí)間,并能作到數(shù)據(jù)庫的完全恢復(fù)。1、連接數(shù)據(jù)庫,創(chuàng)建測(cè)試表并插入記錄sql connect int
24、etnm丄/pmsswotd as sysdba; connectedsql> create table test (a int) tablespace users; table createdsql> insert into test values(1);1 row insertedsql> commit;commit complete2、備份數(shù)據(jù)庫sql> hotbak . sql 或在 dos 下 svrmgrl hotbak sql3、繼續(xù)在測(cè)試表中插入記錄sql> insert into test values(2);1 row insertedsql&
25、gt; commit;commit completesql> select * from test;a 12sql> alter system switch logfile;system altered.sql> alter system switch logfile;system altered.4、關(guān)閉數(shù)據(jù)庫,模擬丟失數(shù)據(jù)文件sql> shutdown immediate;database closed.database dismountedoracle instance shut downc:>del d:oracleoradatatestusers01.d
26、bf 模擬媒體毀壞。5、啟動(dòng)數(shù)據(jù)庫錯(cuò)渓,脫機(jī)該數(shù)據(jù)文件:sql> startuporacle instance started.total system globalfixed sizevariable sizedatabase buffersredo buffersdatabase rr.ountedarea 102020364 bytes 70924 bytes 85487616 bytes 16384000 bytes 77824 bytesora-01157: cannot identify/lock data file 3 - see dbwr trace fileora-01
27、110: data file 3: 'd:oracleoradatatestusers01.dbf'還町以查看報(bào)警文件(見上一個(gè)恢復(fù)案例)或動(dòng)態(tài)視圖v$recover_f ile 如 sql> select * from v$recover_file;file# online errorchange#time3 online10135002003-05-07脫機(jī)數(shù)據(jù)文件sql> alter database datafile 3 offline drop;database altered.6、打開數(shù)據(jù)庫,拷貝備份冋(restore),恢復(fù)(recover)該數(shù)據(jù)文件
28、,并聯(lián)機(jī):sql> alter database open;database altered拷貝備份從備份處copy d:databak usersol.dbf d:oracleoradatatest;恢復(fù)該數(shù)據(jù)文件sql> recover dmtafile 3;ora-00279: change 1053698 generated 05/07/2003 17:51:26 needed for thread 1ora-00289: suggestion :d:oracleoradatatestarchivetestt001s00304 arcora-00280: change 10
29、53698 for thread 1 is in sequence #304specify log: <ret>=suggested | filename | auto | cancelautoora-00279: change 1053701 generated at 05/07/2003 17:51:39 needed for thread 1ora-00289: suggestion : d:oracleoradatatestarchivetestt001s00305.arc ora-00280: change 1053701 for thread 1 is in seque
30、nce #305ora-00278: log file 1d:oracleoradatatestarchivetestt001s00304.arc 1 no longer needed for this recovery log applied.media recovery complete.恢復(fù)成功,聯(lián)機(jī)該數(shù)據(jù)文件sql> alter database datafile 3 online;database altered7、檢査數(shù)據(jù)庫的數(shù)據(jù)(完全恢復(fù))sql> select * from test;a 12說明:1、采用熱備份,需耍運(yùn)行在歸檔模式下,可以實(shí)現(xiàn)數(shù)據(jù)庫的完全恢復(fù),也就
31、是說,從備份后到 數(shù)據(jù)庫崩潰時(shí)的數(shù)據(jù)祁不會(huì)丟失;2、可以采用全備份數(shù)據(jù)庫的方式備份,対于特殊情況,也町以只備份特定的數(shù)據(jù)文件,如只備 份用戶表空間(一般情況下對(duì)于某些寫特別頻繁的數(shù)據(jù)文件,可以單獨(dú)加大備份頻率);3、如果在恢復(fù)過程中,發(fā)現(xiàn)損壞的是多個(gè)數(shù)據(jù)文件,即可以采川一個(gè)一個(gè)數(shù)據(jù)文件的恢復(fù)方法(第5步中需要對(duì)數(shù)據(jù)文件一一脫機(jī),第6步中需要對(duì)數(shù)據(jù)文件分別恢復(fù)),也可以采用整 個(gè)數(shù)據(jù)庫的恢復(fù)方法;4、如果是系統(tǒng)表空間的損壞,不能采用此方法。4.2.2 rman備份方案rman也町以進(jìn)行聯(lián)機(jī)備份,而且備份與恢復(fù)方法將比os備份更簡(jiǎn)單可靠。1、連接數(shù)據(jù)庫,創(chuàng)建測(cè)試表并插入記錄sql> conn
32、ect intetnel/pessword as sysdba;connectedsql> create table test (a int) tablespace users;table createdsql> insert into test values(1);1 row insertedsql> commit;commit complete2、備份數(shù)據(jù)庫表空間usersc:>rmanrecovery manager: release 8.1.6.0.0 一 productionrman> connect rcvcat rman/rmanbackrman-0
33、6008: connected to recovery catalog databaserman> connect target internal/virpurerman-06005: connected to target database: test (dbid=1788174720)rman> run2> allocate channel cl type disk;3> backup tag 1tsuser1 format 1d:backuptsuser_%u_%s_%p14> tablespace users;5> release channel c
34、l;6> rman-03022: compiling command: allocaterman-03023: executing command: allocaterman-08030: allocated channel: clrman-08500: channel cl: sid=16 devtype=diskrman-03022: compiling command: backuprman-03025: performing implicit partial resync of recovery catalogrman-03023: executing command: part
35、ial resyncrman-08003: starting partial resync of recovery catalogrman-c8005: partial resync completerman-03023: executing command: backuprman-c8008: channel cl: starting full datafile backupsetrman-08502: set_count=5 set_stamp=494177 612 creation_time=l6-may-03rman-08010: channel cl: specifying dmta
36、file(s) in backupsetrman-c8522: input datafile fno=00003 name=d:oracleoradatatestuser01.dbfrman-08013: channel cl: piece 1 createdrman-c8503: piece handle=d:backuptsuser_05en93ac_5_l comment=nonerman-08525: backup set complete, elapsed time: 00:00: 01rman-03023: executing command: partial resyncrman
37、-08003: starting partial resync of recovery catalogrman-08005: partial resync completerman-03022: compiling command: releaserman-03023: executing command: releaserman-08031: released channel: clrman>3、繼續(xù)在測(cè)試表中插入記錄sql> insert into test values(2);1 row insertedsql> commit;commit completesql>
38、; select * from test;a12sql> alter system switch logfile;system altered.sqlr1* alter system switch logfile;system altered-4、關(guān)閉數(shù)據(jù)庫,模擬丟失數(shù)據(jù)文件sql shutdown immediate;database closed.database dismounted.oracle instance shut downc:>del d:oracleoradatatestuser01.dbf5、啟動(dòng)數(shù)據(jù)庫,檢查錯(cuò)謀sql> startuporacle in
39、stance started-total system global area 102020364 bytes fixed size70924 bytesvariable size85487616 bytesdatabase buffers16384000 bytesredo buffers77824 bytesdatabase mounted.ora-01157: cannot identify/lock data file 3 一 see dbwr trace fileora-01110: data file 3: 說明:1、rman也可以實(shí)現(xiàn)單個(gè)農(nóng)空間或數(shù)據(jù)文件的恢復(fù),恢復(fù)過程可以在mo
40、unt下或open方式下, 如果在open方式下恢復(fù),町以減少down機(jī)時(shí)間;d:oracleoradatatestuser01.dbf 16、先打開數(shù)據(jù)庫sql> alter database datafile 3 offline drop;database alteredsql> alter database open;database altered7、恢復(fù)該表空間恢復(fù)腳本可以是恢復(fù)單個(gè)數(shù)據(jù)文件run allocate channel cl type disk;restore datafile 3;recover datafile 3;sql 1 alter database
41、 datafile 3 online1;release channel cl;也可以是,恢復(fù)表空間run allocate channel cl type disk;restore tablespace users;recover tablespace users;sql 1 alter database datafile 3 onlirelease channel cl;過程如下:c:>rmanrecovery manager: release 8.1.6.0.0 一 productionrman connect rcvcat rman/rmanbackrman一06008: conn
42、ected to recovery catalog databaserman connect target interna1/virpurerman-06005: connected to target database: test (dbid=1788174720)rman> run2>allocate channelcltypedisk;3>restore datafile3;4recover datafile3;5>sql f alter databasedatafile3 online *;6> release channel cl;7/輸出內(nèi)容冗長,省略
43、-編者rman>8、檢查數(shù)據(jù)是否完整sql> alter database open;database alteredsql> select * from test;a2、如果損壞的是一個(gè)數(shù)據(jù)文件,建議of f line并在open方式下恢復(fù);而且能保證備3、這里可以看到,rman進(jìn)行數(shù)據(jù)文件與表空間恢復(fù)的時(shí)候,代碼都比較簡(jiǎn)單, 份與恢復(fù)的可靠性,所以建議采用rman的備份與恢復(fù).4.3丟失多個(gè)數(shù)據(jù)文件,實(shí)現(xiàn)整個(gè)數(shù)據(jù)庫的恢復(fù).4.3.1 os備份方案os備份歸檔模式下?lián)p壞(丟失)多個(gè)數(shù)據(jù)文件,進(jìn)行整個(gè)數(shù)據(jù)庫的恢復(fù)1、連接數(shù)據(jù)庫,創(chuàng)建測(cè)試表并插入記錄sql> connec
44、t internal/password as sysdba;connectedsql> create table test (a int);table createdsql> insert into test values (1);1 row insertedsql> commit;commit complete2、備份數(shù)據(jù)庫,備份除臨時(shí)數(shù)據(jù)文件后的所數(shù)據(jù)文件sql> qhotbak sql 或在 dos 下 svrmgrl qhotbak . sql3、繼續(xù)在測(cè)試表中插入記錄sql> insert into test values (2);1 row inser
45、tedsql> commit;commit completesql select * from test;a 12sql alter system switch logfile;system altered-sql> alter system switch logfile;systemered.4、關(guān)閉數(shù)據(jù)庫,模擬丟失數(shù)據(jù)文件sql> shutdown immediate;database closed.database dismountedoracle instance shut downc:>del d:oracleoradatatestsystem01.dbfc:
46、>del d:oracleoradatatestindx01.dbfc:>del d:oracleoradatatesttoolsol.dbfc:>del d:oracleoradatatestrbs01.dbf 模擬媒體毀壞(這里刪除多個(gè)數(shù)據(jù)文件)5、啟動(dòng)數(shù)據(jù)庫,檢查錯(cuò)誤sql startuporacle instanee started.total system globalfixed sizevariable sizedatabase buffersredo buffersdatabase mounted.area 102020364 bytes 70924 bytes
47、 85487616 bytes 16384000 bytes 77824 bytestrace fileora-01157: cannot identify/lock data file 1 一 see dbwrcannot identify/丄ock data file 1 一 see dbwr trace file data file 1:1d:oracleoradatatestsystem01dbf1unable to open fileunabjle to open file(os 2)系統(tǒng)找不到指定的文件。09:39:36 2003thu may 08errors in file d
48、:oracleadmintestbdumptestdbwotrc: ora-01157:ora-01110:ora-27041:osd-04002:o/s-error:cannot identify/lock data file 2 - see dbwr trace data file 2:1d:oracleoradatatestrbs01-dbf funabjle to open file unable to open file(os 2)系統(tǒng)找不到指定的文件。file09:39:36 2003thu may 08errors in file d:oracleadmintestbdumpte
49、stdbwotrc: ora-01157:ora-01110:ora-27041:osd-04002:o/s-error:cannot identify/lock data file 5 - see dbwr trace data file 5: 'd:oracleoradatatesttools01.dbf' unabjle to open file unable to open file(os 2)系統(tǒng)找不到指定的文件。file09:39:36 2003thu may 08errors in file d:oracleadmintestbdumptestdbw0.trc:
50、ora-01157:ora-01110:ora-27041:osd-04002:o/s-error:cannot identify/lock data file 6 - see dbwr trace data file 6:1d:oracleoradatatestindx01.dbf 1unable to open fileunable to open file(os 2)系統(tǒng)找不到指定的文件。fileora-01110: data file 1: 'd:or3cleoradatatestsystem01.dbf'詳細(xì)信息可以查看報(bào)警文件ora-1157 signalled d
51、uring: alter database openthu may 08 09:39:36 2003errors in file d:oracleadmintestbdumptestdbw0.trc:ora-01157:ora-01110:ora-27041:osd-04002:o/s-error:通過查詢v$recover_f ile可以看到 sql> select * from v$recover_file;file#onlineerrorchange#1onlinefile not found02onlinefile not found05onlinefile not found0
52、6onlinefile not found0有四個(gè)數(shù)據(jù)文件需要恢復(fù)time6、過程:d:databaksystem01.dbf d:or3cleoradatatestd:databaktestindx01.dbf d:ormcleoradatatest d:databaktesttoolso1dbf d:or3cleoradatatest d:databaktestrbs01dbf.dbf d:oracleoradatatest拷貝備份冋到原地點(diǎn)(restore),開始恢復(fù)數(shù)據(jù)庫(recover restorec:>copyc:>copyc:>copyc:>copyre
53、cover 過程:sql> recover database;ora-00279: change 1073849 generated at 05/08/2003 08:58:35 needed for thread 1 ora-00289: suggestion : d:oracleoradatatestarchivetestt001s00311.arc ora-00280: change 1073849 for thread 1 is in sequence #311specify log: <ret>=suggested | filename | auto | cance
54、lautoora-00279: change 1073856 generated at 05/08/2003 09:03:27 needed for thread 1 ora-00289: suggestion : d:oracleoradatatestarchivetestt001s00312.arcora-00280: change 1073856 for thread 1 is in sequence #312ora-00278: log file 1d:oracleoradatatestarchivetestt001s00311.arc' no longer needed fo
55、r this recoveryora-00279: change 1073858 generated at 05/08/2003 09:11:43 needed for thread 1 ora-00289: suggestion : d:oracleoradatatestarchivetestt001s00313.arc ora-00280: change 1073858 for thread 1 is in sequence #313ora-00278: log file 1d:oracleoradatatestarchivetestt001s00312arc' no longer needed for this recoveryora-00279: change 1073870 generated at 05/08/2003 09:11:46 needed for thread 1ora-00289: suggestion : d:oracleoradatatestarchivetestt001s00314.arc ora-00280: change 1073870 for thread 1 is in sequence #314ora-00278: lo
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 上海市高新技術(shù)產(chǎn)品進(jìn)口合同
- 個(gè)人借款合同及相關(guān)條款
- 京東商城售后服務(wù)勞動(dòng)合同
- 個(gè)人貸款合同范本:擔(dān)保借款全解析
- 專利申請(qǐng)代理合同標(biāo)準(zhǔn)版
- 中學(xué)教師聘用合同范本
- 親友合資建房合同
- 個(gè)人對(duì)公司財(cái)務(wù)借款合同
- XX村道路改建工程集資合同協(xié)議
- 個(gè)人與企業(yè)汽車抵押借款合同范本
- 2024-2025學(xué)年成都市金牛區(qū)九年級(jí)上期末(一診)英語試題(含答案)
- 2024-2025學(xué)年廣東省深圳市南山區(qū)監(jiān)測(cè)數(shù)學(xué)三年級(jí)第一學(xué)期期末學(xué)業(yè)水平測(cè)試試題含解析
- 廣東2024年廣東金融學(xué)院招聘專職輔導(dǎo)員9人筆試歷年典型考點(diǎn)(頻考版試卷)附帶答案詳解
- 2025年研究生考試考研英語(二204)試卷與參考答案
- DB31∕731-2020 船舶修正總噸單位產(chǎn)品能源消耗限額
- 2024-年全國醫(yī)學(xué)博士外語統(tǒng)一入學(xué)考試英語試題
- 2024年衛(wèi)生專業(yè)技術(shù)資格考試衛(wèi)生檢驗(yàn)技術(shù)(初級(jí)(師)211)相關(guān)專業(yè)知識(shí)試題及答案指導(dǎo)
- 《手衛(wèi)生知識(shí)培訓(xùn)》培訓(xùn)課件
- 《祛痘產(chǎn)品祛痘產(chǎn)品》課件
- 江蘇省南京鼓樓區(qū)2024年中考聯(lián)考英語試題含答案
- 兒科護(hù)理學(xué)試題及答案解析-神經(jīng)系統(tǒng)疾病患兒的護(hù)理(二)
評(píng)論
0/150
提交評(píng)論