Oracle 11g 資料庫恢復-場景2:所有據檔案損壞,關庫狀態
--切日誌 sys@TESTDB11>alter system switch logfile;
System altered. --修改資料提交 scott@TESTDB11>select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 17-DEC-80 800 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7788 SCOTT ANALYST 7566 19-APR-87 6000 20 7839 KING PRESIDENT 17-NOV-81 5000 10 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7934 MILLER CLERK 7782 23-JAN-82 2600 10
14 rows selected.
scott@TESTDB11>update emp set sal = 1800 where ename = 'SMITH';
1 row updated.
scott@TESTDB11>commit;
Commit complete. --修改資料不提交 scott@TESTDB11>select * from dept;
DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON
scott@TESTDB11>delete from dept where deptno = 40;
1 row deleted.
--切日誌3次 sys@TESTDB11>alter system switch logfile;
System altered.
--檢視檢查點 sys@TESTDB11>select name, checkpoint_change# from v$datafile;
NAME CHECKPOINT_CHANGE# ------------------------------------------------------------ ------------------ /u01/app/oracle/oradata/TestDB11/system01.dbf 2726220 /u01/app/oracle/oradata/TestDB11/sysaux01.dbf 2726220 /u01/app/oracle/oradata/TestDB11/undotbs01.dbf 2726220 /u01/app/oracle/oradata/TestDB11/users01.dbf 2726220 /u01/app/oracle/oradata/TestDB11/example01.dbf 2726220 /u01/app/oracle/oradata/TestDB11/rotbs01.dbf 2726220
6 rows selected.
--關庫 sys@TESTDB11>shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down.
--刪除所有的dbf檔案 [oracle@S1011:/export/home/oracle]$ cd /u01/app/oracle/oradata/TestDB11 [oracle@S1011:/u01/app/oracle/oradata/TestDB11]$ ls control01.ctl example01.dbf redo01.log redo02.log redo03.log rotbs01.dbf sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf [oracle@S1011:/u01/app/oracle/oradata/TestDB11]$ rm *.dbf [oracle@S1011:/u01/app/oracle/oradata/TestDB11]$ ls control01.ctl redo01.log redo02.log redo03.log
--啟庫 sys@TESTDB11>startup ORACLE instance started.
Total System Global Area 855982080 bytes Fixed Size 2230792 bytes Variable Size 641730040 bytes Database Buffers 209715200 bytes Redo Buffers 2306048 bytes Database mounted. ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: '/u01/app/oracle/oradata/TestDB11/system01.dbf'
--檢視需要恢復的檔案的資訊 sys@TESTDB11>select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME ---------- ------- ------- --------------- ---------- --------- 1 ONLINE ONLINE FILE NOT FOUND 0 2 ONLINE ONLINE FILE NOT FOUND 0 3 ONLINE ONLINE FILE NOT FOUND 0 4 ONLINE ONLINE FILE NOT FOUND 0 5 ONLINE ONLINE FILE NOT FOUND 0 6 ONLINE ONLINE FILE NOT FOUND 0
6 rows selected.
--還原檔案 [oracle@S1011:/]$ cp /backup/inconsistent_backup/*.dbf /u01/app/oracle/oradata/TestDB11
--檢查一下控制檔案中記錄的資料檔案中的檢查點號(一致,因為剛才做的shutdown immediate) sys@TESTDB11>select name, checkpoint_change# from v$datafile;
NAME CHECKPOINT_CHANGE# ------------------------------------------------------------ ------------------ /u01/app/oracle/oradata/TestDB11/system01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/sysaux01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/undotbs01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/users01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/example01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/rotbs01.dbf 2726683
6 rows selected. --檢查還原回來的資料檔案頭中的檢查點號 sys@TESTDB11>select name, checkpoint_change# from v$datafile_header;
NAME CHECKPOINT_CHANGE# ------------------------------------------------------------ ------------------ /u01/app/oracle/oradata/TestDB11/system01.dbf 2654775 (最小的檢查點) /u01/app/oracle/oradata/TestDB11/sysaux01.dbf 2654801 /u01/app/oracle/oradata/TestDB11/undotbs01.dbf 2654893 /u01/app/oracle/oradata/TestDB11/users01.dbf 2654911 /u01/app/oracle/oradata/TestDB11/example01.dbf 2654924 /u01/app/oracle/oradata/TestDB11/rotbs01.dbf 2654946
6 rows selected. --檢視恢復過程中需要使用的日誌 sys@TESTDB11>col archive_name for a30 sys@TESTDB11>select * from v$recovery_log;
THREAD# SEQUENCE# TIME ARCHIVE_NAME ---------- ---------- --------- ------------------------------ 1 98 09-AUG-13 /archive2/1_98_813665348.dbf 1 99 09-AUG-13 /archive2/1_99_813665348.dbf 1 100 10-AUG-13 /archive2/1_100_813665348.dbf 1 101 10-AUG-13 /archive2/1_101_813665348.dbf 1 102 10-AUG-13 /archive2/1_102_813665348.dbf 1 103 10-AUG-13 /archive2/1_103_813665348.dbf 1 104 10-AUG-13 /archive2/1_104_813665348.dbf
7 rows selected.
sys@TESTDB11>select sequence#, group#, status from v$log;
SEQUENCE# GROUP# STATUS ---------- ---------- ---------------- 106 1 INACTIVE 105 3 INACTIVE 107 2 CURRENT
--計算一下,為什麼需要上述這些歸檔(找還原回來的資料檔案頭中最小的檢查點) sys@TESTDB11>col name for a50 sys@TESTDB11>select first_change#, next_change#, sequence#, name from v$archived_log;
FIRST_CHANGE# NEXT_CHANGE# SEQUENCE# NAME ------------- ------------ ---------- -------------------------------------------------- 2547678 2572509 89 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_08/o1_mf_1_89_9088fgfy_.arc
2572509 2580755 90 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_08/o1_mf_1_90_908m64sj_.arc
2580755 2581128 91 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_08/o1_mf_1_91_908mld6s_.arc
2581128 2581689 92 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_08/o1_mf_1_92_908n7jll_.arc
2581689 2583163 93 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_08/o1_mf_1_93_908o4bd8_.arc
2583163 2583270 94 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_08/o1_mf_1_94_908obsky_.arc
2583270 2603385 95 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_08/o1_mf_1_95_908oq470_.arc
2603385 2635256 96 /u01/app/oracle/fast_recovery_area/TESTDB11/archiv elog/2013_08_09/o1_mf_1_96_909wogyw_.arc
2635256 2641003 97 /archive1/1_97_813665348.dbf 2635256 2641003 97 /archive2/1_97_813665348.dbf 2641003 2660981 98 /archive1/1_98_813665348.dbf 2641003 2660981 98 /archive2/1_98_813665348.dbf 2660981 2667783 99 /archive1/1_99_813665348.dbf 2660981 2667783 99 /archive2/1_99_813665348.dbf 2667783 2679804 100 /archive1/1_100_813665348.dbf 2667783 2679804 100 /archive2/1_100_813665348.dbf 2679804 2699110 101 /archive1/1_101_813665348.dbf 2679804 2699110 101 /archive2/1_101_813665348.dbf 2699110 2725650 102 /archive1/1_102_813665348.dbf 2699110 2725650 102 /archive2/1_102_813665348.dbf 2725650 2726122 103 /archive1/1_103_813665348.dbf 2725650 2726122 103 /archive2/1_103_813665348.dbf 2726122 2726220 104 /archive1/1_104_813665348.dbf 2726122 2726220 104 /archive2/1_104_813665348.dbf 2726220 2726249 105 /archive1/1_105_813665348.dbf 2726220 2726249 105 /archive2/1_105_813665348.dbf 2726249 2726261 106 /archive1/1_106_813665348.dbf 2726249 2726261 106 /archive2/1_106_813665348.dbf
28 rows selected.
--執行恢復 sys@TESTDB11>recover database; ORA-00279: change 2654775 generated at 08/09/2013 21:25:44 needed for thread 1 ORA-00289: suggestion : /archive2/1_98_813665348.dbf ORA-00280: change 2654775 for thread 1 is in sequence #98
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
--輸入回車
ORA-00279: change 2660981 generated at 08/09/2013 22:19:48 needed for thread 1 ORA-00289: suggestion : /archive2/1_99_813665348.dbf ORA-00280: change 2660981 for thread 1 is in sequence #99
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} auto ORA-00279: change 2667783 generated at 08/10/2013 00:00:55 needed for thread 1 ORA-00289: suggestion : /archive2/1_100_813665348.dbf ORA-00280: change 2667783 for thread 1 is in sequence #100
ORA-00279: change 2679804 generated at 08/10/2013 03:00:28 needed for thread 1 ORA-00289: suggestion : /archive2/1_101_813665348.dbf ORA-00280: change 2679804 for thread 1 is in sequence #101
ORA-00279: change 2699110 generated at 08/10/2013 08:29:58 needed for thread 1 ORA-00289: suggestion : /archive2/1_102_813665348.dbf ORA-00280: change 2699110 for thread 1 is in sequence #102
ORA-00279: change 2725650 generated at 08/10/2013 10:27:18 needed for thread 1 ORA-00289: suggestion : /archive2/1_103_813665348.dbf ORA-00280: change 2725650 for thread 1 is in sequence #103
ORA-00279: change 2726122 generated at 08/10/2013 10:29:03 needed for thread 1 ORA-00289: suggestion : /archive2/1_104_813665348.dbf ORA-00280: change 2726122 for thread 1 is in sequence #104
-- 為什麼沒有應用序號為105和106的日誌? Log applied. Media recovery complete.
--檢視一致性 sys@TESTDB11>select name, checkpoint_change# from v$datafile;
NAME CHECKPOINT_CHANGE# -------------------------------------------------- ------------------ /u01/app/oracle/oradata/TestDB11/system01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/sysaux01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/undotbs01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/users01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/example01.dbf 2726683 /u01/app/oracle/oradata/TestDB11/rotbs01.dbf 2726683
6 rows selected.
sys@TESTDB11>select name, checkpoint_change# from v$datafile_header;
NAME CHECKPOINT_CHANGE# -------------------------------------------------- ------------------ /u01/app/oracle/oradata/TestDB11/system01.dbf 2726681 /u01/app/oracle/oradata/TestDB11/sysaux01.dbf 2726681 /u01/app/oracle/oradata/TestDB11/undotbs01.dbf 2726681 /u01/app/oracle/oradata/TestDB11/users01.dbf 2726681 /u01/app/oracle/oradata/TestDB11/example01.dbf 2726681 /u01/app/oracle/oradata/TestDB11/rotbs01.dbf 2726681
6 rows selected.
--開庫 sys@TESTDB11>alter database open;
Database altered.
--檢視資料 --提交的修改 scott@TESTDB11>select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 17-DEC-80 1800 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7788 SCOTT ANALYST 7566 19-APR-87 6000 20 7839 KING PRESIDENT 17-NOV-81 5000 10 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7934 MILLER CLERK 7782 23-JAN-82 2600 10
14 rows selected.
--未提交的修改 scott@TESTDB11>select * from dept;
DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17013648/viewspace-1151908/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 11g 資料庫恢復-場景1:所有的資料檔案損壞,OPEN狀態Oracle資料庫
- Oracle 11g RMAN恢復-場景2:所有的資料檔案損壞,OPEN狀態Oracle
- Oralce 11g資料庫恢復-場景3:部分檔案損壞恢復,關庫狀態,高可用恢復方式資料庫
- Oracle 11g 資料庫恢復-場景5:部分檔案損壞恢復,開庫狀態,低可用恢復方式Oracle資料庫
- Oracle 11g 資料庫恢復-場景4:部分檔案損壞恢復,開庫狀態, 高可用恢復方式Oracle資料庫
- Oracle 11g RMAN恢復-場景1:所有的資料檔案損壞,資料庫CLOSEOracle資料庫
- Oracle 11g 資料庫恢復-場景7:部分檔案損壞Oracle資料庫
- Oracle 11g 資料庫恢復-場景8:系統預設undo表空間資料檔案損壞,CLOSE狀態Oracle資料庫
- Oracle 11g RMAN恢復-場景3:非系統表空間資料檔案損壞,資料庫OPEN狀態,高可用Oracle資料庫
- Oracle 11g資料庫恢復:場景11:資料檔案損壞,不能恢復到原來的位置, 恢復到新的路徑Oracle資料庫
- Oracle 11g 資料庫恢復:場景9-系統預設undo表空間資料檔案損壞Oracle資料庫
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- [ORACLE] 系統故障資料庫恢復--資料檔案無損壞Oracle資料庫
- Oracle資料庫UNDO損壞後的恢復Oracle資料庫
- Oracle資料庫恢復:歸檔日誌損壞案例一則Oracle資料庫
- oracle資料庫正常關閉狀態下丟失undo檔案的恢復Oracle資料庫
- Oracle 11g 資料庫恢復:場景12續:將資料檔案恢復回原來正確的位置Oracle資料庫
- Oracle資料檔案損壞恢復例項二則Oracle
- inactive狀態日誌組檔案損壞的恢復
- 【資料庫資料恢復】Oracle資料庫檔案出現壞塊報錯的資料恢復案例資料庫資料恢復Oracle
- 資料庫資料恢復—NTFS分割槽損壞如何恢復SqlServer資料庫資料資料庫資料恢復SQLServer
- InterBase資料庫檔案損壞的修復方法資料庫
- 資料庫檔案壞塊損壞導致開啟時報錯的恢復方法資料庫
- master資料庫損壞之後的恢復AST資料庫
- 使用RMAN恢復完全損壞的資料庫資料庫
- Oracle資料庫不同損壞級別的恢復詳解Oracle資料庫
- 【恢復】使用控制檔案的trace備份恢復因異常斷電導致所有控制檔案損壞的資料庫故障資料庫
- 織夢資料庫配置檔案資料庫損壞:嘗試修復資料庫資料庫
- 資料檔案丟失損壞的恢復--
- 所有控制檔案損壞的恢復--resetlogs方式
- 所有控制檔案損壞的恢復--noresetlogs方式
- u盤檔案損壞怎麼恢復資料 u盤恢復損壞資料的有效方法
- 資料庫資料恢復-SQL SERVER資料庫MDF (NDF)或LDF損壞如何恢復資料?資料庫資料恢復SQLServer
- PG 資料庫檔案損壞的另一個不完全恢復方案.資料庫
- rman 恢復---歸檔丟失and資料檔案損壞
- 某個資料檔案損壞完全恢復(三)
- 完全恢復之所有資料庫檔案丟失資料庫
- 備份與恢復--重建控制檔案後資料檔案損壞的恢復