oracle之 RAC 11G ASM下控制文件多路复用

时间:2024-11-15 16:37:25

如果数据库仅有一组control file文件,需要添加一组或者多组,保证一组文件损坏或者丢失导致数据库宕机。

-- 环境说明
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

SQL> show parameter cluster;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string

0、记录现有控制文件路径

SQL>select name from v$controlfile;SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DATA/devdb/controlfile/current.260.936769367
+FLASH/devdb/controlfile/current.256.936769367

1、关闭两个节点

$ srvctl stop database -d devdb

2、在其中一个节点上启动rman

[oracle@node1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Tue Dec 27 16:59:10 2016

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

connected to target database (not started)

3、将数据库启动到nomount状态下

RMAN> startup nomount;

Oracle instance started

Total System Global Area 4275781632 bytes

Fixed Size 2260088 bytes
Variable Size 989856648 bytes
Database Buffers 3271557120 bytes
Redo Buffers 12107776 bytes

4、采用restore拷贝一份controlfile到新路径

RMAN> restore controlfile to '+FLASH/devdb/controlfile/current.256.936769368' from '+DATA/devdb/controlfile/current.260.936769367';

Starting restore at 27-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=50 instance=orcl1 device type=DISK

channel ORA_DISK_1: copied control file copy
Finished restore at 27-DEC-16

说明:’+FLASH/devdb/controlfile/current.256.936769368’是拷贝的新的控制文件,
如果asm自动管理的,可能名字不会按照你的命名,需要确定下新的文件名字。

ASMCMD> pwd
+FLASH/devdb/controlfile/
ASMCMD> ls
current.303.956019293 > 跟你指定的不一样

5. sqlplus 中 修改控制文件路径, 修改完成后,关闭数据库
SQL> alter system set control_files='+DATA/devdb/controlfile/current.260.936769367','+FLASH/devdb/controlfile/current.256.936769367','+FLASH/devdb/controlfile/current.303.956019293' scope=spfile sid='*';

SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.

6、启动数据库

[grid@node1 oracle]$ srvctl start database -d devdb

7、验证

SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA/devdb/controlfile/current.260.936769367
+FLASH/devdb/controlfile/current.256.936769367
+FLASH/devdb/controlfile/current.303.956019293