本篇文章给大家分享的是有关keepalived中怎么构建高可用MySQL-HA,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
环境拓扑如下
MysqL-VIP:192.168.1.200 MysqL-master1:192.168.1.201 MysqL-master2:192.168.1.202 OS版本:CentOS 5.4 MysqL版本:5.0.89 Keepalived版本:1.1.20
一、MysqL master-master配置
两台MysqL均如要开启binlog日志功能,开启方法:在MysqL配置文件[MysqLd]段中加上log-bin=MysqL-bin选项
两台MysqL的server-ID不能一样,默认情况下两台MysqL的serverID都是1,需将其中一台修改为2即可
2、将192.168.1.201设为192.168.1.202的主服务器
在192.168.1.201上新建授权用户
MysqL> grant replication slave on *.* to replication@% identified by replication; Query OK, 0 rows affected (0.00 sec) MysqL> show master status; +------------------+----------+--------------+------------------+ | File | Position | binlog_Do_DB | binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | MysqL-bin.000003 | 374 | | | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
在192.168.1.202上将192.168.1.201设为自己的主服务器
MysqL> change master to master_host=192.168.1.201,master_user=replication,master_password=replication,master_log_file=MysqL-bin.000003,master_log_pos=374;
Query OK, 0 rows affected (0.05 sec)
MysqL> start slave;
Query OK, 0 rows affected (0.00 sec)
MysqL> show slave statusG
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.201
Master_User: replication
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: MysqL-bin.000003
Read_Master_Log_Pos: 374
Relay_Log_File: MysqL-master2-relay-bin.000002
Relay_Log_Pos: 235
Relay_Master_Log_File: MysqL-bin.000003
Slave_IO_Running: Yes
Slave_sql_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 374
 
以上就是keepalived中怎么构建高可用MysqL-HA,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注编程之家行业资讯频道。