測試恢復3==當資料庫處於開啟狀態時的恢復
說明:資料庫在開啟狀態下需要恢復要怎麼做呢?首先明確什麼時候需要這麼做這麼做的前提是什麼===發生損壞的檔案和SYSTEM表空間沒關係【系統表空間如果有問題那隻能在關閉狀態下進行恢復】,資料庫在恢復的時候要求開啟【這樣不影響業務或者說影響業務的程度要小一點】,當前資料庫正處在開啟狀態下。。。。
開啟狀態下的常規恢復流程:
1.把受影響的資料檔案離線
2.還原資料檔案RESTORE DATAFILE;
3.應用歸檔日誌APPLY ARCHIVELOG
4.然後把資料檔案ONLINE
========================準備工作==============================
如:
會話1:增加T表資料
SQL> show user;
USER is "QQ1"
SQL> select * from t;
ID NAME
---------- ----------
0 qq1
1 qq2
2 qq3
SQL> insert into t values (3,'qq4');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- ----------
0 qq1
1 qq2
2 qq3
3 qq4
SQL>
會話2:手動切換日誌
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL>
切換日誌以後在歸檔檔案中會看到剛歸檔的歸檔日誌
[oracle@oraclelinux 2012_04_26]$ ll
total 23308
-rw-r----- 1 oracle oinstall 21413888 Apr 26 10:11 o1_mf_1_53_7skcppkm_.arc
-rw-r----- 1 oracle oinstall 1565184 Apr 26 10:59 o1_mf_1_54_7skgjqyf_.arc
-rw-r----- 1 oracle oinstall 825856 Apr 26 11:01 o1_mf_1_55_7skgmvm2_.arc
-rw-r----- 1 oracle oinstall 1024 Apr 26 11:01 o1_mf_1_56_7skgn9cp_.arc
[oracle@oraclelinux 2012_04_26]$ ll
total 23796
-rw-r----- 1 oracle oinstall 21413888 Apr 26 10:11 o1_mf_1_53_7skcppkm_.arc
-rw-r----- 1 oracle oinstall 1565184 Apr 26 10:59 o1_mf_1_54_7skgjqyf_.arc
-rw-r----- 1 oracle oinstall 825856 Apr 26 11:01 o1_mf_1_55_7skgmvm2_.arc
-rw-r----- 1 oracle oinstall 1024 Apr 26 11:01 o1_mf_1_56_7skgn9cp_.arc
-rw-r----- 1 oracle oinstall 489984 Apr 26 11:25 o1_mf_1_57_7skj11s9_.arc
[oracle@oraclelinux 2012_04_26]$ ll
total 23804
-rw-r----- 1 oracle oinstall 21413888 Apr 26 10:11 o1_mf_1_53_7skcppkm_.arc
-rw-r----- 1 oracle oinstall 1565184 Apr 26 10:59 o1_mf_1_54_7skgjqyf_.arc
-rw-r----- 1 oracle oinstall 825856 Apr 26 11:01 o1_mf_1_55_7skgmvm2_.arc
-rw-r----- 1 oracle oinstall 1024 Apr 26 11:01 o1_mf_1_56_7skgn9cp_.arc
-rw-r----- 1 oracle oinstall 489984 Apr 26 11:25 o1_mf_1_57_7skj11s9_.arc
-rw-r----- 1 oracle oinstall 1536 Apr 26 11:26 o1_mf_1_58_7skj2sn1_.arc
[oracle@oraclelinux 2012_04_26]$ ll
total 23816
-rw-r----- 1 oracle oinstall 21413888 Apr 26 10:11 o1_mf_1_53_7skcppkm_.arc
-rw-r----- 1 oracle oinstall 1565184 Apr 26 10:59 o1_mf_1_54_7skgjqyf_.arc
-rw-r----- 1 oracle oinstall 825856 Apr 26 11:01 o1_mf_1_55_7skgmvm2_.arc
-rw-r----- 1 oracle oinstall 1024 Apr 26 11:01 o1_mf_1_56_7skgn9cp_.arc
-rw-r----- 1 oracle oinstall 489984 Apr 26 11:25 o1_mf_1_57_7skj11s9_.arc
-rw-r----- 1 oracle oinstall 1536 Apr 26 11:26 o1_mf_1_58_7skj2sn1_.arc
-rw-r----- 1 oracle oinstall 4608 Apr 26 11:26 o1_mf_1_59_7skj3oqc_.arc
[oracle@oraclelinux 2012_04_26]$
以上的準備是為了保證資料在發生更新以後,可用的歸檔完好無損的存在著!
===========================災難發生===========================
會話1:測試用T表所有表空間資料檔案被刪除
[root@oraclelinux dbtest]# pwd
/u01/oradata/dbtest
[root@oraclelinux dbtest]# ll
total 1626024
-rw-r----- 1 oracle oinstall 7061504 Apr 26 11:36 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 Apr 26 11:36 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 Apr 26 11:36 control03.ctl
-rw-r--r-- 1 oracle oinstall 1228 Mar 22 21:09 ctl
-rw-r----- 1 oracle oinstall 104865792 Apr 26 11:31 example01.dbf
-rw-r----- 1 oracle oinstall 20979712 Apr 26 11:31 paul01.dbf
-rw-r----- 1 oracle oinstall 52436992 Apr 26 11:31 qq01.dbf
-rw-r----- 1 oracle oinstall 52429312 Apr 26 11:26 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Apr 26 11:36 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Apr 26 11:25 redo03.log
-rw-r----- 1 oracle oinstall 52429312 Mar 23 14:50 redo04a.log
-rw-r----- 1 oracle oinstall 52429312 Apr 26 11:26 redo04.log
-rw-r----- 1 oracle oinstall 461381632 Apr 26 11:35 sysaux01.dbf
-rw-r----- 1 oracle oinstall 576724992 Apr 26 11:35 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Apr 25 22:00 temp01.dbf
-rw-r----- 1 oracle oinstall 115351552 Apr 26 11:34 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Apr 26 11:31 users01.dbf
-rw-r----- 1 oracle oinstall 20979712 Apr 26 11:31 wenchuan01.dbf
-rw-r----- 1 oracle oinstall 20979712 Apr 26 11:31 wenchuan2.dbf
[root@oraclelinux dbtest]# rm -rf qq01.dbf
[root@oraclelinux dbtest]#
=====================恢復開始==================================
我們知道是那個資料檔案丟失了QQ01.DBF,檢視對應資料檔案編號
SQL> select file#,name from v$datafile;
FILE# NAME
---------- ------------------------------
9 /u01/oradata/dbtest/qq01.dbf
2.讓這個資料檔案離線
SQL> alter database datafile 9 offline;
Database altered.
SQL>
3.RESTORE恢復
把之前熱備的資料檔案複製到資料庫存放資料檔案的目錄下
[root@oraclelinux hot]# ls
qq01.dbf
[root@oraclelinux hot]# cp qq01.dbf /u01/oradata/dbtest/
4.RECOVER資料檔案
SQL> recover datafile 9;就使用一命令
這一步是做log applied
5.讓資料檔案ONLINE
SQL> alter database datafile 9 online;
Database altered.
SQL>
6.檢查恢復結果,標準是T表中有4條記錄
SQL> select * from t;
ID NAME
---------- ----------
0 qq1
1 qq2
2 qq3
3 qq4
SQL>
=========================恢復結束=============================
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15720542/viewspace-722274/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sqlsever處理資料庫的恢復掛起狀態SQL資料庫
- SQLServer資料庫處於恢復掛起狀態的解決辦法SQLServer資料庫
- Jtti:SQLServer資料庫處於恢復掛起狀態的解決辦法JttiSQLServer資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 資料庫資料恢復-oracle資料庫報錯無法開啟的如何恢復資料?資料庫資料恢復Oracle
- 寶塔資料庫恢復 mysql資料庫丟失恢復 mysql資料庫刪除庫恢復 寶塔mysql資料庫恢復資料庫MySql
- 資料庫恢復後開啟時遇到 ORA-01152資料庫
- 【資料庫資料恢復】SAP資料庫資料恢復案例資料庫資料恢復
- 【資料庫資料恢復】MongoDB資料庫服務啟動失敗的資料恢復案例資料庫資料恢復MongoDB
- 【資料庫資料恢復】無法啟動MongoDB服務的資料恢復案例資料庫資料恢復MongoDB
- 【資料庫資料恢復】Sql Server資料庫資料恢復案例資料庫資料恢復SQLServer
- 如何恢復SSD NVME固態硬碟的資料恢復硬碟資料恢復
- 資料庫修復資料恢復資料庫資料恢復
- PostgreSQL 恢復大法 - 恢復部分資料庫、跳過壞塊、修復無法啟動的資料庫SQL資料庫
- 【資料庫資料恢復】windows server下SqlServer資料庫的資料恢復資料庫資料恢復WindowsServerSQL
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- Sybase ASE資料庫恢復,Sybase資料恢復,資料誤刪除恢復工具READSYBDEVICE資料庫資料恢復dev
- 伺服器資料恢復—透過拼接資料庫碎片恢復SqlServer資料庫資料的資料恢復案例伺服器資料恢復資料庫SQLServer
- 資料庫資料恢復——Windows無法啟動MongoDB服務的資料恢復案例資料庫資料恢復WindowsMongoDB
- 【資料庫資料恢復】Oracle資料庫誤truncate table的資料恢復案例資料庫資料恢復Oracle
- 【資料庫資料恢復】誤truncate table的Oracle資料庫資料恢復方案資料庫資料恢復Oracle
- 資料庫資料恢復—MongoDB資料庫檔案丟失,啟動報錯的資料恢復案例資料庫資料恢復MongoDB
- 【資料庫資料恢復】突然斷電造成Syabse資料庫無法啟動的資料恢復案例資料庫資料恢復
- 【資料庫資料恢復】EXT3檔案系統下MYSQL資料庫恢復案例資料庫資料恢復MySql
- NAS陣列恢復資料資料恢復開盤陣列資料恢復
- MySQL資料庫的恢復MySql資料庫
- sybase資料庫恢復資料庫
- 資料恢復:AMDU資料抽取恢復資料恢復
- Sybase SQL Anywhere(ASA)資料庫恢復,ASA資料恢復,資料誤刪除恢復工具ReadASADBSQL資料庫資料恢復
- 【資料庫資料恢復】sql server資料庫連線失效的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】SqlServer資料庫無法讀取的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- 【資料庫資料恢復】oracle資料庫誤truncate table怎麼恢復資料?資料庫資料恢復Oracle
- 【資料庫資料恢復】linux系統下MYSQL資料庫資料恢復案例資料庫資料恢復LinuxMySql
- SQL Server資料庫恢復,SQL Server資料恢復,SQL Server資料誤刪除恢復工具SQLRescueSQLServer資料庫資料恢復
- 處理恢復資料方法
- 資料庫資料恢復—附加資料庫錯誤823的SQL Server資料恢復案例資料庫資料恢復SQLServer