集群系列四(基于ivs-DR模型的ipvsadm+heartbeat+ldirecrtord)
实现目标:
1,借助ldirectord工具实现两台director节点备份;
2,当某RealServer或其web服务出现故障时,Director能自动将其隔离,并在RealServer的web服务恢复时自动将其重新上线;期望将时间控制在5秒钟之内(此过程通过脚本实现)
前提:
VIP 172.16.4.1
Master 172.16.4.10
Backup 172.16.4.20
Trans1 192.168.4.10
Trans2 192.168.4.20
Realserver1 172.16.4.11
Realserver2 172.16.4.22
(此实验是基于虚拟机环境实现,其中trans1,和trans2是用于director相互传递心跳信息,这里我们将其放在同一区域vmnet5中)
准备环境:
1,在两个director上配置(以下操作在两台节点上均需要配置):
#vim /etc/sysconfig/network
主机名为node1.a.com
#vim /etc/hosts
172.16.4.10 node1.a.com node1
172.16.4.20 node2.a.com node2
方便两个director传递心跳信息,配置无密码通信:
#ssh-keygen -t rsa
#ssh-copy-id -i/ .ssh/id_rsa.pub root@node2.a.com
2,在realservers上安装测试服务httpd:
#yum install httpd
为了方便测试设置两个页面:
#echo "<h1>I'm realserver1,welcome to</h1>" > /var/www/html/index.html
#echo "<h1>I'm realserver2,welcome to</h1>" > /var/www/html/index.html
#echo "<h1>ok</h1> > /var/www/html/.test.html
#echo "<h1>ok</h1>" > /var/www/html/.test.html
# service httpd restart
# elinks http://172.16.4.22 --dump //测试网页是否正常显示
I'm realserver2,welcome to //说明服务正常
一、在director上安装ipvadm的软件包:
#rpm -ivh ipvsadm.i386
安装heartbeat软件包:
heartbeat-2.1.4-9.el5.i386.rpm
heartbeat-devel-2.1.4-9.el5.i386.rpm
heartbeat-gui-2.1.4-9.el5.i386.rpm
heartbeat-ldirectord-2.1.4-9.el5.i386.rpm
heartbeat-pils-2.1.4-10.el5.i386.rpm
heartbeat-stonith-2.1.4-10.el5.i386.rpm
libnet-1.1.4-3.el5.i386.rpm
perl-MailTools-1.77-1.el5.noarch.rpm
这些软件包需从网上下载
本地安装软件包:
#yum localinstall --nogpgcheck heartbeat-2.1.4-9.el5.i386.rpm
#yum localinstall --nogpgcheck heartbeat-devel-2.1.4-9.el5.i386.rpm
#yum localinstall --nogpgcheck heartbeat-gui-2.1.4-9.el5.i386.rpm
#yum localinstall --nogpgcheck heartbeat-ldirectord-2.1.4-9.el5.i386.rpm
#yum localinstall --nogpgcheck heartbeat-pils-2.1.4-10.el5.i386.rpm
#yum localinstall --nogpgcheck heartbeat-stonith-2.1.4-10.el5.i386.rpm
#yum localinstall --nogpgcheck libnet-1.1.4-3.el5.i386.rpm
#yum localinstall --nogpgcheck perl-MailTools-1.77-1.el5.noarch.rpm
二、配置相关文件
# cp /usr/share/doc/heartbeat-2.1.4/{authkeys, ha.cf, haresources} /etc/ha.d/
#cp /usr/share/doc/heartbeat-ldirectord-2.1.4/ldirectord.cf /etc/ha.d/
1,配置authkeys文件
#cd /etc/ha.d/
#vim authkeys
auth 2
2 sha1 kfjhkjdfhladfh //sha1后面的字符串是随机的(可以随便输入)
#chmod 400 authkeys &n
- 发表评论
-
- 最新评论 更多>>