您好,登錄后才能下訂單哦!
這篇“Oracle備份恢復的方法有哪些”文章的知識點大部分人都不太理解,所以小編給大家總結了以下內容,內容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“Oracle備份恢復的方法有哪些”文章吧。
一、不同場景在滿足不同的條件時的恢復方法:
二、針對不同的恢復方法給出具體的恢復思路:
2.1、通過重新拷貝冗余的控制文件
1、在線或者關閉數據庫后損壞了其中部分控制文件;
2、shutdown abort關閉數據庫;
3、拷貝其中一個完好的控制文件;
4、startup啟動數據庫。
2.2、 通過備份控制文件進行完全恢復
1、在線或者關閉數據庫后損壞了所有控制文件;
2、shutdown abort關閉數據庫;
3、startup nomount啟動數據庫;
4、restore controlfile from ‘xxx’;從備份中還原控制文件;
5、alter database mount;
5、recover database using backup controlfile until cancel,在執行時選擇auto自動應用所有的歸檔文件;
6、再次執行recover database using backup controlfile until cancel,選擇應用未歸檔的redo文件;
7、alter database open resetlogs;
2.3、通過備份控制文件進行不完全恢復
1、在線或者關閉數據庫后損壞了所有控制文件;
2、shutdown abort關閉數據庫;
3、startup nomount啟動數據庫;
4、restore controlfile from ‘xxx’;從備份中還原控制文件;
5、alter database mount;
6、recover database using backup controlfile until cancel,在執行時選擇auto自動應用盡可能多的歸檔文件;
7、alter database open resetlogs;
2.4、通過備份控制文件進行重建的恢復(noresetlogs方式)
1、在線或者關閉數據庫后損壞了所有控制文件;
2、shutdown abort關閉數據庫;
3、startup nomount啟動數據庫;
4、restore controlfile from ‘xxx’;從備份中還原控制文件;
5、alter database mount;
6、alter database backup controlfile to trace,生成創建控制文件的腳本;
7、shutdown immediate并啟動到startup nomount狀態;
8、使用noresetlogs方式創建控制文件;
9、recover database恢復數據庫;
10、恢復完后通過alter database open打開數據庫;
2.5、通過備份控制文件進行重建的恢復(resetlogs方式)
1、在線或者關閉數據庫后損壞了所有控制文件;
2、shutdown abort關閉數據庫;
3、startup nomount啟動數據庫;
4、restore controlfile from ‘xxx’;從備份中還原控制文件;
5、alter database mount;
6、alter database backup controlfile to trace,生成創建控制文件的腳本;
7、shutdown immediate并啟動到startup nomount狀態
8、使用resetlogs方式創建控制文件;
9、如果未歸檔的redo文件可用時,則直接recover database,然后選用未歸檔的redo文件應用,
最后通過alter database open resetlogs方式打開數據庫。
10、如果未歸檔的redo文件不可用時,則需要設置隱含參數_allow_resetlogs_corruption為true跳
過一致性檢查,最后用alter database open resetlogs方式打開數據庫。
注:打開數據庫后很多情況下會出現需要推進scn的問題。
2.6、通過手工重建的控制文件進行恢復(noresetlogs方式)
1、在線或者關閉數據庫后損壞了所有控制文件;
2、shutdown abort關閉數據庫;
3、startup nomount啟動數據庫;
4、構造控制文件;
下面的步驟參考2.4的第八步;
2.7、通過手工重建的控制文件進行恢復(resetlogs方式)
1、在線或者關閉數據庫后損壞了所有控制文件;
2、shutdown abort關閉數據庫;
3、startup nomount啟動數據庫;
4、構造控制文件;
下面的步驟參考2.5的第八步;
三、模擬幾種恢復方法的操作:
下面主要對這三種恢復方法(通過備份控制文件進行完全恢復、通過備份控制文件進行重建的恢復(noresetlogs方式)、通過備份控制文件進行重建的恢復(resetlogs方式))的操作模擬,因為其他的幾種恢復方法要么比較簡單要么跟這三種方法共通。
3.1、通過備份控制文件進行完全恢復
1、查看數據庫基本信息和數據庫狀態 SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string leonliao SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /home/oracle/oradata/leonliao/ control01.ctl, /home/oracle/or adata/leonliao/control02.ctl SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE 2、備份控制文件 RMAN> backup current controlfile; 3、數據庫在線時刪除所有控制文件 [oracle@leon1 leonliao]$ rm -rf control0*ctl [oracle@leon1 leonliao]$ pwd /home/oracle/oradata/leonliao 4、無法正常關閉數據庫只能shutdown abort SQL> shutdown immediate Database closed. ORA-00210: cannot open the specified control file ORA-00202: control file: '/home/oracle/oradata/leonliao/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> shutdown abort ORACLE instance shut down. SQL> 5、啟動數據庫到nomount狀態并還原備份的控制文件 SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes RMAN> restore controlfile from '/u01/app/oracle/dbs/01qvmql3_1_1'; 6、將數據庫啟動到mount狀態并開始恢復 SQL> alter database mount; Database altered. SQL> SQL> SQL> recover database using backup controlfile until cancel; ORA-00279: change 1181770 generated at 03/05/2016 05:02:58 needed for thread 1 ORA-00289: suggestion : /home/oracle/oradata/leonliao/arch/1_6_905662043.dbf ORA-00280: change 1181770 for thread 1 is in sequence #6 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} auto <<<<<選擇auto,自動應用所有的歸檔文件 ORA-00308: cannot open archived log '/home/oracle/oradata/leonliao/arch/1_6_905662043.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 ORA-00308: cannot open archived log '/home/oracle/oradata/leonliao/arch/1_6_905662043.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/home/oracle/oradata/leonliao/system01.dbf' SQL> recover database using backup controlfile until cancel; <<<<<由于未歸檔的redo文件需要手動應用 ORA-00279: change 1181770 generated at 03/05/2016 05:02:58 needed for thread 1 ORA-00289: suggestion : /home/oracle/oradata/leonliao/arch/1_6_905662043.dbf ORA-00280: change 1181770 for thread 1 is in sequence #6 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} /home/oracle/oradata/leonliao/redo03.log <<<<<在關閉數據庫前可以查看當前current的redo文件是哪一個,不清楚可以一個個應用直到提示Log applied為止 Log applied. Media recovery complete. 7、以open resetlogs方式打開數據庫 SQL> alter database open resetlogs; Database altered. SQL> SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE |
3.2、通過備份控制文件進行重建的恢復(noresetlogs方式)
1、查看數據庫基本信息和數據庫狀態 SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string leonliao SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /home/oracle/oradata/leonliao/ control01.ctl, /home/oracle/or adata/leonliao/control02.ctl SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE 2、備份控制文件 RMAN> backup current controlfile; 3、數據庫在線時刪除所有控制文件 [oracle@leon1 leonliao]$ rm -rf control0*ctl [oracle@leon1 leonliao]$ pwd /home/oracle/oradata/leonliao 4、無法正常關閉數據庫只能shutdown abort SQL> shutdown immediate Database closed. ORA-00210: cannot open the specified control file ORA-00202: control file: '/home/oracle/oradata/leonliao/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> shutdown abort ORACLE instance shut down. SQL> 5、啟動數據庫到nomount狀態并還原備份的控制文件 SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes RMAN> restore controlfile from '/u01/app/oracle/dbs/03qvmrqj_1_1'; 6、將數據庫啟動到mount狀態并生成創建控制文件的腳本 SQL> alter database mount; Database altered. SQL> alter database backup controlfile to trace; Database altered. 7、shutdown immediate并啟動到startup nomount狀態創建控制文件 SQL> shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes SQL> CREATE CONTROLFILE REUSE DATABASE "LEONLIAO" NORESETLOGS ARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/home/oracle/oradata/leonliao/redo01.log' SIZE 50M BLOCKSIZE 512, 9 GROUP 2 '/home/oracle/oradata/leonliao/redo02.log' SIZE 50M BLOCKSIZE 512, 10 GROUP 3 '/home/oracle/oradata/leonliao/redo03.log' SIZE 50M BLOCKSIZE 512 11 -- STANDBY LOGFILE 12 DATAFILE 13 '/home/oracle/oradata/leonliao/system01.dbf', 14 '/home/oracle/oradata/leonliao/sysaux01.dbf', 15 '/home/oracle/oradata/leonliao/undotbs01.dbf', 16 '/home/oracle/oradata/leonliao/users01.dbf' 17 CHARACTER SET ZHS16GBK 18 ; Control file created. 8、開始恢復 SQL> recover database; ORA-00283: recovery session canceled due to errors ORA-00264: no recovery required 9、以open方式打開數據庫 SQL> alter database open; Database altered. SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE |
3.3、通過備份控制文件進行重建的恢復(resetlogs方式)
1、查看數據庫基本信息和數據庫狀態 SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string leonliao SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /home/oracle/oradata/leonliao/ control01.ctl, /home/oracle/or adata/leonliao/control02.ctl SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1 ONLINE /home/oracle/oradata/leonliao/redo01.log NO 3 ONLINE /home/oracle/oradata/leonliao/redo03.log NO 2 ONLINE /home/oracle/oradata/leonliao/redo02.log NO SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE 2、備份控制文件 RMAN> backup current controlfile; 3、數據庫在線時刪除所有控制文件和redo文件 [oracle@leon1 leonliao]$ rm -rf control0*ctl [oracle@leon1 leonliao]$ rm -rf redo0*log [oracle@leon1 leonliao]$ pwd /home/oracle/oradata/leonliao 4、無法正常關閉數據庫只能shutdown abort SQL> shutdown immediate Database closed. ORA-00210: cannot open the specified control file ORA-00202: control file: '/home/oracle/oradata/leonliao/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> shutdown abort ORACLE instance shut down. SQL> 5、啟動數據庫到nomount狀態并還原備份的控制文件 SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes RMAN> restore controlfile from '/u01/app/oracle/dbs/01qvmtbj_1_1'; 6、將數據庫啟動到mount狀態并生成創建控制文件的腳本 SQL> alter database mount; Database altered. SQL> alter database backup controlfile to trace; Database altered. 7、shutdown immediate并啟動到startup nomount狀態創建resetlogs的控制文件 SQL> shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes SQL> CREATE CONTROLFILE REUSE DATABASE "LEONLIAO" RESETLOGS ARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/home/oracle/oradata/leonliao/redo01.log' SIZE 50M BLOCKSIZE 512, 9 GROUP 2 '/home/oracle/oradata/leonliao/redo02.log' SIZE 50M BLOCKSIZE 512, 10 GROUP 3 '/home/oracle/oradata/leonliao/redo03.log' SIZE 50M BLOCKSIZE 512 11 -- STANDBY LOGFILE 12 DATAFILE 13 '/home/oracle/oradata/leonliao/system01.dbf', 14 '/home/oracle/oradata/leonliao/sysaux01.dbf', 15 '/home/oracle/oradata/leonliao/undotbs01.dbf', 16 '/home/oracle/oradata/leonliao/users01.dbf' 17 CHARACTER SET ZHS16GBK 18 ; Control file created. 8、因為所有redo文件都刪除了,無法恢復,所以會出現一致性的問題,通過設置隱含參數_allow_resetlogs_corruption為true跳過一致性檢查; SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile; System altered. SQL> shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes Database mounted. 9、以open resetlogs方式打開數據庫 SQL> alter database open resetlogs; Database altered. SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE |
以上就是關于“Oracle備份恢復的方法有哪些”這篇文章的內容,相信大家都有了一定的了解,希望小編分享的內容對大家有幫助,若想了解更多相關的知識內容,請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。