有關控制檔案的學習(一):

orchidllh發表於2005-04-15

試驗環境:SunOS 5.7 ORACLE 8.1.7.0
首先試驗的是丟失單個控制檔案的情況:

察看控制檔案的情況:
SQL> show parameter control_files

NAME                                 TYPE    VALUE                        
------------------------------------ --------------------------------   ------------------------------
control_files                        string    /home2/oracle/oradata/SID/control01.ctl, /home3/oracle/oradata/SID/control02.ctl

有兩個控制檔案,分別在home2和home3上面,然後將home3上面的那個挪走了。


# mv control02.ctl ../.

sqlplus 的操作沒有發現什麼問題,shutdown資料庫:
SQL> shutdown immediate
ORA-24323: value not allowed
ORA-03113: end-of-file on communication channel

再登陸:
$ sqlplus "/as sysdba"

SQL*Plus: Release 8.1.7.0.0 - Production on Fri Apr 15 17:04:22 2005

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

Connected to an idle instance.

察看bdump目錄下的日誌檔案:
$ cat ckpt_7205.trc
/home2/oracle/SIDin/SID/bdump/ckpt_7205.trc
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
ORACLE_HOME = /home2/oracle/product/817
System name:    SunOS
Node name:      oraad.163.com
Release:        5.7
Version:        Generic_106542-23
Machine:        i86pc
Instance name: SID
Redo thread mounted by this instance: 1
Oracle process number: 5
Unix process pid: 7205, image:
oracle@oraad.163.com (CKPT)

*** 2005-04-15 17:04:11.265
*** SESSION ID:(4.1) 2005-04-15 17:04:11.235
ORA-00206: error in writing (block 19, # blocks 1) of controlfile
ORA-00202: controlfile: '/home3/oracle/oradata/SID/control02.ctl'
ORA-27041: unable to open file
Intel SVR4 UNIX Error: 2: No such file or directory
Additional information: 3
error 221 detected in background process

$ tail -50 alert_SID.log
....
Fri Apr 15 17:04:11 2005
Errors in file /home2/oracle/SIDin/SID/bdump/ckpt_7205.trc:
ORA-00206: error in writing (block 19, # blocks 1) of controlfile
ORA-00202: controlfile: '/home3/oracle/oradata/SID/control02.ctl'
ORA-27041: unable to open file
Intel SVR4 UNIX Error: 2: No such file or directory
Additional information: 3
Fri Apr 15 17:04:11 2005
CKPT: terminating instance due to error 221
Instance terminated by CKPT, pid = 7205

修改$ORACLE_HOME/dbs/initSID.ora
control_files = ("/home2/oracle/oradata/SID/control01.ctl", "/home3/oracle/oradata/SID/control02.ctl")
改成:
control_files = ("/home2/oracle/oradata/SID/control01.ctl")

啟動資料庫:
SQL> startup pfile = $ORACLE_HOME/dbs/initSID.ora
ORACLE instance started.

Total System Global Area  548925600 bytes
Fixed Size                    73888 bytes
Variable Size             260485120 bytes
Database Buffers          286720000 bytes
Redo Buffers                1646592 bytes
Database mounted.
Database opened.

察看引數:
SQL> show parameter control_files

NAME                                 TYPE    VALUE                        
------------------------------------ --------------------------------   ------------------------------
control_files                        string    /home2/oracle/oradata/SID/control01.ctl

已經可以重新啟動了。

將挪出的控制檔案挪回去:
# mv ../control02.ctl .

把引數檔案修改回原來的樣子

重啟資料庫:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup    
ORACLE instance started.

Total System Global Area  548925600 bytes
Fixed Size                    73888 bytes
Variable Size             260485120 bytes
Database Buffers          286720000 bytes
Redo Buffers                1646592 bytes
ORA-00214: controlfile '/home2/oracle/oradata/SID/control01.ctl' version 2069
inconsistent with file '/home3/oracle/oradata/SID/control02.ctl' version 2061

提示兩個控制檔案的版本不同。
呵呵,原來這個已經不好使了。
將home2的控制檔案拷貝到home3:
$ cp /home2/oracle/oradata/SID/control01.ctl /home3/oracle/oradata/SID/control02.ctl

再重啟資料庫:
SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area  548925600 bytes
Fixed Size                    73888 bytes
Variable Size             260485120 bytes
Database Buffers          286720000 bytes
Redo Buffers                1646592 bytes
Database mounted.
Database opened.

啟動成功。
察看初始化引數:
SQL> show parameter control_files

NAME                                 TYPE    VALUE                        
------------------------------------ --------------------------------   ------------------------------
control_files                        string    /home2/oracle/oradata/SID/control01.ctl, /home3/oracle/oradata/SID/control02.ctl

所以,在有控制檔案的情況下,增加一個控制檔案是很簡單的:
shutdown資料庫->cp control01.ctl control03.ctl->修改init.ora->startup->ok

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

相關文章