作为dba,我们都知道控制文件的重要性,控制文件一旦损坏或者丢失,就需要重建控制文件,为避免控制文件单点故障,我们一般会增加控制文件至2个或者3个,这几个控制文件互为镜像。那么接下就为大家演示一下增加控制文件的方法。
一、停止数据库集群,在此使用srvctl命令
[oracle@node2]$ srvctl stop instance -d racdb -i racdb1,racdb2 -o immediate
停库之后,查看crs状态
[oracle@node2 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM2.asm application ONLINE ONLINE node1
ora....E1.lsnr application ONLINE ONLINE node1
ora.node1.gsd application ONLINE ONLINE node1
ora.node1.ons application ONLINE ONLINE node1
ora.node1.vip application ONLINE ONLINE node1
ora....SM1.asm application ONLINE ONLINE node2
ora....E2.lsnr application ONLINE ONLINE node2
ora.node2.gsd application ONLINE ONLINE node2
ora.node2.ons application ONLINE ONLINE node2
ora.node2.vip application ONLINE ONLINE node2
ora.racdb.db application OFFLINE OFFLINE
ora....b1.inst application OFFLINE OFFLINE
ora....b2.inst application OFFLINE OFFLINE
二、启动数据库到nomount状态
[oracle@node2 ~]$ srvctl start database -d racdb -o nomount
启动之后,查看数据库状态
SQL> select INSTANCE_NAME,HOST_NAME,STATUS from gv$instance;
INSTANCE_NAME HOST_NAME STATUS
---------------- -------------------- ------------
racdb1 node2.ocean.com STARTED
racdb2 node1.ocean.com STARTED
三、登录到rman,从现有的控制文件复制出新的控制文件
[oracle@node2 ~]$ rman target / nocatalog
RMAN> restore controlfile to '+DATA/racdb/controlfile/control_2' from '+DATA/racdb/controlfile/current.256.842559447';
Starting restore at 20-MAR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 instance=racdb1 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 20-MAR-14
四、登录到数据库,修改参数
SQL> alter system set control_files='+DATA/racdb/controlfile/control_2','+DATA/racdb/controlfile/current.256.842559447'
scope=spfile;
System altered.
五、再次停止数据库,因为control_files静态参数,修改之后要重启实例才能生效。
[oracle@node2 ~]$ srvctl stop instance -d racdb -i racdb1,racdb2 -o immediate
六、启动集群数据库
[oracle@node2 ~]$ srvctl start database -d racdb
七、验证结果,查看control_files参数
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string +DATA/racdb/controlfile/contro
l_2, +DATA/racdb/controlfile/c
urrent.256.842559447
此时我们已经增加了control_2这个控制文件。
--转自