ORA-01157&ORA-01110故障解決

來源:互聯網
上載者:User

ORA-01157&ORA-01110故障解決

今天在啟動虛擬機器測試庫時,資料庫報了ORA-01157和ORA-01110錯誤,提示找不到一個資料檔案。我一看檔案名稱就知道問題在哪兒了,是另一台虛擬機器沒有啟動導致的,因為這個資料庫通過dnfs建立了一個“遠程”資料表空間。由於暫時不想啟動那台虛擬機器(節省記憶體),乾脆就把這個資料表空間刪除,熟悉一下trouble-shooting的過程。

1.環境準備
我們在Oracle11g中進行測試。

SQL>

SQL> select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

PL/SQL Release 11.2.0.3.0 - Production

CORE 11.2.0.3.0 Production

TNS for Linux: Version 11.2.0.3.0 - Production

NLSRTL Version 11.2.0.3.0 - Production

SQL>

2.啟動資料庫報錯

在啟動資料庫過程中,報了ORA-01157和ORA-01110錯誤,提示找不到資料檔案。

SYS@HOEGH>startup
 
ORACLE instance started.

Total System Global Area 941600768 bytes

Fixed Size 1348860 bytes

Variable Size 524290820 bytes

Database Buffers 411041792 bytes

Redo Buffers 4919296 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 9 - see DBWR trace file

ORA-01110: data file 9: \'/u02/oradata/HOEGH/test_tbs01.dbf\'

SYS@HOEGH>select status from v$instance;

STATUS

------------

MOUNTED

SYS@HOEGH>
由於另外一台虛擬機器沒有啟動,資料庫在啟動過程中後台進程不能找到相應的資料檔案或者不能鎖定相應的資料檔案,資料庫將禁止訪問這些資料檔案而其他的資料檔案則沒有影響。ORA-01157錯誤一般和ORA-01110錯誤一起出現。

 
3.重啟資料庫到mount狀態,刪除資料檔案
啟動資料庫時,nomount狀態讀取參數檔案,mount狀態讀取控制檔案,在mount狀態下可以刪除資料檔案。

SYS@HOEGH>
 
SYS@HOEGH>startup nomount

ORACLE instance started.

Total System Global Area 941600768 bytes

Fixed Size 1348860 bytes

Variable Size 524290820 bytes

Database Buffers 411041792 bytes

Redo Buffers 4919296 bytes

SYS@HOEGH>

SYS@HOEGH>

SYS@HOEGH>alter database mount;

Database altered.

SYS@HOEGH>alter database datafile \'/u02/oradata/HOEGH/test_tbs01.dbf\' offline drop;

Database altered.
 
4.開啟資料庫,刪除資料表空間
啟動資料庫到open狀態,尋找資料檔案對應的資料表空間名稱;然後,刪除資料表空間。

SYS@HOEGH>alter database open;
 

Database altered.

SYS@HOEGH>

SYS@HOEGH>select file_id,tablespace_name from dba_data_files;

  FILE_ID TABLESPACE_NAME

---------- ------------------------------

        4 USERS

        3 UNDOTBS1

        2 SYSAUX

        1 SYSTEM

        5 TEST1

        6 TEST2

        7 TEST3

        8 TEST

        9 TEST_TBS

9 rows selected.

SYS@HOEGH>col file_name for a50

SYS@HOEGH>col file_id for 99

SYS@HOEGH>col tablespace_name for a10

SYS@HOEGH>col status for a10

SYS@HOEGH>col online_status for a20

SYS@HOEGH>select file_name,file_id,TABLESPACE_NAME,STATUS,ONLINE_STATUS from dba_data_files;

FILE_NAME FILE_ID TABLESPACE STATUS ONLINE_STATUS

-------------------------------------------------- ------- ---------- ---------- --------------------

/u01/app/oracle/oradata/HOEGH/users01.dbf 4 USERS AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/undotbs01.dbf 3 UNDOTBS1 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/sysaux01.dbf 2 SYSAUX AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/system01.dbf 1 SYSTEM AVAILABLE SYSTEM

/u01/app/oracle/oradata/HOEGH/TEST101.dbf 5 TEST1 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/TEST201.dbf 6 TEST2 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/TEST301.dbf 7 TEST3 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/test.dbf 8 TEST AVAILABLE ONLINE

/u02/oradata/HOEGH/test_tbs01.dbf 9 TEST_TBS AVAILABLE RECOVER

9 rows selected.

SYS@HOEGH>drop tablespace TEST_TBS including contents;

Tablespace dropped.

SYS@HOEGH>

SYS@HOEGH>select file_name,file_id,TABLESPACE_NAME,STATUS,ONLINE_STATUS from dba_data_files;

FILE_NAME FILE_ID TABLESPACE STATUS ONLINE_STATUS

-------------------------------------------------- ------- ---------- ---------- --------------------

/u01/app/oracle/oradata/HOEGH/users01.dbf 4 USERS AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/undotbs01.dbf 3 UNDOTBS1 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/sysaux01.dbf 2 SYSAUX AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/system01.dbf 1 SYSTEM AVAILABLE SYSTEM

/u01/app/oracle/oradata/HOEGH/TEST101.dbf 5 TEST1 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/TEST201.dbf 6 TEST2 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/TEST301.dbf 7 TEST3 AVAILABLE ONLINE

/u01/app/oracle/oradata/HOEGH/test.dbf 8 TEST AVAILABLE ONLINE

8 rows selected.

SYS@HOEGH>
 
5.重啟資料庫
在進行上述操作後,重啟資料庫,確保資料庫能夠正常開啟。

SYS@HOEGH>
 
SYS@HOEGH>shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SYS@HOEGH>

SYS@HOEGH>

SYS@HOEGH>startup

ORACLE instance started.

Total System Global Area 941600768 bytes

Fixed Size 1348860 bytes

Variable Size 511707908 bytes

Database Buffers 423624704 bytes

Redo Buffers 4919296 bytes

Database mounted.

Database opened.

SYS@HOEGH>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.