A simple HTTP HA cluster keepalived instance configuration

Source: Internet
Author: User

Here is an example of a keepalived:
master:192.168.200.11 Running Service httpd
slave:192.168.200.12 Running Service httpd

Virtual ip:192.168.200.16

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  HTTPD}vrrp_script check_httpd{ script  "KILLALL -0 HTTPD"  interval 2} vrrp_instance vi_1 {    state master    interface  eth0    virtual_router_id 51    priority 100     advert_int 1    authentication {         auth_type PASS        auth_pass 1111     } notify_master  "/etc/keepalived/master.sh"  notify_master  "/etc/keepalived/backup.sh"  notify_master   "/etc/keepalived/fault.sh"  track_script { check_httpd}    virtual_ ipaddress {        192.168.200.16/24 dev eth0         }}vim master.shLOGFIELE=/var/log/keepalived-state.logecho  "[Master]"  >>  $LOGFILEdate  + "%f %t"  >> $LOGFILEvim  backup.shlogfiele= /var/log/keepalived-state.logecho  "[Backup]"  >>  $LOGFILEdate  + "%f %t"  > > $LOGFILEvim  master.shLOGFIELE=/var/log/keepalived-state.logecho  "[Fault]"  >> $ logfiledate + "%f %t"  >> $LOGFILE

Copy the above files to the backup node to change two parameters, state to backup, priority 80


Detailed parameters:

Vrrp_instance Vi_1: Instance is represented by vrrp_instance, followed by instance name

State: The role used to specify Keepalived (MASTER or BACKUP)


Interface: interface for specifying an HA monitoring network

VRITUAL_ROUTER_ID: is a virtual route identity, which is a number that is unique in the same instance and is consistent with the master and backup identities

Priority: Used to define node precedence, the larger the number, the higher the priority level

Advert_int: Used to set the time interval between master and backup hosts for synchronization checks, by default s

MCAST_SRC_IP: Used to set the address of the sending multicast packet, if not set, will use the IP address of the bound network card

Garp_master_delay: Sets the time to delay the gratuitous ARP request after switching to the master state


Nopreempt: The non-preemption feature in a highly available cluster is set. In a highly available cluster, if the primary node dies, the standby node becomes the primary node and the primary node

After recovery, the resource is preempted again, the resource is re-returned to its node from the currently running node, and if this is set, after the primary node fails to recover, it will not

Seizing resources will keep the existing running state. Resource transfers do not occur until an existing primary node fails.

Preemtp_delay: Used to set the preemption delay time, in S, this option is mainly used after the device system restarts, the network needs a period of time to work properly, this

There is no need for a master-slave switchover to set the time interval for this to occur, and the failure to do so during this time does not switch


Virtual_ipaddress: Used to set up related routing entries added or removed during switchover
Track_scrip: Call Vrrp_script

Killall-0 signal indicates the running state of the program is monitored, and if a process shutdown or other exception is found, the status code 1 is returned

About setting parameter interpretation in Vrrp_script:

Vrrp_script chk_haporxy{
Script "killall-0 Haproxy"
Interval 2
#监测周期
Weight-2
# If the monitoring fails the current node priority minus 2
Fail 2
#失败次数, if the request fails 2 times it is assumed that the node resource failed to switch

Rise 1
#监测成功就立即成功, if the request succeeds, the node resource is returned to normal by default
}

This article is from the "Vbird" blog, make sure to keep this source http://cpvbird.blog.51cto.com/3165113/1585592

A simple HTTP HA cluster keepalived instance configuration

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.