KeepAlive configuration file Detailed

Source: Internet
Author: User

KEEPALIVE.CONF # configuration file

# vip 101.21.55.12 10.10.10.12# real server1 101.21.55.13 10.10.10.13#  Real Server2 101.21.55.14 10.10.10.14# ! Configuration File for  keepalived #  Global Definition Section global_defs {  notification_email {      [email protected] #  set the alarm email address, you can set multiple, one per line. Note that if you want to turn on mail alerts, you need to turn on the SendMail service on this computer. [email protected]  }  notification_email_from [email protected]   #  set the send address of the message   smtp_server 127.0.0.1  #  set Smtp server address   smtp_ connect_timeout 30  #  Setting the connection SMTP server time-out   router_id lvs_devel  #   Run an identity for the keepalived server. The information that is displayed in the message header when the message is sent}# VRRP the instance definition section, and you can define the extranet IP as well as the intranet IP. This article is a 2-way definition of a role that uses vrrp_instance vi_1 {  state master  #  to specify keepalived. Master indicates that this host is the primary server and backup represents a standby server   interface eth1  #  Specifies the interface   virtual_router_id 1  #  virtual route identifier of the HA monitoring network, which is a number, And the same VRRP instance uses a unique identity, that is, master and backup must be consistent under the same vrrp_instance.   priority 101    #  define priority, the higher the number, the higher the priority, under one vrrp_instance, The priority of master must be greater than the priority of backup   advert_int 1    #  Set the interval between master and backup load balancer synchronization check in seconds   authentication  #  set authentication type and password   {     auth_type PASS  #  set authentication type, mainly have PASS and ah two kinds of     auth_pass  xde.146_5%DJYP  #  Set the authentication password, under a vrrp_instance, master and backup must use the same password to communicate properly   }   virtual_ipaddress  #  set a virtual IP address, you can set multiple virtual IP addresses, one per line   {     101.21.55.12  }}#  Virtual Server Definition Section virtual_server  101.21.55.12 80  #   Set up virtual server, need to specify virtual IP address and service port, IP and port separated by space {  delay_loop 2   #  Set Health check time, unit is seconds   lb_algo wrr    #  set the load scheduling algorithm, which is set to WRR, that is, the least link scheduling   lb_kind DR      #  Set Load balancer forwarding rules, can have NAT, Tun and Dr Three modes optional   persistence_timeout 0  #  session hold time, Units are seconds, this option is very useful for dynamic Web pages and provides a good solution for session sharing in a clustered system. With this session hold feature, the user's request is distributed to a service node until it exceeds the session hold time. It is important to note that this session hold time is the maximum no response timeout, that is, when the user is working on a dynamic page, if no action is taken within 50 seconds, then the next operation will be distributed to the other node, but if the dynamic page has been operating, it is not subject to 50 seconds of time limit    protocol TCP #  Specify the type of forwarding protocol, with TCP and UDP two types   nat_mask 255.255.255.240    gateway  101.21.55.158  real_server  101.21.55.13 80    #  Configuration Service Node 1, you need to specify the real IP address and port of the real server, separated by a space between IP and port   {    weight  1  #  set weights, weight values in numbers, the higher the number, the higher the weight, the size of the weight can be different performance of the server to assign different loads, you can set higher weights for high performance servers, The lower weight is set for the low performance server, so it is reasonable to use and allocate the state detection setting part of the system resource     tcp_check  # realserve, Units are seconds     {  connect_timeout 3   # 3 seconds No response timeout       nb_get_retry 3       #  Retry Attempts       delay_before_retry 3  #  Retry Interval     }  }  real_server  101.21.55.14 80    #  Configuring the Service node 2  {    weight 1    tcp_check {       connect_timeout 3      nb_get_retry  3      delay_before_retry 3    }  }}#   The following is the definition of the intranet IP/VIP and its real server, similar to the above, but the IP has made the corresponding changes Vrrp_instance vi_2 {  state  backup  interface eth0  virtual_router_id 1  priority 100   advert_int 1  authentication {    auth_type pass     auth_pass xde.146_5%DJYP  }  virtual_ipaddress {    10.10.10.12   }}virtual_server  10.10.10.12 80{  delay_loop 2  lb_algo  wrr  lb_kind dr  nat_mask 255.255.255.0  gateway  10.10.10.1   persistence_timeout 0  protocol TCP  real_server   10.10.10.13 80 {    weight 1    tcp_check {       connect_timeout 3      nb_get_retry 3       delay_before_retry 3    }  }   real_server  10.10.10.14 80 {    weight 1     TCP_CHECK {      connect_timeout 3       nb_get_retry 3      delay_before_retry 3    }  }} 


When configuring keepalived.conf, you need to pay special attention to the syntax format of the configuration file, because Keepalived does not detect the correctness of the configuration file at startup, even if there is no configuration file, keepalived can still start up, so the configuration file must be correct.

By default, keepalived will look for the/etc/keepalived/keepalived.conf profile when it starts, and if your profile is placed under a different path, you can use the "keepalived-f" parameter specifies the path to the configuration file you are in.

Once the keepalived.conf is configured, copy the file to the Alternate Director server path, and then make two simple modifications:

Change "state MASTER" to "state BACKUP"

Change priority 100 to a smaller value, which is changed to "priority 80"

Finally, the real server node of the cluster is also configured to communicate with the Director server and ignore ARP, and the contents of the script are described in the previous article and are not explained here.


This article is from "Walker--->" blog, please be sure to keep this source http://liumissyou.blog.51cto.com/4828343/1775069

KeepAlive configuration file Detailed

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.