Complete keepalived configuration Template

Source: Internet
Author: User

Reference:

http://my.oschina.net/9981/blog/473209

http://my.oschina.net/ahanflw/blog/286206

Here is the configuration template for keepalived, which can be used directly later.

! configuration file for keepalivedvrrp_script chk_haproxy {          script  "/etc/keepalived/check_haproxy.sh"     // Here is the concrete execution of the script, including the time parameters      interval 2          weight   2 } global_defs {   notification_email  {     [email protected]     [email protected]      [email protected]   }   notification_email_ From [email protected]   smtp_server 192.168.200.1   smtp_connect _timeout 30   router_id lvs_devel}vrrp_instance vi_1 {     state master    interface eth0    virtual_router_id  51    mcast_src_ip       here fill in the native IP of the same network segment as the virtual IP!!!     priority 100    advert_int 1     authentication {        auth_type pass         auth_pass 1111    }          track_script {         chk_haproxy    //here write the script to be executed id    }     virtual_ipaddress {         192.168.200.16         192.168.200.17        192.168.200.18    }} # virtual_server 192.168.200.100 443 {#delay_loop  6#lb_algo rr#lb_kind nat#nat_ Mask 255.255.255.0#persistence_timeout 50#protocol tcp#real_server  192.168.201.100 443 {# weight 1# ssl_get {#url  {#  path /#digest  ff20ad2481f97b1754ef3e12ecd3a9cc#&nbsp, #url  {#path  /mrtg/#digest   9b3a0c85a887a256d6939da88aabd8cd#} #connect_timeout  3#nb_get_retry 3#delay_before_retry 3#}#}#}# virtual_server 10.10.10.2 1358 {#delay_loop  6#lb_algo rr  #lb_kind  nat# persistence_timeout 50#protocol tcp#sorry_server 192.168.200.200 1358# #real_server   192.168.200.2 1358 {#weight  1# HTTP_GET {# url { #    path /testurl/test.jsp#digest 640205b7b0fc66c1ea91c463fac6334d#} #url  { # path / Testurl2/test.jsp# digest 640205b7b0fc66c1ea91c463fac6334d# }# url { # path  /testurl3/test.jsp#  digest 640205b7b0fc66c1ea91c463fac6334d# }# connect_ Timeout 3# nb_get_retry 3# delay_before_retry 3#}#} #real_server  192.168.200.3 1358 {# weight  1#http_get {#url  { # path /testurl/test.jsp#  digest  640205b7b0fc66c1ea91c463fac6334c# }# url { #  path /testurl2/test.jsp#  digest 640205b7b0fc66c1ea91c463fac6334c#}# connect_timeout 3#  nb_get_retry  3# delay_before_retry 3#}#}#} #virtual_server  10.10.10.3 1358 {#delay_loop   3# lb_algo rr  #lb_kind  nat#nat_mask 255.255.255.0# persistence_timeout 50# protocol tcp#real_server 192.168.200.4 1358 {# weight 1# http_get {#   url { #  path /testurl/test.jsp#   digest  640205b7b0fc66c1ea91c463fac6334d# }# url { #   path /testurl2/test.jsp #      digest 640205b7b0fc66c1ea91c463fac6334d#     }#   url { #     path /testurl3/test.jsp#    digest  640205b7b0fc66c1ea91c463fac6334d#  }#  connect_timeout 3#  nb_get_retry  3# DELAY_BEFORE_RETRY 3#  }#&NBSP,} #real_server  192.168.200.5 1358 {#  weight 1#   http_get {#       url {  #        path /testurl/test.jsp#        digest 640205b7b0fc66c1ea91c463fac6334d#      }#       url { #        path / testurl2/test.jsp#      digest 640205b7b0fc66c1ea91c463fac6334d#      }#      url { #      path /testurl3/test.jsp#       digest 640205b7b0fc66c1ea91c463fac6334d#     }#   connect_ timeout 3#   nb_get_retry 3#    delay_before_retry 3#   }# }#}

The really executed script check_haproxy.sh is defined as: Modify the place you want to modify it yourself.

#!/bin/bashstatus=$ (ps aux|grep haproxy | grep -v grep | grep -v  bash | wc -l) echo  "Start status:"   $statusif  [  $status  =   "0"  ] ; then        echo  "haproxy " STOPED.STARTING HAPROXY&NBSP: "         cd /root/ Haproxy-1.4.23/haproxy-1.4.23/haproxy-1.4.23        ./haproxy -f  ./examples/haproxy.cfg        sleep 3         status=$ (ps aux|grep haproxy | grep -v grep |  grep -v bash | wc -l) #status = "1"          if [  $status  =  "0"  ] ; then                 pkill keepalived                 echo  "haproxy start failed. so keepalived stoped.";         else                 echo  "haproxy started.";         fifiecho  "End status:"   $status

command to start keepalived:

./bin/keepalived-f/root/keepalived-1.2.8/keepalived/etc/keepalived/keepalived.conf -P -l  如果想前台启动则加上-n

Complete keepalived configuration Template

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.