作業系統層恢復非關鍵資料檔案
在沒有備份的情況下,執行中的資料庫突然丟失了或者誤刪除一個非關鍵資料檔案,
這時候,記得不要馬上關閉資料庫,這個問題可以從系統層上來恢復丟失了的資料檔案。
系統層恢復資料庫執行下的資料檔案過程如下:
1、建立測試表:
SQL> create table t2 tablespace TS_ORA11GR2 as select 1 id from dual;
Table created.
2、刪除表空間TS_ORA11GR2的資料檔案:
[oracle@enmo OCMU]$ rm ts_ora11gr2_01.dbf
[oracle@enmo OCMU]$ ls
control01.ctl example01.dbf redo02.log redo05.log system01.dbf ts_audit01.dbf users01.dbf
control03.ctl MYTEST02.dbf redo03.log redo06.log temp01.dbf tscatalog.dbf
create redo01.log redo04.log sysaux.dbf test01.dbf undotbs01.dbf
3、嘗試建立新表到丟失的資料檔案上:
SQL> create table t3 tablespace TS_ORA11GR2 as select 1 id from dual;
create table t3 tablespace ts_test as select 1 id from dual
*
ERROR at line 1:
ORA-00959: tablespace 'TS_ORA11GR2' does not exist
4、作業系統層檢視控制程式碼:
[oracle@enmo ~]$ ps -ef|grep dbw|grep -v grep
oracle 4610 1 0 16:43 ? 00:00:01 ora_dbw0_OCMU
[oracle@enmo ~]$
total 0
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 9 -> /u01/app/oracle/product/11.2.0/dbhome_1/dbs/hc_OCMU.dat
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 8 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 7 -> /proc/4610/fd
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 6 -> /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 5 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 4 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 3 -> /dev/null
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 271 -> /u01/app/oracle/oradata/mytemp.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 270 -> /u01/app/oracle/oradata/OCMU/temp01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 269 -> /u01/app/oracle/oradata/OCMU/tscatalog.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 268 -> /u01/app/oracle/oradata/OCMU/ts_audit01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 267 -> /u01/app/oracle/oradata/OCMU/MYTEST02.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 266 -> /u01/app/oracle/oradata/OCMU/test01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 265 -> /u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf (deleted)
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 264 -> /u01/app/oracle/oradata/OCMU/example01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 263 -> /u01/app/oracle/oradata/OCMU/users01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 262 -> /u01/app/oracle/oradata/OCMU/sysaux.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 261 -> /u01/app/oracle/oradata/OCMU/undotbs01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 260 -> /u01/app/oracle/oradata/OCMU/system01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 259 -> /u01/app/FRA/control04.ctl
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 258 -> /u01/app/oracle/oradata/OCMU/control03.ctl
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 257 -> /u01/app/oracle/fast_recovery_area/control02.ctl
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 256 -> /u01/app/oracle/oradata/OCMU/control01.ctl
l-wx------ 1 oracle oinstall 64 Oct 12 23:33 2 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 11 -> /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/mesg/oraus.msb
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 10 -> /u01/app/oracle/product/11.2.0/dbhome_1/dbs/lkORA11GR2
l-wx------ 1 oracle oinstall 64 Oct 12 23:33 1 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 0 -> /dev/null
5、根據控制程式碼找回檔案:
cp /proc//4610/fd/265 /u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf
6、檢視檔案位置:
SQL> select file#,status,name from v$datafile;
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
1 SYSTEM
/u01/app/oracle/oradata/OCMU/system01.dbf
2 ONLINE
/u01/app/oracle/oradata/OCMU/undotbs01.dbf
3 ONLINE
/u01/app/oracle/oradata/OCMU/sysaux.dbf
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
4 ONLINE
/u01/app/oracle/oradata/OCMU/users01.dbf
5 ONLINE
/u01/app/oracle/oradata/OCMU/example01.dbf
6 ONLINE
/u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf
7、修改檔案狀態:
SQL> alter database datafile 6 offline;
Database altered.
8、再次檢視:
SQL> select file#,status,name from v$datafile;
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
1 SYSTEM
/u01/app/oracle/oradata/OCMU/system01.dbf
2 ONLINE
/u01/app/oracle/oradata/OCMU/undotbs01.dbf
3 ONLINE
/u01/app/oracle/oradata/OCMU/sysaux.dbf
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
4 ONLINE
/u01/app/oracle/oradata/OCMU/users01.dbf
5 ONLINE
/u01/app/oracle/oradata/OCMU/example01.dbf
6 RECOVER
/u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf
9、恢復檔案:
SQL> recover datafile 6;
Media recovery complete.
10、設定資料檔案online:
SQL> alter database datafile 6 online;
Database altered.
恢復完成。
這時候,記得不要馬上關閉資料庫,這個問題可以從系統層上來恢復丟失了的資料檔案。
系統層恢復資料庫執行下的資料檔案過程如下:
1、建立測試表:
SQL> create table t2 tablespace TS_ORA11GR2 as select 1 id from dual;
Table created.
2、刪除表空間TS_ORA11GR2的資料檔案:
[oracle@enmo OCMU]$ rm ts_ora11gr2_01.dbf
[oracle@enmo OCMU]$ ls
control01.ctl example01.dbf redo02.log redo05.log system01.dbf ts_audit01.dbf users01.dbf
control03.ctl MYTEST02.dbf redo03.log redo06.log temp01.dbf tscatalog.dbf
create redo01.log redo04.log sysaux.dbf test01.dbf undotbs01.dbf
3、嘗試建立新表到丟失的資料檔案上:
SQL> create table t3 tablespace TS_ORA11GR2 as select 1 id from dual;
create table t3 tablespace ts_test as select 1 id from dual
*
ERROR at line 1:
ORA-00959: tablespace 'TS_ORA11GR2' does not exist
4、作業系統層檢視控制程式碼:
[oracle@enmo ~]$ ps -ef|grep dbw|grep -v grep
oracle 4610 1 0 16:43 ? 00:00:01 ora_dbw0_OCMU
[oracle@enmo ~]$
total 0
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 9 -> /u01/app/oracle/product/11.2.0/dbhome_1/dbs/hc_OCMU.dat
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 8 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 7 -> /proc/4610/fd
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 6 -> /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 5 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 4 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 3 -> /dev/null
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 271 -> /u01/app/oracle/oradata/mytemp.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 270 -> /u01/app/oracle/oradata/OCMU/temp01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 269 -> /u01/app/oracle/oradata/OCMU/tscatalog.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 268 -> /u01/app/oracle/oradata/OCMU/ts_audit01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 267 -> /u01/app/oracle/oradata/OCMU/MYTEST02.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 266 -> /u01/app/oracle/oradata/OCMU/test01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 265 -> /u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf (deleted)
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 264 -> /u01/app/oracle/oradata/OCMU/example01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 263 -> /u01/app/oracle/oradata/OCMU/users01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 262 -> /u01/app/oracle/oradata/OCMU/sysaux.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 261 -> /u01/app/oracle/oradata/OCMU/undotbs01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 260 -> /u01/app/oracle/oradata/OCMU/system01.dbf
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 259 -> /u01/app/FRA/control04.ctl
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 258 -> /u01/app/oracle/oradata/OCMU/control03.ctl
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 257 -> /u01/app/oracle/fast_recovery_area/control02.ctl
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 256 -> /u01/app/oracle/oradata/OCMU/control01.ctl
l-wx------ 1 oracle oinstall 64 Oct 12 23:33 2 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 11 -> /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/mesg/oraus.msb
lrwx------ 1 oracle oinstall 64 Oct 12 23:33 10 -> /u01/app/oracle/product/11.2.0/dbhome_1/dbs/lkORA11GR2
l-wx------ 1 oracle oinstall 64 Oct 12 23:33 1 -> /dev/null
lr-x------ 1 oracle oinstall 64 Oct 12 23:33 0 -> /dev/null
5、根據控制程式碼找回檔案:
cp /proc//4610/fd/265 /u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf
6、檢視檔案位置:
SQL> select file#,status,name from v$datafile;
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
1 SYSTEM
/u01/app/oracle/oradata/OCMU/system01.dbf
2 ONLINE
/u01/app/oracle/oradata/OCMU/undotbs01.dbf
3 ONLINE
/u01/app/oracle/oradata/OCMU/sysaux.dbf
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
4 ONLINE
/u01/app/oracle/oradata/OCMU/users01.dbf
5 ONLINE
/u01/app/oracle/oradata/OCMU/example01.dbf
6 ONLINE
/u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf
7、修改檔案狀態:
SQL> alter database datafile 6 offline;
Database altered.
8、再次檢視:
SQL> select file#,status,name from v$datafile;
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
1 SYSTEM
/u01/app/oracle/oradata/OCMU/system01.dbf
2 ONLINE
/u01/app/oracle/oradata/OCMU/undotbs01.dbf
3 ONLINE
/u01/app/oracle/oradata/OCMU/sysaux.dbf
FILE# STATUS
---------- -------
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
4 ONLINE
/u01/app/oracle/oradata/OCMU/users01.dbf
5 ONLINE
/u01/app/oracle/oradata/OCMU/example01.dbf
6 RECOVER
/u01/app/oracle/oradata/OCMU/ts_ora11gr2_01.dbf
9、恢復檔案:
SQL> recover datafile 6;
Media recovery complete.
10、設定資料檔案online:
SQL> alter database datafile 6 online;
Database altered.
恢復完成。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2126307/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【伺服器資料恢復】StorNext檔案系統資料恢復案例伺服器資料恢復
- 【儲存資料恢復】WAFL檔案系統下raid資料恢復案例資料恢復AI
- FastDFS檔案系統遷移和資料恢復AST資料恢復
- Linux伺服器資料恢復案例;ocfs2檔案系統資料恢復Linux伺服器資料恢復
- 【資料庫資料恢復】EXT3檔案系統下MYSQL資料庫恢復案例資料庫資料恢復MySql
- 【伺服器資料恢復】xfs檔案系統資料丟失的資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】reiserfs檔案系統下RAID5資料恢復案例伺服器資料恢復AI
- 【伺服器資料恢復】ZFS檔案系統下伺服器資料恢復案例伺服器資料恢復
- 伺服器資料恢復-ext3檔案系統下oracle資料庫資料恢復案例伺服器資料恢復Oracle資料庫
- 伺服器資料恢復-伺服器XFS檔案系統分割槽資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】Lustre分散式檔案系統RAID5資料恢復案例伺服器資料恢復分散式AI
- 【儲存資料恢復】IBM儲存檔案NTFS系統損壞的資料恢復案例資料恢復IBM
- 【伺服器資料恢復】StorNext檔案系統下raid5資料恢復過程伺服器資料恢復AI
- 【伺服器資料恢復】Zfs檔案系統下誤刪除怎麼恢復資料伺服器資料恢復
- 伺服器資料恢復—重灌系統導致XFS檔案系統分割槽丟失的資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】linux ext3檔案系統下mysql資料庫資料恢復案例伺服器資料恢復LinuxMySql資料庫
- 【北亞資料恢復】zfs檔案系統的伺服器誤刪除的資料恢復資料恢復伺服器
- 【伺服器資料恢復】VMFS檔案系統RAID5硬碟故障的資料恢復案例伺服器資料恢復AI硬碟
- 【伺服器資料恢復】ORACLE-SUN-ZFS檔案系統伺服器資料恢復案例伺服器資料恢復Oracle
- 【伺服器資料恢復】伺服器reiserfs檔案系統損壞的資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】5節點Lustre檔案系統RAID5資料恢復案例伺服器資料恢復AI
- 【伺服器資料恢復】ext3檔案系統下Raid5資料恢復案例伺服器資料恢復AI
- 【伺服器資料恢復】REISERFS檔案系統RAID5崩潰的資料恢復案例伺服器資料恢復AI
- 【伺服器資料恢復】IBM伺服器ext3檔案系統資料恢復案例伺服器資料恢復IBM
- 伺服器資料恢復-斷電導致linux作業系統資料丟失的資料恢復案例伺服器資料恢復Linux作業系統
- 【伺服器資料恢復】Ext4檔案系統執行fsck後檔案掛載報錯的資料恢復伺服器資料恢復
- 【伺服器資料恢復】重灌系統導致XFS檔案系統分割槽無法訪問的資料恢復伺服器資料恢復
- 伺服器資料恢復-UNIX類檔案系統資料災難的資料恢復可能性分析伺服器資料恢復
- macOS Big Sur系統如何恢復丟失的資料檔案?Mac
- 【伺服器資料恢復】HP MSA儲存raid5下vxfs檔案系統資料恢復伺服器資料恢復AI
- 【北亞資料恢復】昆騰系列儲存伺服器StorNext檔案系統資料恢復案例資料恢復伺服器
- 【伺服器資料恢復】xfs檔案系統分割槽消失不可用的資料恢復案例伺服器資料恢復
- 【分散式儲存資料恢復】hbase和hive資料庫底層檔案誤刪的資料恢復案例分散式資料恢復Hive資料庫
- 【伺服器資料恢復】NTFS檔案系統下雙迴圈riad5的資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】Linux伺服器EXT4檔案系統故障的資料恢復案例伺服器資料恢復Linux
- 【伺服器資料恢復】ZFS檔案系統下RAIDZ多塊硬碟離線的資料恢復案例伺服器資料恢復AI硬碟
- 【北亞伺服器資料恢復】伺服器reiserfs檔案系統損壞的資料恢復案例伺服器資料恢復
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 【北亞資料恢復】伺服器raid陣列癱瘓導致ZFS檔案系統元檔案損壞的資料恢復資料恢復伺服器AI陣列