Keepalive安装
原创
©著作权归作者所有:来自51CTO博客作者kexl的原创作品,请联系作者获取转载授权,否则将追究法律责任
1,首先我们到官方网站下载最新版本的软件
tar zxvf keepalived-1.2.2.tar.gz
cd keepalived-1.2.2
./configure --prefix=/appsdata/apps/keepalive
make
make install
find / -name keepalived
- 查看keepalived位置
cp /appsdata/apps/keepalive/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /appsdata/apps/keepaliveetc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /appsdata/apps/keepalive/etc/keepalived/keepalived.conf /etc/keepalived/
cp /appsdata/apps/keepalive/sbin/keepalived /usr/sbin/
启动keepalived
service keepalived start|stop|restart
以上成功安装完毕 下面进行配置文件的设置
global_defs {
notification_email {
xxx@exp.com
}
notification_email_from sns-lvs@gmail.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script chk_gearmand_port {
script "</dev/tcp/127.0.0.1/4730"
interval 3 ## 脚本检测时间
weight -40
faill 2
rise 1
}
## 检测时间脚本
1 VIP1
vrrp_instance VI_1 {
state MASTER #指定那个为master,那个为backup,如果设置了nopreempt这个值不起作用,主备考priority决定
interface eth0 #设置实例绑定的网卡
virtual_router_id 51 ##VPID标记 ,路由ID,可通过#tcpdump vrrp查看
priority 100 ##优先级,高优先级竞选为master
advert_int 1 ##检查间隔,默认1秒
authentication { #设置认证
auth_type PASS
auth_pass 1111
}
virtual_ipaddress { ###设置vip
10.201.17.29
}
track_script {
chk_gearmand_port
}
# 执行上述编写脚本
}