作者·2010-08-17 16:58
·

WebSphere Edge Component 做网络负载均衡器的实施案例

字数 7047阅读 2189评论 0赞 1

安装环境:RedHat Enterprise Linux AS 4 Update 2

相关IP地址说明见附录1

1. mount 光盘,执行launchpad.sh

选择必要的组件Load Balancer安装即可。

2. 配置 Load Balancer(以下简称LB

我们只用到Dispatcher Server

2.1 启动LB,执行dsserver

2.2 用图形界面管理工具lbadmin

2.3 配置内容

2.3.1 主节点lb1

 

dscontrol set loglevel 1

dscontrol executor start

 

dscontrol cluster add lbcluster address 10.9.162.100 primaryhost 10.9.162.41

dscontrol cluster set lbcluster proportions 49 50 1 0

 

dscontrol port add lbcluster:80 reset no

 

dscontrol server add lbcluster:80:WAS2 address 10.9.162.44

dscontrol server set lbcluster:80:WAS2 weight 10

 

dscontrol server add lbcluster:80:WAS1 address 10.9.162.43

dscontrol server set lbcluster:80:WAS1 weight 10

 

dscontrol port add lbcluster:443 reset no

 

dscontrol server add lbcluster:443:WAS2 address 10.9.162.44

dscontrol server set lbcluster:443:WAS2 weight 9

 

dscontrol server add lbcluster:443:WAS1 address 10.9.162.43

dscontrol server set lbcluster:443:WAS1 weight 9

 

dscontrol highavailability heartbeat add 10.9.162.41 10.9.162.42

dscontrol highavailability backup add primary=10.9.162.41 auto 12345

dscontrol highavailability reach add 10.9.162.22

 

dscontrol manager start manager.log 10004

 

dscontrol advisor start Http 80 Http_80.log

 

2.3.2 备份节点lb2

 

dscontrol set loglevel 1

dscontrol executor start

 

dscontrol cluster add lbcluster address 10.9.162.100 primaryhost 10.9.162.41

dscontrol cluster set lbcluster proportions 49 50 1 0

 

dscontrol port add lbcluster:80 reset no

 

dscontrol server add lbcluster:80:WAS2 address 10.9.162.44

dscontrol server set lbcluster:80:WAS2 weight 10

 

dscontrol server add lbcluster:80:WAS1 address 10.9.162.43

dscontrol server set lbcluster:80:WAS1 weight 10

 

dscontrol port add lbcluster:443 reset no

 

dscontrol server add lbcluster:443:WAS2 address 10.9.162.44

dscontrol server set lbcluster:443:WAS2 weight 9

 

dscontrol server add lbcluster:443:WAS1 address 10.9.162.43

dscontrol server set lbcluster:443:WAS1 weight 9

 

dscontrol highavailability heartbeat add 10.9.162.42 10.9.162.41

dscontrol highavailability backup add backup auto 12345

dscontrol highavailability reach add 10.9.162.22

 

dscontrol manager start manager.log 10004

 

dscontrol advisor start Http 80 Http_80.log

 

3. 配置HTTP Server

/etc/rc.d/rc.local追加一行

ip addr add 10.9.162.100/32 scope host dev lo

执行

#sysctl -w net.ipv4.conf.all.arp_ignore=3 net.ipv4.conf.all.arp_announce=2

确认返回正常后,在/etc/sysctl.conf追加两行

net.ipv4.conf.all.arp_ignore=3

net.ipv4.conf.all.arp_announce=2

#shutdown -r now

4. 配置HA的相关脚本

复制/opt/ibm/edge/lb/servers/samples下的goActive.sample goStandby.sample goInOp.sample highavailChange.sample

bin下并改名成goActive goStandby goInOp highavailChange

修改CLUSTER=10.9.162.100 INTERFACE=eth0:1 NETMASK=255.255.255.0

各脚本内容如下:

goActive

#!/bin/bash

# 5639-D57, 5630-A36, 5630-A37, 5724-D18, 5724-H88, 5724-H89 (C) COPYRIGHT International Business Machines Corp. 1999, 2004

# All Rights Reserved * Licensed Materials - Property of IBM

#

# goActive script

#

# Configure this script when using the high availability feature of

# Load Balancer.

#

# This script is executed when Load Balancer goes into the

# 'Active' state and begins routing packets.

#

# This script must be placed in Load Balancer's bin directory

# (/opt/ibm/edge/lb/servers/bin/) and it needs to have root execute permission.

#

# eth0=Ethernet

# The netmask must be the netmask of your LAN.  It may be hexadecimal or dotted-decimal notation.

#

CLUSTER=10.9.162.100

INTERFACE=eth0:1

NETMASK=255.255.255.0

#

echo "Adding device alias"

ifconfig $INTERFACE $CLUSTER netmask $NETMASK up

 

goStandby

 

#!/bin/bash

# 5639-D57, 5630-A36, 5630-A37, 5724-D18, 5724-H88, 5724-H89 (C) COPYRIGHT International Business Machines Corp. 1999, 2004

# All Rights Reserved * Licensed Materials - Property of IBM

#

# goStandby script

#

# Configure this script when using the high available feature of

# Load Balancer.

#

# This script is executed when Load Balancer goes into the

# 'Standby' state.  Monitoring the health of the 'Active' machine

# but not routing packets.

#

# This script must be placed in Load Balancer's bin directory

# (/opt/ibm/edge/lb/servers/bin/) and it needs to have root execute permission.

#

# eth0=Ethernet

#

CLUSTER=10.9.162.100

INTERFACE=eth0:1

NETMASK=0xfffff800

#

echo "Deleting the device alias(es)"

ifconfig $INTERFACE down

 

goInOp

#!/bin/bash

# 5639-D57, 5630-A36, 5630-A37, 5724-D18, 5724-H88, 5724-H89 (C) COPYRIGHT International Business Machines Corp. 1999, 2004

# All Rights Reserved * Licensed Materials - Property of IBM

#

# goInOp script

#

# Configure this script when using the high availability feature of

# Load Balancer and optionally when using Load Balancer in a

# standalone environment.

#

# This script is executed when the Load Balancer executor is stopped

# (and before the executor is initially started).

#

# This script must be placed in Load Balancer's bin directory

# (/opt/ibm/edge/lb/servers/bin) and it needs to have root execute permission.

#

# eth0=Ethernet

#

CLUSTER=10.9.162.100

INTERFACE=eth0:1

#

echo "Removing device alias(es)"

ifconfig $INTERFACE down

 

highavailChange

#!/bin/bash

# 5630-A36,  (C) COPYRIGHT International Business Machines Corp., 2001, 2002

# All Rights Reserved * Licensed Materials - Property of IBM

#

# highavailChange script

#

# Configure this script only if you are using the Highavailability

# feature of Dispatcher.

#

# Configuration of this script is optional.

#

# This script must be placed in Dispatcher's bin directory

# (by default this is /opt/ibm/edge/lb/servers/bin/) and it needs to have

# root execute permission.

#

# This script is executed whenever the Highavailability state

# changes within Dispatcher such that one of the go* scripts is

# called. The single parameter passed to this script is the name

# of the go* script just run by Dispatcher.

#

# This script may use this information in many ways, such as to alert

# an Administrator or simply record the event.  Below is an example

# of how to record the data when Dispatcher has detected a problem.

 

DATE=`date`

OUTPUT="$DATE LB just ran $1."

 

echo $OUTPUT >> /opt/ibm/edge/lb/servers/logs/lb.log

#:echo $OUTPUT | mail -s "highavailChange" root@localhost

 

 

#chmod 700 go*

#chmod highavailChange

 

5. 测试Load Balancer

分别停止LB

#dsserver stop

先启动主节点的LB

后启动备份节点LB

主节点状态时是“活动”,集群地址在这台机器上。

备份节点状态是“备用”

拔掉主节点的网线,主节点状态变为“备用”,备份节点的状态变为“活动”,集群地址在备份节点上。

接上主节点的网线,主节点状态变为“活动”,备份节点的状态变为“备用”,集群地址在主节点上。

 

附录1. 相关IP地址说明:

Load balancer对外提供的IP地址:10.9.162.100

Load balancer主节点的IP地址10.9.162.41

Load balancer备份节点的IP地址10.9.162.42

IBM HTTP Server的地址分别是10.9.162.43  10.9.162.44

10.9.162.22是用于测试Load balancer是否处于激活状态的IP地址。这是数据库服务器的服务地址。

 

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

1

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广