MySQL雙主雙活+Keepalived高可用方案關建配置點

一、在兩臺服務器上分別安裝MySQL實例

Mysql01:192.168.0.207

Mysql02:192.168.0.208

vip1:192.168.0.211

vip2:192.168.0.212

(略)

二、在兩臺服務器上配置主主複製

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

;

三、配置keepalived,這個方案的關鍵點在於keepalived的配製,兩個vrrp_instance在兩個主上的優先級相反。

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

}

}

主二:

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

}

}


MySQL課程推薦

   MySQL性能管理及架構設計

   高性能可擴展MySQL數據庫設計及架構優化 電商項目  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章