Get the App
SLTechnology News&Howtos  ›  Database  › 

Analysis of MySQL double main High availability configuration method

Shulou Source: shulou.com Published: 2022-06-01 20:44:02 09月27日 Update

The following content mainly brings you the analysis of MySQL dual-master high availability configuration method. The knowledge mentioned here, which is slightly different from books, is summed up by professional and technical personnel in the process of contact with users, and has a certain value of experience sharing. I hope to bring help to the majority of readers.

1. Install MySQL instances on two CVM respectively

Mysql01:192.168.0.207

Mysql02:192.168.0.208

Vip1:192.168.0.211

Vip2:192.168.0.212

(slightly)

Configure primary primary replication on two servers

GRANT REPLICATION SLAVE ON *. * TO 'dba_repl'@'192.168.0.%' IDENTIFIED BY' 123456'

Change master to MASTER_HOST='192.168.0.207'

MASTER_USER='dba_repl'

MASTER_PASSWORD = '123456'

MASTER_LOG_FILE = 'mysql-bin.000003'

MASTER_LOG_POS = 120

Third, configure keepalived, the key point of this scheme lies in the configuration of keepalived, the priority of the two vrrp_instance on the two hosts is opposite.

MySQL01:

Global_defs {

# Keepalived process identifier

Lvs_id MySQL_HA

}

# Script used to check if Proxy is running

Vrrp_script check_proxy {

Script "killall-0 mysql"

Interval 2

Weight 3

}

# Virtual interface 1

# The priority specifies the order in which the assigned interface to take over in a failover

Vrrp_instance VI_01 {

State MASTER

Interface eth0

Virtual_router_id 51

Priority 100

# The virtual ip address shared between the two loadbalancers

Virtual_ipaddress {

192.168.0.211 dev eth0

}

Track_script {

Check_proxy

}

}

# Virtual interface 2

# The priority specifies the order in which the assigned interface to take over in a failover

Vrrp_instance VI_02 {

State MASTER

Interface eth0

Virtual_router_id 52

Priority 102

# The virtual ip address shared between the two loadbalancers

Virtual_ipaddress {

192.168.0.212 dev eth0

}

Track_script {

Check_proxy

}

}

Principal two:

Global_defs {

# Keepalived process identifier

Lvs_id MySQL_HA

}

# Script used to check if Proxy is running

Vrrp_script check_proxy {

Script "killall-0 mysql"

Interval 2

Weight 3

}

# Virtual interface 1

# The priority specifies the order in which the assigned interface to take over in a failover

Vrrp_instance VI_01 {

State MASTER

Interface eth0

Virtual_router_id 51

Priority 102

# The virtual ip address shared between the two loadbalancers

Virtual_ipaddress {

10.103.9.211 dev eth0

}

Track_script {

Check_proxy

}

}

# Virtual interface 2

# The priority specifies the order in which the assigned interface to take over in a failover

Vrrp_instance VI_02 {

State MASTER

Interface eth0

Virtual_router_id 52

Priority 100

# The virtual ip address shared between the two loadbalancers

Virtual_ipaddress {

192.168.0.212 dev eth0

}

Track_script {

Check_proxy

}

}

For the above analysis of MySQL dual-master high availability configuration method, if you have more information, you can continue to pay attention to the innovation of our industry. If you need professional solutions, you can contact the pre-sale and after-sale ones on the official website. I hope this article can bring you some knowledge updates.

Tags: Configuration method specialty two server knowledge service different following books people value priority key points content available in examples technology solutions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology macOS Microsoft Xiaomi