资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

MySQL双主高可用配置方法解析-创新互联

下文内容主要给大家带来MySQL双主高可用配置方法解析,这里所讲到的知识,与书籍略有不同,都是创新互联专业技术人员在与用户接触过程中,总结出来的,具有一定的经验分享价值,希望给广大读者带来帮助。

创新互联公司专注于企业营销型网站、网站重做改版、隆德网站定制设计、自适应品牌网站建设、HTML5成都商城网站开发、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为隆德等各大城市提供网站开发制作服务。

一、在两台云服务器上分别安装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

}

}

对于以上关于MySQL双主高可用配置方法解析,如果大家还有更多需要了解的可以持续关注我们创新互联的行业推新,如需获取专业解答,可在官网联系售前售后的,希望该文章可给大家带来一定的知识更新。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻标题:MySQL双主高可用配置方法解析-创新互联
本文链接:http://cdkjz.cn/article/ccdcgc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220