【ORACLE】重寫控制文件

[oracle@rac01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 15 23:45:02 2018

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  784998400 bytes
Fixed Size                    2257352 bytes
Variable Size                  541068856 bytes
Database Buffers          239075328 bytes
Redo Buffers                    2596864 bytes
ORA-00205: error in identifying control file, check alert log for more info



CREATE CONTROLFILE REUSE DATABASE "proc" NORESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '+DATA/proc/onlinelog/group_1.257.965585459'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '+DATA/proc/onlinelog/group_2.258.965585467' SIZE 50M BLOCKSIZE 512,
  GROUP 3 '+DATA/proc/onlinelog/group_3.265.965591745' SIZE 50M BLOCKSIZE 512,
  GROUP 4 '+DATA/proc/onlinelog/group_4.266.965591749' SIZE 50M BLOCKSIZE 512,
  GROUP 5 '+DATA/proc/onlinelog/group_5.268.966135797' SIZE 50M BLOCKSIZE 512,
  GROUP 6 '+DATA/proc/onlinelog/group_6.269.966135801' SIZE 50M BLOCKSIZE 512,
  GROUP 7 '+DATA/proc/onlinelog/group_7.270.966135807' SIZE 50M BLOCKSIZE 512,
  GROUP 8 '+DATA/proc/onlinelog/group_8.271.966135869' SIZE 50M BLOCKSIZE 512,
  GROUP 9 '+DATA/proc/onlinelog/group_9.272.966135875' SIZE 50M BLOCKSIZE 512,
  GROUP 10 '+DATA/proc/onlinelog/group_10.273.966135881'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '+DATA/proc/datafile/SYSAUX.260.965585511',
  '+DATA/proc/datafile/SYSTEM.259.965585479',
   '+DATA/proc/datafile/UNDOTBS1.261.965585527',
  '+DATA/proc/datafile/UNDOTBS2.263.965585563',
   '+DATA/proc/datafile/USERS.264.965585575'
CHARACTER SET AL32UTF8

-- 在節點1的 nomount狀態下執行報錯

ORA-01503: CREATE CONTROLFILE failed
ORA-12720: operation requires database is in EXCLUSIVE mode

-- 解決方案
關閉其餘節點,保留節點1,並修改節點1的參數文件
SQL> alter system set cluster_database=FALSE scope=spfile sid='*';

System altered.

SQL> shutdown immediate

-- 再次啓動數據庫到nomount狀態,再重建控制文件就能夠了
--啓動數據庫到open狀態


SQL> alter database open;

Database altered.

-- 發現asm磁盤組中的控制文件本身生成了


ASMCMD> ls
Current.256.970878297
control02.ctl


-- 啓動節點2,說是不能在獨佔模式下啓動數據庫
SQL> startup
ORA-01102: cannot mount database in EXCLUSIVE mode

-- 由於控制文件重建了,因此要將參數cluster_database改成true,並從spfile生成pifle,並重啓

SQL> alter system set cluster_database=true scope=spfile sid='*';
SQL> create pfile from spfile='注意路徑';
SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup
ORACLE instance started.

Total System Global Area  784998400 bytes
Fixed Size                    2257352 bytes
Variable Size                  541068856 bytes
Database Buffers          239075328 bytes
Redo Buffers                    2596864 bytes
Database mounted.
Database opened.

SQL>  show parameter cluster_database;

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean         TRUE
cluster_database_instances             integer         2

File created.


-- 發現節點能夠啓動到nomount狀態了,但是在mount狀態依然報錯
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  784998400 bytes
Fixed Size                    2257352 bytes
Variable Size                  620760632 bytes
Database Buffers          159383552 bytes
Redo Buffers                    2596864 bytes
SQL>
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info

-- 查看一下告警日誌,能夠看到它還在找原來的控制文件,說明spfile沒有寫入pfile
ORA-00210: cannot open the specified control file
ORA-00202: control file: '+FRA/proc/controlfile/current.256.965585457'
ORA-17503: ksfdopn:2 Failed to open file +FRA/proc/controlfile/current.256.965585457
ORA-15012: ASM file '+FRA/proc/controlfile/current.256.965585457' does not exist

-- 查看spfile發現沒有路徑
SQL> show parameter spfile

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
spfile                                     string

-- 從新設置spfile路徑
SQL> alter system set spfile ='+data/proc/spfileproc.ora';

-- 重啓
SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  784998400 bytes
Fixed Size                    2257352 bytes
Variable Size                  620760632 bytes
Database Buffers          159383552 bytes
Redo Buffers                    2596864 bytes
SQL> alter database mount;

Database altered.

SQL> alter database open;

Database altered.
相關文章
相關標籤/搜索