Configuring keepalive for MySQL dual master high Availability

Source: Internet
Author: User

Configuring keepalive for MySQL dual master high Availability

1. Installing KeepAlive

2 . Configure KeepAlive

Global_defs {

Notification_email {

[Email protected]

[Email protected]

[Email protected]

}

Router_idmysql_ha

}

Vrrp_script Check_mysqld {

Script "/etc/keepalived/mysqlcheck/keepalived_check_mysql.sh"

Interval 2

}

Vrrp_instance ha_1 {

State BACKUP

Interface eth0

VIRTUAL_ROUTER_ID 51

Priority 100

Advert_int 1

Nopreempt

authentication{

Auth_typepass

auth_pass1111

}

Track_script {

Check_mysqld

}

virtual_ipaddress {

192.168.32.100/24 Dev eth0

}

}

Two keepalive of state are set to backup

Check MySQL script keepalived_check_mysql.sh

#!/bin/bash

Mysql=/usr/bin/mysql

Mysql_host=localhost

Mysql_user=root

Mysql_password=www.123

Check_time=3

#mysql is WORKINGMYSQL_OK are 1, MySQL MYSQL_OK is 0

Mysql_ok=1

function Check_mysql_helth () {

$MYSQL-H $MYSQL _host-u $MYSQL _user-p${mysql_password}-e "show status;" >/dev/null 2>&1

If [$ = 0]; then

Mysql_ok=1

Else

Mysql_ok=0

Fi

return $MYSQL _OK

}

While [$CHECK _time-ne 0]

Do

Let "check_time-= 1"

Check_mysql_helth

if [$MYSQL _OK = 1]; Then

Check_time=0

Exit 0

Fi

If [$MYSQL _ok-eq 0] && [$CHECK _time-eq 0]

Then

/etc/init.d/keepalived stop

Exit 1

Fi

Sleep 1

Done

/etc/init.d/keepalived start

Test High Availability: When you turn off DB1 MySQL. His VIP will float to DB2.

Test MySQL master-slave sync function

1. Log on to the remote client through the VIP login test

2. data copy function test

A database was created in DB1. See if you have this database in DB2


This article from "Do not abandon!" Do not give up "blog, be sure to keep this source http://6437769.blog.51cto.com/6427769/1654372

Configuring keepalive for MySQL dual master high Availability

Related Article

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.