Keepalived is set to not preemptible resources, and keepalived is used to preemptible resources.

Source: Internet
Author: User

Keepalived is set to not preemptible resources, and keepalived is used to preemptible resources.

When keepalived is used for HA, it is often used to switch between a preemptible master and backup.


Example:
Generally, if the master service dies, the backup will become the master, but when the master service is ready, the master will seize the VIP, in this way, two switching operations will be difficult for busy websites. Therefore, we need to add nopreempt to the configuration file for non-preemption. However, this parameter can only be used when the state is backup, therefore, when using HA, it is best to set both the master and backup states to backup to allow them to compete through priority.

Note: after this configuration, we should pay attention to the order in which the keepalived service is started. If I want to make A backup, The keepalived service of A cannot be started first.

The following are examples of master and slave database configuration in the MHA architecture:

Master Database

[Root @ mysqltest ~] # More/etc/keepalived. conf
#20140916
#! /Bin/bash

Global_defs {
Router_id mysqlmha
}

Vrrp_script check_run {
Script "/etc/keepalived/check_mysql.sh"
Interval 1
}

Vrrp_instance VI_1 {
State BACKUP -- the status is specified as backup.
Interface eth0
Virtual_router_id 151
Priority100
Advert_int 1
Nopreempt -- set nopreempt to prevent resource Preemption
Authentication {
Auth_type PASS
Auth_pass 1111
}

Track_script {
Check_run
}
Virtual_ipaddress {
192.168.66.53
}
}

Slave Database

[Root @ ceshi ~] # More/etc/keepalived. conf
! Configuration File for keepalived

Global_defs {
Router_id mysqlmha
}

Vrrp_script check_run {
Script "/etc/keepalived/check_mysql.sh"
Interval 1
}

Vrrp_instance VI_1 {
State BACKUP
Interface eth0
Virtual_router_id 151
Priority 90
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}

Track_script {
Check_run
}

Virtual_ipaddress {
192.168.66.53
}
}

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.