一次恢復oracle的嘗試
2024-08-29 13:39:08
供稿:網友
 
             偶的一臺測試機上裝了個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';