
先按照老师的来吧,先用下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自动接替,由于用虚拟机做的效果不好,改天实验室真机实验。
以前记着龙神做双机热备时天天拔网线玩,现在轮到我了~·~