[bigdata-66] ubuntu 14.04 + keepalived+mysql5.5 mysql双机主主同步热备ip漂移故障自动切换实践

本文档详细介绍了在Ubuntu 14.04上使用Keepalived和MySQL实现双机主主同步热备的步骤,包括MySQL的配置、主主同步设置、故障自动切换以及Keepalived的安装和配置。测试结果显示,一旦设定,系统能够自动同步数据并完成IP漂移,确保高可用性。但在阿里云等环境下可能不支持Keepalived的部署。
摘要由CSDN通过智能技术生成
1. 两个节点
192.168.17.112 smysql1
192.168.17.109 smysql2

2. 两个节点均安装mysql
apt-get install mysql-client-5.5 mysql-server-5.5
root密码是tt88

3. 配置主主同步
3.1 在两个节点mysql上都执行
create user 'mmsync'@'%' identified by 'weirj33';
grant replication slave, replication client on *.* to 'mmsync'@'%' identified by 'weirj33';

3.2 对smysql1进行配置,修改/etc/my.cnf,增加如下命令
[mysqld]
log-bin=mysql-bin
server-id=11
expire-logs-days=100
binlog-ignore-db=mysql
binlog-ignore-db=infomation_schema
binlog-ignore-db=performance_schema #5.5以上需要这一行
auto-increment-increment=2
auto-increment-offset=1
character-set-server=utf8  
collation-server=utf8_general_ci

[client]
default-character-set=utf8

3.3 对smysql2创建复制帐号
create user 'mmsync'@'%' identified by 'weirj33';
grant replication slave, replication client on *.* to 'mmsync'@'%' identified by 'weirj33';

3.4 对smysql2的/etc/my.cnf进行配置
[mysqld]
log-bin=mysql-bin
server-id=12
expire-logs-days=100
binlog-ignore-db=mysql
binlog-ignore-db=infomation_schema
auto-increment-increment=2
auto-increment-offset=2
character-set-server=utf8  
collation-server=utf8_general_ci

[client]
default-character-set=utf8

 

3.5 互告bin-log信息
重启mysql服务
3.5.1 在smysql1上执行show master status,查看bin-log文件
  File: mysql-bin.000001
        Position: 107
    Binlog_Do_DB:
Binlog_Ignore_DB: mysql,infomation_schema
1 row in set (0.00 sec)

3.5.2 在smysql2上执行show master status查看bin-log文件
File: mysql-bin.000002
        Position: 107
    Binlog_Do_DB:
Binlog_Ignore_DB: mysql,infomation_schema


3.5.3 在smysql1上执行
change master to master_host='192.168.17.109',master_user='mmsync',master_password='weirj33',master_log_file='mysql-bin.000002',master_log_pos=107;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值