! Configuration File for keepalived  

global_defs {
notification_email {
linuxedu@foxmail.com
mageedu@.com
}
notification_email_from kanotify@magedu.com
smtp_connect_timeout
smtp_server 127.0.0.1
router_id LVS_DEVEL
} vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval
weight
} vrrp_script chk_mantaince_down {
script "[[ -f /etc/keepalived/down ]] && exit 1 || exit 0"
interval
weight
} vrrp_instance VI_1 {
interface eth0
state MASTER # BACKUP for slave routers
priority # for BACKUP
virtual_router_id
garp_master_delay authentication {
auth_type PASS
auth_pass password
}
track_interface {
eth0
}
virtual_ipaddress {
172.16.100.1/ dev eth0 label eth0:
}
track_script {
chk_haproxy
chk_mantaince_down
} notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
} 注意:
、上面的state为当前节点的起始状态,通常在master/slave的双节点模型中,其一个默认为MASTER,而别一个默认为BACKUP。
、priority为当关节点在当前虚拟路由器中的优先级,master的优先级应该大于slave的; 下面是一个notify.sh脚本的简单示例:
#!/bin/bash
# Author: MageEdu <linuxedu@foxmail.com>
# description: An example of notify script
# vip=172.16.100.1
contact='root@localhost' Notify() {
mailsubject="`hostname` to be $1: $vip floating"
mailbody="`date '+%F %H:%M:%S'`: vrrp transition, `hostname` changed to be $1"
echo $mailbody | mail -s "$mailsubject" $contact
} case "$1" in
master)
notify master
/etc/rc.d/init.d/haproxy start
exit
;;
backup)
notify backup
/etc/rc.d/init.d/haproxy restart
exit
;;
fault)
notify fault
exit
;;
*)
echo 'Usage: `basename $0` {master|backup|fault}'
exit
;;
esac

最新文章

  1. Struts1.x 中的 Validate 框架
  2. 浏览器 - Firefox开发者附加组件
  3. C语言中void*详解及应用
  4. Java_spring_定时执行任务
  5. POJ1873 - Balance(01背包)
  6. Linux自动登陆的设置方法
  7. English - even though和even if用法解析
  8. [2014-09-18]Entity Framework 6 预热、启动优化
  9. 提取URL的搜索字符串中的参数
  10. java.sql.SQLException:ORA-01861:文字和格式字符串不匹配
  11. SPOJ D-QUERY
  12. ColorUtil【Color工具类(color整型、rgb数组、16进制互相转换)】
  13. DevExpress 控件汉化代码和使用方法
  14. MTK6261初始化待机流程
  15. idea 上传代码到 gitee
  16. 红米Note 7 Pro在印度首销迅速售罄
  17. boost 编写finger服务
  18. Linux:【解决】无法连接 MKS:套接字连接尝试次数太多正在放弃
  19. linux环境vnc安装
  20. centos6安装部署git服务器(gitlab6.4)

热门文章

  1. Spring使用Rabbitmq (简单使用)
  2. 01 语言基础+高级:1-8 File类与IO流_day09【字节流、字符流】
  3. JS变量、作用域及内存
  4. UML-从需求到设计--迭代进化
  5. day61-mysql-索引原理和慢查询优化
  6. opencv+tkinter制作HsvMaster(一)
  7. beta函数分布图
  8. Unable to cast object of type &#39;System.String&#39; to type &#39;System.Int32&#39;.
  9. E. Delete a Segment(删除一个区间,让并区间最多)
  10. Angular(二)