1. Director Server配置
安装软件依赖环境
1 | # yum install -y gcc* |
安装ipvsadm
1 | # yum install -y ipvsadm |
下载软件安装包并解压
1 | # wget http://www.keepalived.org/software/keepalived-1.3.2.tar.gz |
为程序准备安装目录
1 | # mkdir /usr/local/keepalived |
编译前配置
1 | # cd keepalived-1.3.2 |
编译安装
1 | # make && make install |
为keepalived准备启动脚本和配置文件
1 | # cd /usr/local/keepalived/ |
将keepalived加入开机启动项
1 | # chmod +x /etc/init.d/keepalived |
在MASTER服务器上按需修改keepalived.conf配置文件
1 | # vim /etc/keepalived/keepalived.conf |
将MASTER上的配置同步到BACKUP服务器并相应修改
1 | # scp -P 16804 /etc/keepalived/keepalived.conf root@kp-bt-04:/etc/keepalived/ |
配置iptables规则
1 | # iptables -I INPUT -d 224.0.0.0/8 -j ACCEPT |
启动keepalived服务
1 | # service keepalived start |
2. Realserver配置
创建一个脚本配置arp抑制及绑定vip
1 | # vim /home/vip-add.sh |
启动该脚本
1 | # chmod +x vip-add.sh |
测试访问正常。