Heartbeat双机热备体验

admin 发表于 Linux, 网络技术 分类,标签: , ,
1

_r1_c1

先按照老师的来吧,先用下Heartbeat,LVS和keepalived到实验室再做吧。
实验拓扑图如下:

1.安装heartbeat,我这里用的yum,装了2遍,不知怎回事。
[root@s1 ~]# yum install nginx
2.把配置文件复制到/etc/ha.d
[root@s1 ~]# cd /usr/share/doc/heartbeat-2.1.3/
[root@s1 heartbeat-2.1.3]# cp ha.cf /etc/ha.d/
[root@s1 heartbeat-2.1.3]# cp authkeys /etc/ha.d/
[root@s1 heartbeat-2.1.3]# cp haresources /etc/ha.d/
3.查看本机的名字(提前改好)
[root@s1 heartbeat-2.1.3]# uname -n
s1.ncist.cn
4.编辑配置文件
[root@s1 heartbeat-2.1.3]# cd /etc/ha.d
[root@s1 ha.d]# vi ha.cf
logfile /var/log/ha-log
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
bcast   eth1
ucast eth1 192.168.0.20
node    s1.ncist.cn
node    s2.ncist.cn
ping 192.168.128.2

[root@s1 ha.d]# vi authkeys
auth 1
1 crc

[root@s1 ha.d]# vi haresources
s1.ncist.cn 192.168.128.5 httpd

5.编辑hosts文件
[root@s1 ha.d]# vi /etc/hosts

192.168.128.4 s2.ncist.cn
192.168.128.3 s1.ncist.cn

6.启动服务

[root@s1 ha.d]# chmod 600 authkeys
[root@s1 ha.d]# service heartbeat start

S2的配置基本一致,心跳检测改为192.168.0.10

OK,启动测试,
S1虚拟出来的网卡

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:1C:9A:9D 
          inet addr:192.168.128.5  Bcast:192.168.128.255 

S1关掉,S2自动接替,由于用虚拟机做的效果不好,改天实验室真机实验。

参考资料:http://0451861.blog.51cto.com/133006/130900


一篇评论 关于 “Heartbeat双机热备体验”

发表我的评论

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word