白天和黑夜只交替没交换无法想像对方的世界
分类: Oracle
2011-09-27 00:46:27
ORACLE RAC--webapps测试
本实验将利用oracle clusterware 配置一个高可用的web网站集群系统,整个集群由两个节点组成,web网站使用apache搭建,环境如下图所示。集群的任何一节点出现宕机现象,都不会影响web站点的高可用性,web服务会自动转移到另外一个节点上运行。
1.在两节点上使用yum安装httpd服务:
[oracle@rac1 ~]# yum –y install httpd
[oracle@rac2 ~]# yum –y install httpd
2.创建web_vip的profile:
[oracle@rac1 ~]$ cd /u01/oracle/product/crs/crs/public
[oracle@rac1 public]$ ls
action_scr.scr ora.rac1.LISTENER_RAC1.lsnr.cap ora.rac2.LISTENER_RAC2.lsnr.cap
[oracle@rac1 public]$ crs_profile -create racdb1_vip -t application -a /u01/oracle/product/crs/bin/usrvip -o oi=eth0,ov=172.21.1.82,on=255.255.255.0
[oracle@rac1 public]$ ll
total 16
-rw-rw---- 1 oracle oinstall 3396 Aug 3 2004 action_scr.scr
-rw-r----- 1 oracle oinstall 828 Sep 20 16:57 ora.rac1.LISTENER_RAC1.lsnr.cap
-rw-r----- 1 oracle oinstall 828 Sep 20 16:57 ora.rac2.LISTENER_RAC2.lsnr.cap
-rw-r--r-- 1 oracle oinstall 788 Sep 26 05:07 racdb1_vip.cap
[oracle@rac1 public]$ strings racdb1_vip.cap
NAME=racdb1_vip
TYPE=application
ACTION_SCRIPT=/u01/oracle/product/crs/bin/usrvip
ACTIVE_PLACEMENT=0
AUTO_START=restore
CHECK_INTERVAL=60
DESCRIPTION=racdb1_vip
FAILOVER_DELAY=0
FAILURE_INTERVAL=0
FAILURE_THRESHOLD=0
HOSTING_MEMBERS=
OPTIONAL_RESOURCES=
PLACEMENT=balanced
REQUIRED_RESOURCES=
RESTART_ATTEMPTS=1
SCRIPT_TIMEOUT=60
START_TIMEOUT=0
STOP_TIMEOUT=0
UPTIME_THRESHOLD=7d
USR_ORA_ALERT_NAME=
USR_ORA_CHECK_TIMEOUT=0
USR_ORA_CONNECT_STR=/ as sysdba
USR_ORA_DEBUG=0
USR_ORA_DISCONNECT=false
USR_ORA_FLAGS=
USR_ORA_IF=eth0
USR_ORA_INST_NOT_SHUTDOWN=
USR_ORA_LANG=
USR_ORA_NETMASK=255.255.255.0
USR_ORA_OPEN_MODE=
USR_ORA_OPI=false
USR_ORA_PFILE=
USR_ORA_PRECONNECT=none
USR_ORA_SRV=
USR_ORA_START_TIMEOUT=0
USR_ORA_STOP_MODE=immediate
USR_ORA_STOP_TIMEOUT=0
USR_ORA_VIP=172.21.1.82
3.注册web_vip:
[oracle@rac1 public]$ crs_register racdb1_vip
4.设置权限,需要使用root身份:
[root@rac1 bin]# /u01/oracle/product/crs/bin/crs_setperm racdb1_vip -o root
[root@rac1 bin]# /u01/oracle/product/crs/bin/crs_setperm racdb1_vip -u user:oracle:r-x
5..测试这个vip创建是否成功:
先查看VIP启动前的IP地址:
[oracle@rac1 public]$ /sbin/ip ad sh
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:ad:6e:57 brd ff:ff:ff:ff:ff:ff
inet 172.21.1.30/24 brd 172.21.1.255 scope global eth0
inet 172.21.1.80/24 brd 172.21.1.255 scope global secondary eth0:1
inet6 fe80::20c:29ff:fead:6e57/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
link/ether 00:0c:29:ad:6e:61 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.11/24 brd 10.0.0.255 scope global eth1
inet6 fe80::20c:29ff:fead:6e61/64 scope link
valid_lft forever preferred_lft forever
4: sit0:
link/sit 0.0.0.0 brd 0.0.0.0
在启动VIP前,eth0上,只有两个地址,然后启动VIP:
[oracle@rac1 public]$ crs_start racdb1_vip
Attempting to start `racdb1_vip` on member `rac2`
Start of `racdb1_vip` on member `rac2` succeeded.
[oracle@rac2 crsd]$ /sbin/ip ad sh
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:bd:02:cc brd ff:ff:ff:ff:ff:ff
inet 172.21.1.31/24 brd 172.21.1.255 scope global eth0
inet 172.21.1.81/24 brd 172.21.1.255 scope global secondary eth0:2
inet 172.21.1.82/24 brd 172.21.1.255 scope global secondary eth0:1
inet6 fe80::20c:29ff:febd:2cc/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
link/ether 00:0c:29:bd:02:d6 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.12/24 brd 10.0.0.255 scope global eth1
inet6 fe80::20c:29ff:febd:2d6/64 scope link
valid_lft forever preferred_lft forever
4: sit0:
link/sit 0.0.0.0 brd 0.0.0.0
在rac2节点上的eth0上多出来一个IP地址,使用 crs_stat racdb1_vip查看资源状态,输出说明资源状态ONLINE,运行在节点rac2上:
[oracle@rac2 crsd]$ crs_stat racdb1_vip
NAME=racdb1_vip
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac2
测试资源转移:
[oracle@rac1 public]$ crs_relocate racdb1_vip
Attempting to stop `racdb1_vip` on member `rac2`
Stop of `racdb1_vip` on member `rac2` succeeded.
Attempting to start `racdb1_vip` on member `rac1`
Start of `racdb1_vip` on member `rac1` succeeded.
[oracle@rac1 public]$ crs_stat racdb1_vip
NAME=racdb1_vip
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
通过IE访问得到如下请求页面:
[oracle@rac1 public]$ crs_relocate racdb1_vip
Attempting to stop `racdb1_vip` on member `rac1`
Stop of `racdb1_vip` on member `rac1` succeeded.
Attempting to start `racdb1_vip` on member `rac2`
Start of `racdb1_vip` on member `rac2` succeeded.
通过IE访问得到如下请求页面:
[oracle@rac1 public]$ crs_stat racdb1_vip
NAME=racdb1_vip
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac2