RAC下新增控制檔案

煙花丶易冷發表於2017-08-16
一、檢視控制檔案和spfile檔案位置
[root@node1 ~]# su - oracle
[oracle@node1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on 星期三 8月 16 09:58:38 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> show parameter spf 

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATADG/prod/spfileprod.ora
SQL> show parameter contr


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +DATADG/prod/controlfile/curre
                                                 nt.260.947712913
control_management_pack_access       string      DIAGNOSTIC+TUNING

二、關閉兩個節點
[oracle@node2 /]srvctl stop database -d PROD
[oracle@node1 /]srvctl stop database -d PROD
三、在其中一節點利用RMAN複製控制檔案
[oracle@node1 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on 星期三 8月 16 10:01:45 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area    1252663296 bytes

Fixed Size                     2252824 bytes
Variable Size                922750952 bytes
Database Buffers             318767104 bytes
Redo Buffers                   8892416 bytes

RMAN> restore controlfile to '+DATADG' from '+DATADG/PROD/CONTROLFILE/Current.260.947712913';   

Starting restore at 16-8月 -17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=15 instance=PROD1 device type=DISK

channel ORA_DISK_1: copied control file copy
Finished restore at 16-8月 -17

RMAN> exit

Recovery Manager complete.

四、確定新複製的控制檔名
[grid@node2 ~]$ asmcmd
ASMCMD> cd DATADG
ASMCMD> ls
PROD/
ASMCMD> cd PROD
ASMCMD> ls       
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileprod.ora
ASMCMD> cd CONTROLFILE
ASMCMD> ls
Current.260.947712913
current.272.952164187
五、修改spfile檔案
SQL> create pfile='/u01/0816.ora' from spfile='+DATADG/prod/spfileprod.ora';

File created.
[oracle@node1 u01]$ vi 0816.ora
*.control_files='+DATADG/prod/controlfile/current.260.947712913'
*.control_files='+DATADG/prod/controlfile/current.272.952164187'


SQL> create spfile='+DATADG/prod/spfileprod.ora' from pfile='/u01/0816.ora';


File created.
六、修改完成,檢視
[oracle@node1 ~]$ srvctl start database -d PROD 
[oracle@node1 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on 星期三 8月 16 10:09:39 2017


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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options


SQL> show parameter contr


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +DATADG/prod/controlfile/curre
                                                 nt.260.947712913, +DATADG/prod
                                                 /controlfile/current.272.95216
                                                 4187
control_management_pack_access       string      DIAGNOSTIC+TUNING
SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATADG/prod/spfileprod.ora

注意:複製控制檔案之前要關閉資料庫,否則會出現控制檔案版本不一致的報錯
還有另外一種方式,在關庫情況下直接在ASM裡面複製,但是控制檔名字不能和ASM命名機制相同,
ASMCMD> cp current.272.952164187 current.272.952164188
copying +DATADG/PROD/CONTROLFILE/current.272.952164187 -> +DATADG/PROD/CONTROLFILE/current.272.952164188
ASMCMD-8016: copy source '+DATADG/PROD/CONTROLFILE/current.272.952164187' and target '+DATADG/PROD/CONTROLFILE/current.272.952164188' failed
ORA-15056: additional error message
ORA-15046: ASM file name '+DATADG/PROD/CONTROLFILE/current.272.952164188' is not in single-file creation form
ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 415
ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute)
ASMCMD> cp current.272.952164187 current.272.95216418744444
copying +DATADG/PROD/CONTROLFILE/current.272.952164187 -> +DATADG/PROD/CONTROLFILE/current.272.95216418744444
然後再修改spfile檔案即可。建議使用第一種方法





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

相關文章