2.cd /usr/local/src/lvs
3.上传keepalived-1.1.20.tar.gz ipvsadm-1.24.tar.gz到指定文件夹
4.lsmod |grep ip_vs
5.uname -r
结果:2.6.32-431.el6.x86_64
6.ln -s /usr/src/kernels/2.6.32-431.el6.x86_64/ /usr/src/linux
7 tar zxvf ipvsadm-1.24.tar.gz
cd ipvsadm-1.24
make && make install
然后用 ipvsadm 进行测试
8. tar zxvf keepalived-1.1.20.tar.gz
cd keepalived-1.1.20
./configure && make && make install
find / -name keepalived # 查看keepalived位置
9. cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/sbin/keepalived /usr/sbin/
service keepalived start|stop #做成系统启动服务方便管理.
10
vim /etc/init.d/lvsdr
#!/bin/bash
RIP1=10.0.0.19
RIP2=10.0.0.23
VIP=10.0.0.11
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo " start LVS of DirectorServer"
# set the Virtual IP Address and sysctl parameter
/sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev eth0:0
echo "1" >/proc/sys/net/ipv4/ip_forward
#Clear IPVS table
/sbin/ipvsadm -C
#set LVS
#Web Apache
/sbin/ipvsadm -A -t $VIP:80 -s rr
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g