Oracle RAC CRS、OCR、Voting数据库集群破坏重建的详细过程

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:314

Oracle RAC CRS、OCR、Voting数据库集群破坏重建的详细过程(重新配置ORACLE RAC)

1、主机名:
#Public Network - (eth0)
192.168.10.11 rac1
192.168.10.12 rac2
#Private Interconnect - (eth1)
10.10.10.11 rac1priv
10.10.10.12 rac2priv
#Public Virtual IP (VIP) addresses - (eth0)
192.168.10.21 rac1vip
192.168.10.22 rac2vip

2、生成listener的cap文件,用于重建ocr后注册监听(也可以用后面的netca)
crs_stat -p ora.rac1.LISTENER_RAC1.lsnr > /oracle/backup/ora.rac1.LISTENER_RAC1.lsnr.cap
crs_stat -p ora.rac2.LISTENER_RAC2.lsnr > /oracle/backup/ora.rac2.LISTENER_RAC2.lsnr.cap

3、停掉所有的资源,备份ocr、votingdisk并重新格式化
crs_stop -all
crsctl stop crs
备份OCR:
[root@rac1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 104216
Used space (kbytes) : 4640
Available space (kbytes) : 99576
ID : 1718671696
Device/File Name : /dev/raw/raw1
Device/File integrity check succeeded
Device/File not configured
Cluster registry integrity check succeeded

ocrconfig -export /oracle/backup/ocr_20100531.bak
[root@rac1 ~]# ocrconfig -export /oracle/backup/ocr_20100531.bak
备份votedisk:
[root@rac1 ~]# crsctl query css votedisk
0. 0 /dev/raw/raw2
located 1 votedisk(s).

破坏OCR,Voting磁盘
在两边用root执行:
/oracle/app/crs/install/rootdelete.sh
/oracle/app/crs/install/rootdeinstall.sh
[root@rac1 ~]# dd if=/dev/raw/raw2 f=/oracle/backup/votedisk_20100531.bak
208864+0 records in
208864+0 records out
106938368 bytes (107 MB) copied, 78.8653 seconds, 1.4 MB/s
[root@rac1 ~]#
[root@rac1 ~]# dd if=/dev/zero f=/dev/raw/raw2 bs=1024000 count=120
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.00235728 seconds, 434 kB/s
[root@rac1 ~]# dd if=/dev/zero f=/dev/raw/raw1 bs=1024000 count=120
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.0335442 seconds, 30.5 kB/s

在每个节点依次执行(root 用户):
如果是10.2.0.1 版本,在最后一个节点上执行的时候会因为静默vipca的bug抛出异常,在该节点上图形化
界面调用VIPCA。
/oracle/app/crs/root.sh
Checking to see if Oracle CRS stack is already configured
Setting the permissions on OCR backup directory
Setting up NS directories
Oracle Cluster Registry configuration upgraded successfully
WARNING: directory '/oracle/app' is not owned by root
WARNING: directory '/oracle' is not owned by root
Successfully accumulated necessary OCR keys.
Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897.
node :
node 1: rac1 rac1priv rac1
node 2: rac2 rac2priv rac2
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Now formatting voting device: /dev/raw/raw2
Format of 1 voting devices complete.
Startup will be queued to init within 30 seconds.
Adding daemons to inittab
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
rac1
rac2
CSS is active on all nodes.
Waiting for the Oracle CRSD and EVMD to start
Oracle CRS stack installed and running under init(1M)
Running vipca(silent) for configuring nodeapps
Creating VIP application resource on (2) nodes...
Creating GSD application resource on (2) nodes...
Creating ONS application resource on (2) nodes...
Starting VIP application resource on (2) nodes...
Starting GSD application resource on (2) nodes...
Starting ONS application resource on (2) nodes...
Done
如果报错:
[root@rac1 backup]# /oracle/app/crs/install/rootconfig
Checking to see if Oracle CRS stack is already configured
Oracle CRS stack is already configured and will be running under init(1M)
则删除文件:每台机器上都删除rm /etc/oracle/scls_scr/rac1/oracle/cssfatal 这根文件
[oracle@rac1 admin]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2

--------以下均用oracle用户操作

7、使用oifcfg配置db使用的共有、私连网络
oifcfg setif -global eth0/192.168.10.0:public
oifcfg setif -global eth1/10.10.10.0:cluster_interconnect
[oracle@rac2 bin]$ oifcfg getif
eth0 192.168.10.0 global public
eth1 10.10.10.0 global cluster_interconnect

8、注册其他资源到集群(oracle用户)
①注册监听到集群
修改监听配置文件lisntener.ora并编辑生成的cap文件(改名),更改其中用到的hostname.
ora.rac1.LISTENER_rac1.lsnr.cap
ora.rac2.LISTENER_rac2.lsnr.cap
crs_register ora.rac1.LISTENER_RAC1.lsnr -dir /oracle/backup
crs_register ora.rac2.LISTENER_RAC2.lsnr -dir /oracle/backup
[oracle@rac1 backup]$ srvctl start listener -n rac1
[oracle@rac1 backup]$ srvctl start listener -n rac2
[oracle@rac1 backup]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
删除可用
[root@rac1 backup]# crs_unregister ora.rac1.LISTENER_RAC1.lsnr
[root@rac1 backup]# crs_unregister ora.rac2.LISTENER_RAC2.lsn
或者使用netca图形化界面来配置监听。

②注册ASM实例到集群(如果使用ASM)
srvctl add asm -n rac1 -i +ASM1 -o $ORACLE_HOME
srvctl add asm -n rac2 -i +ASM2 -o $ORACLE_HOME
[oracle@rac1 backup]$ srvctl start asm -n rac1
[oracle@rac1 backup]$ srvctl start asm -n rac2
[oracle@rac1 backup]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
③注册instance/database到集群
srvctl add database -d racdb -o $ORACLE_HOME
srvctl add instance -d racdb -i racdb1 -n rac1
srvctl add instance -d racdb -i racdb2 -n rac2
srvctl config database -d racdb
srvctl start database -d racdb
[root@rac1 backup]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
ora.racdb.db application ONLINE ONLINE rac1
ora....b1.inst application ONLINE ONLINE rac1
ora....b2.inst application ONLINE ONLINE rac2

4.注册services到集群
(命令注册不能用与DB相同的service名)
srvctl add service -d -s -r "" [-a ""] [-P ]
[root@rac1 backup]# srvctl add service -h
Usage: srvctl add service -d -s -r "" [-a ""] [-P ]
-d Unique name for the database
-s Service name
-r "" List of preferred instances
-a "" List of available instances
-P TAF policy (NONE, BASIC, or PRECONNECT)
Usage: srvctl add service -d -s -u {-r "" | -a ""}
-d Unique name for the database
-s Service name
-u Add a new instance to service configuration
-r Name of new preferred instance
-a Name of new available instance
-h Print usage
/oracle/app/crs/bin/srvctl add service -d racdb -s racdb-r racdb1 -a racdb2 -P BASIC
/oracle/app/crs/bin/srvctl add service -d racdb -s racdb_s -r racdb1,racdb2 -P BASIC
(建议)
[root@rac2 ~]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
ora.racdb.db application ONLINE ONLINE rac1
ora....b1.inst application ONLINE ONLINE rac1
ora....b2.inst application ONLINE ONLINE rac2
ora....db_s.cs application ONLINE ONLINE rac1
ora....db1.srv application ONLINE ONLINE rac1
ora....db2.srv application ONLINE ONLINE rac2
与之前不同service名后,则数据库会自己变为新的service名字,如下:
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string racdb_s
###############################################
5、更改tnsnams名字即可

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】