[oracle]undo表空間出錯,導致資料庫例項無法開啟

zad800發表於2010-08-31

         今天老師幫某客戶解決了資料庫例項無法開啟的情況,出現此故障是由於undo表空間損壞所致。

         老師問我們,如何解決此問題,本人隨口一答,新建undo表空間,然後把undo_tablespace引數指向新的表空間即可。後來才反應過來,資料庫在未open的情況下,是無法新建表空間操作的,頓時覺得很囧。

         廢話不說了,下面演示針對undo表空間出錯的情況下,如何開啟資料庫例項。

         解決思路:將UNDO_MANAGEMENT修改為manul,下次啟動資料庫時,則系統使用的是system表空間的回滾段(rollback segment)。

1、  模擬undo表空間出錯的情況,將該表空間名字修改為一個錯誤的名字。則下次啟動使用spfile時,會因為無法找到該表空間而報錯。

SQL> alter system set undo_tablespace=undotbs11 scope=spfile;

System altered.

2、重啟資料庫例項,果然出現了錯誤(老師所述的錯誤是由於undo表空間出現了壞塊,不過解決這種問題的辦法都是相同的):

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             121636432 bytes

Database Buffers          159383552 bytes

Redo Buffers                2973696 bytes

Database mounted.

ORA-01092: ORACLE instance terminated. Disconnection forced

3、這種情況下,由於資料庫無法變成open狀態,因此是無法開啟spfile的,我們只能通過pfile來開啟資料庫。

3.1、新建pfile

SQL> create pfile from spfile;

        

File created.

3.2、編輯pfile,我們將undo_management的值由AUTO修改為manual

[oracle@localhost dbs]$ cd $ORACLE_HOME/dbs

[oracle@localhost dbs]$ vi initorcl.ora 

*.undo_management='AUTO'  à                    *.undo_management='manual'

         4、下面,我們採用pfile來啟動資料庫:

SQL> shutdown immediate

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist

Linux Error: 2: No such file or directory

SQL> startup pfile=/opt/ora10g/product/10.2.0/db_1/dbs/initorcl.ora

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             121636432 bytes

Database Buffers          159383552 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL>

 

5、現在資料庫例項開啟了,我們再建立spfile,讓資料庫下次啟動時,自動讀取spfile

SQL> show parameter spfile

NAME                                 TYPE        VALUE

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

spfile                               string

SQL> create spfile from pfile;

File created.

 

SQL> startup force

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             121636432 bytes

Database Buffers          159383552 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> show parameter spfile

NAME       TYPE              VALUE

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

spfile        string                    /opt/ora10g/product/10.2.0/db_1/dbs/spfileorcl.ora

6、現在我們再將相應的引數修改回去,系統表空間的資源是有限的,我們最好不要使用回滾段。

SQL> show parameter undo

NAME                                 TYPE        VALUE

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

undo_management                      string      MANUAL

undo_retention                       integer     900

undo_tablespace                      string      UNDOTBS11

SQL> alter system set undo_management=auto scope=spfile;

System altered.

 

SQL> alter system set undo_tablespace=UNDOTBS1 scope=spfile;

System altered.

 

SQL> startup force

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             125830736 bytes

Database Buffers          155189248 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> show parameter undo

NAME                                 TYPE        VALUE

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

undo_management                      string      AUTO

undo_retention                       integer     900

undo_tablespace                      string      UNDOTBS1

 

至此,undo表空間損壞,導致資料庫例項無法開啟的問題的基本解決思路已經展示完成。有興趣的讀者,還可以自行再建立新的undo表空間,並且將undo_tablespace的引數值修改為此表空間名

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

相關文章