设为首页 收藏本站
查看: 647|回复: 0

[经验分享] High Availability

[复制链接]

尚未签到

发表于 2018-12-31 07:54:51 | 显示全部楼层 |阅读模式
  本配置项是针对Keepalived v1.3.4 (02/18,2017):
  #######################全局配置#################################
  

  global_defs {
   notification_email {  #指定keepalived在发生切换时需要发送email到的对象,一行一个
    sysadmin@fire.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc #指定发件人
   smtp_server localhost #指定smtp服务器地址
   smtp_connect_timeout 30 #指定smtp连接超时时间
   router_id LVS_DEVEL #运行keepalived机器的一个标识
}

  
keyworkddefinitiontype
global_defs identify the global def configuration block(全局配置)
notification_email email accounts that will receive the notification mail(收件人的电子邮件)List(列表)
notification_email_from email to use when processing “MAIL FROM:” SMTP command(发件人的电子邮件)List
smtp_server remote SMTP server to use for sending mail notifications(smtp服务器)alphanum(字母数字)
smtp_connection_timeout specify a timeout for SMTP stream processing(指定smtp连接超时时间)numerical
lvs_id   specify the name of the LVS director
  (指定LVS控制器的名称)
alphanum
  

  


  ############vrrp监控组实例###############
vrrp_sync_group string {

  group {
string(实例名)
string
}
notify_master /path_to_script/script_master.sh
(or notify_master “/path_to_script/script_master.sh ”)
notify_backup /path_to_script/script_backup.sh
(or notify_backup “/path_to_script/script_backup.sh ”)
notify_fault /path_to_script/script_fault.sh
(or notify_fault “/path_to_script/script_fault.sh ”)
}

  notify_master:当keepalive状态为master的时候触动脚本
  notify_backup:当keepalive状态是backup的时候触动脚本
  notify_fault: 当keepalive状态失败的时候
  #用vrrp_sync_group 统一监控的目的是,如果你有多个实例,一个内网段和一个外网段,当你外网端ok的时候,内网段有问题,vrrp_sync_group还是会切
  
vrrp_instance string {
state MASTER|BACKUP (实例状态)
interface string (心跳接口)
mcast_src_ip @IP (组播源ip,默认是心跳接口ip)
lvs_sync_daemon_interface string (指定的网络接口lv sync_daemon上运行,默认是心跳接口
virtual_router_id num (设置虚拟路由ID)
priority num (优先级)
advert_int num (间隔探测时间,默认1s)

  smtp_alert (触发smtp)
authentication {
auth_type PASS|AH(认证类型)
auth_pass string (认证密码)
}

  ########################跟踪脚本#########
  
  track_script {
      chk_httpd
  

  }
  

    track_interface { (追踪接口,除了默认的心跳口)
     eth0
  }
  virtual_ipaddress { # Block limited to 20 IP addresses(限制20个以内)
  @IP(虚拟ip)
@IP
@IP
}
virtual_ipaddress_excluded { # Unlimited IP addresses number(不限制ip地址)
@IP(虚拟ip)
@IP
@IP
}
notify_master /path_to_script/script_master.sh (同上)
(or notify_master “/path_to_script/script_master.sh ”)
notify_backup /path_to_script/script_backup.sh
(or notify_backup “/path_to_script/script_backup.sh ”)
notify_fault /path_to_script/script_fault.sh
(or notify_fault “/path_to_script/script_fault.sh ”)
}

  #########脚本检测#############

  
  vrrp_script chk_httpd {
      script "/etc/keepalived/check_httpd.sh"
      interval 1 (间隔1秒)
      weight 2 (权重,这个地方需要在后面的文章详细介绍一下)
      fall 2 (需要请求2次失败,才叫失败,默认是1)
      rise 2 (需要请求2次成功,才叫成功默认1,备注这个参数测试好像不行)
  }
  #######LVS#######################
  virtual_server (@IP PORT)|(fwmark num) {
delay_loop num(指定间隔检测时间)
lb_algo rr|wrr|lc|wlc|sh|dh|lblc(调度算法)
lb_kind NAT|DR|TUN(lvs模式)
(nat_mask @IP)
persistence_timeout num (会话保持时间)
persistence_granularity @IP (?)
virtualhost string (指定http虚拟头部)
protocol TCP|UDP (指定协议)
sorry_server @IP PORT (指定备用vs地址)
real_server @IP PORT {
weight num (权重)
########tcp探测#######

  TCP_CHECK {
connect_port num (连接端口)
connect_timeout num (超时时间)
}
}
real_server @IP PORT {
weight num

  ##########混合探测#####
MISC_CHECK {
misc_path /path_to_script/script.sh(脚本检测)
(or misc_path “/path_to_script/script.sh ”)
}
}
}
real_server @IP PORT {
weight num

  #####http和https检测#####
HTTP_GET|SSL_GET {
url { # You can add multiple url block
path alphanum

  status num (状态检测)
digest alphanum (genhash,页面hash)
}
connect_port num
connect_timeout num
nb_get_retry num
delay_before_retry num
}
}
}

  

  

  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-657789-1-1.html 上篇帖子: Keepalived+LVS实现负载均衡高可用 下篇帖子: keepalived+LVS实现高可用的Web负载均衡
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表