一次恢復oracle的嘗試(轉)

BSDLite發表於2007-08-16
一次恢復oracle的嘗試(轉)[@more@]偶的一臺測試機上裝了個oracle815 for solaris的版本。因為也是測試,所以就沒怎麼管。

環境如下:
Oracle815
歸檔模式。

問題如下:
oracle裝在/opt/oracle下,但是有一些資料檔案放在了/export/home/oracle下面。
因為磁碟故障,/export/home分割槽不可使用了。
只是後啟動oracle後報錯說幾個資料檔案不可用了。





恢復過程:

出錯:
SQL> startup
ORACLE instance started.

Total System Global Area 72007056 bytes
Fixed Size 64912 bytes
Variable Size 54992896 bytes
Database Buffers 16777216 bytes
Redo Buffers 172032 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 10 - see DBWR trace file
ORA-01110: data file 10: '/export/home/oracle/DATA/DISK4/data01.dbf'

提示找不到資料檔案。
經過查詢,發現/export/home原來掛載的檔案都已經消失。

恢復:

/opt/oracle/oradata/dbora815/system01.dbf SYSTEM
/opt/oracle/oradata/dbora815/oemrep01.dbf ONLINE
/opt/oracle/oradata/dbora815/rbs01.dbf ONLINE
/opt/oracle/oradata/dbora815/temp01.dbf ONLINE
/opt/oracle/oradata/dbora815/users01.dbf ONLINE
/opt/oracle/oradata/dbora815/indx01.dbf ONLINE
/opt/oracle/oradata/dbora815/app_data_01.dbf ONLINE
/opt/oracle/oradata/dbora815/app_data_02.dbf ONLINE
/opt/oracle/oradata/dbora815/query01.dbf ONLINE
/export/home/oracle/DATA/DISK4/data01.dbf ONLINE
/export/home/oracle/DATA/DISK5/data02.dbf ONLINE
/export/home/oracle/DATA/DISK3/indx01.dbf ONLINE
/export/home/oracle/DATA/DISK1/ronly.dbf ONLINE

發現有四個檔案在/export/home目錄下。

先把這四個檔案offline.

SQL> alter database datafile '/export/home/oracle/DATA/DISK4/data01.dbf' offline;
Database altered.
SQL> alter database datafile '/export/home/oracle/DATA/DISK5/data02.dbf' offline;
Database altered.
SQL> alter database datafile '/export/home/oracle/DATA/DISK3/indx01.dbf' offline;
Database altered.
SQL> alter database datafile '/export/home/oracle/DATA/DISK1/ronly.dbf' offline;
Database altered.

然後恢復

SQL> alter database create datafile '/export/home/oracle/DATA/DISK4/data01.dbf';
alter database create datafile '/export/home/oracle/DATA/DISK4/data01.dbf'
*
ERROR at line 1:
ORA-01119: error in creating database file '/export/home/oracle/DATA/DISK4/data01.dbf'
ORA-27040: skgfrcre: create error, unable to create file
SVR4 Error: 2: No such file or directory

錯了?查一下

bash-2.03$ oerr ora 01119
01119, 00000, "error in creating database file '%s'"
// *Cause: Usually due to not having enough space on the device.
// *Action:

原來是這個檔案的上一級目錄也不存在,建上了以後再做。

SQL> alter database create datafile '/export/home/oracle/DATA/DISK4/data01.dbf';
Database altered.
SQL> alter database create datafile '/export/home/oracle/DATA/DISK5/data02.dbf';
Database altered.
SQL> alter database create datafile '/export/home/oracle/DATA/DISK3/indx01.dbf';
Database altered.
SQL> alter database create datafile '/export/home/oracle/DATA/DISK1/ronly.dbf';
Database altered.

做一下recover

SQL> recover datafile '/export/home/oracle/DATA/DISK1/ronly.dbf'
SQL> recover datafile '/export/home/oracle/DATA/DISK3/indx01.dbf'
SQL> recover datafile '/export/home/oracle/DATA/DISK5/data02.dbf';
SQL> recover datafile '/export/home/oracle/DATA/DISK4/data01.dbf'

將datafile上線

SQL> alter database datafile '/export/home/oracle/DATA/DISK1/ronly.dbf' online;
Database altered.
SQL> alter database datafile '/export/home/oracle/DATA/DISK3/indx01.dbf' online;
Database altered.
SQL> alter database datafile '/export/home/oracle/DATA/DISK5/data02.dbf' online;
Database altered.
SQL> alter database datafile '/export/home/oracle/DATA/DISK4/data01.dbf' online;
Database altered.

發現磁碟不夠了,因為現在這些新建的檔案都是在/分割槽下,本來/opt就很大了。
好吧,將這些個資料檔案重新resize一下,每個20M.

先open資料庫

SQL> alter database open;
Database altered.

resize

alter database datafile '/export/home/oracle/DATA/DISK1/ronly.dbf' resize 20m;
Database altered.
alter database datafile '/export/home/oracle/DATA/DISK3/indx01.dbf' resize 20m;
Database altered.
alter database datafile '/export/home/oracle/DATA/DISK5/data02.dbf' resize 20m;
Database altered.
alter database datafile '/export/home/oracle/DATA/DISK4/data01.dbf' resize 20m;
Database altered.

呵呵,成了。
可是偶不知道,這個是不是可以把資料都完全恢復。雖然有歸檔檔案。


補充:如果有歸檔檔案,而沒有備份檔案,丟失資料檔案也是可以把資料完全恢復的(當然丟失system資料檔案了就不能恢復了)。
使用:
alter database create datafile '/export/home/oracle/DATA/DISK5/data02.dbf' as '/export/home/oracle/DATA/DISK5/data02.dbf';

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617542/viewspace-961503/,如需轉載,請註明出處,否則將追究法律責任。

相關文章