MySQL双主高可用配置方法详析
发布时间:2023-08-22 15:21:29 所属栏目:MySql教程 来源:
导读:下文内容主要给大家带来MySQL双主高可用配置方法解析,这里所讲到的知识,与书籍略有不同,都是亿速云专业技术人员在与用户接触过程中,总结出来的,具有一定的经验分享价值,希望给广大读者带来帮助。
一、在两
一、在两
下文内容主要给大家带来MySQL双主高可用配置方法解析,这里所讲到的知识,与书籍略有不同,都是亿速云专业技术人员在与用户接触过程中,总结出来的,具有一定的经验分享价值,希望给广大读者带来帮助。 一、在两台云服务器上分别安装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'; MySQL双主高可用配置方法解析 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 } } (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐