系统环境: rhel6 x86_64 iptables and selinux disabled
主机: 192.168.122.119 server19.example.com
192.168.122.25 server25.example.com
192.168.122.163 server63.example.com
192.168.122.193 server93.example.com
yum仓库配置:
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=ftp://192.168.122.1/pub/yum
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[HighAvailability]
name=Instructor Server Repository
baseurl=ftp://192.168.122.1/pub/yum/HighAvailability
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled=1
[LoadBalancer]
name=Instructor Server Repository
baseurl=ftp://192.168.122.1/pub/yum/LoadBalancer
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled=1
[ResilientStorage]
name=Instructor Server Repository
baseurl=ftp://192.168.122.1/pub/yum/ResilientStorage
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled=1
[ScalableFileSystem]
name=Instructor Server Repository
baseurl=ftp://192.168.122.1/pub/yum/ScalableFileSystem
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled=1
Realserver1 192.168.122.163:apache
Realserver2 192.168.122.193:apache
Load Balance 192.168.122.119:piranha
Load Balance 192.168.122.25:piranha
以下步骤在server19和server25上实施:
[root@server19 ~]# yum install piranha -y
[root@server19 ~]# piranha-passwd
以下步骤在server19或server25上实施:
[root@server19 ~]# /etc/init.d/piranha-gui start
[root@server19 ~]# netstat -antple
tcp 0 0 :::3636 :::* LISTEN 0 11213 2268/httpd
注:piranha会调用apache进程开启一个3636端口,能查看到此端口表示启动成功.
访问192.168.122.119:3636看到如下页面:
选择Login登录,用户名为piranha,密码为之前执行piranha-passwd时候设置的密码.
选择GLOBAL SETTINGS
选择REDUNDANCY
选择ENABLE
按如下如图配置并提交(按ACCEPT)
选择VIRTUAL SERVERS
选择ADD
选择EDIT
按如下如图配置并提交(按ACCEPT)
选择REAL SERVER
选择ADD然后选择EDIT
按如下如图配置并提交(按ACCEPT)设置Realserver
选择MONITORING SCRIPTS,无需设置直接提交(按ACCEPT)
选择REAL SERVER并选择(DE)ACTIVE将所有的Realserver激活
选择VIRTUAL SERVERS并选择(DE)ACTIVE将其激活
注:所有的操作都将自动写如server19的/etc/sysconfig/ha/lvs.cf中.
[root@server19 ha]# scp lvs.cf root@192.168.122.25:/etc/sysconfig/ha/
以下步骤在server63上实施:
[root@server63 ~]# yum install arptables_jf httpd -y
[root@server63 ~]# arptables -A IN -d 192.168.122.178 -j DROP
[root@server63 ~]# arptables -A OUT -s 192.168.122.178 -j mangle --mangle-ip-s 192.168.122.163
[root@server63 ~]# /etc/init.d/arptables_jf save
[root@server63 ~]# ifconfig eth0:0 192.168.122.178 netmask 255.255.255.255 up
[root@server63 ~]# echo `hostname` > /var/www/html/index.html
[root@server63 ~]# /etc/init.d/httpd start
以下步骤在server93上实施:
[root@server93 ~]# yum install arptables_jf httpd -y
[root@server93 ~]# arptables -A IN -d 192.168.122.178 -j DROP
[root@server93 ~]# arptables -A OUT -s 192.168.122.178 -j mangle --mangle-ip-s 192.168.122.193
[root@server93 ~]# /etc/init.d/arptables_jf save
[root@server93 ~]# ifconfig eth0:0 192.168.122.178 netmask 255.255.255.255 up
[root@server93 ~]# echo `hostname` > /var/www/html/index.html
[root@server93 ~]# /etc/init.d/httpd start
以下步骤在server19和server25上实施:
[root@server19 ~]# /etc/init.d/pulse start
测试:
将piranha启动后,会在主备server19产生一个eth0:1接口,当主备的宕掉(例如:piranha关闭,网断,内核崩溃)后,会由备用的server25接管,充当调度器.
原文:http://www.cnblogs.com/xautlmx/p/4381177.html