keepalived中怎么构建高可用MySQL-HA
本篇文章给大家分享的是有关keepalived中怎么构建高可用MySQL-HA,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
环境拓扑如下
MySQL-VIP:192.168.1.200MySQL-master1:192.168.1.201MySQL-master2:192.168.1.202OS版本:CentOS5.4MySQL版本:5.0.89Keepalived版本:1.1.20
一、MySQL master-master配置
1、修改MySQL配置文件
两台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>grantreplicationslaveon*.*toreplication@%identifiedbyreplication;QueryOK,0rowsaffected(0.00sec)MySQL>showmasterstatus;+------------------+----------+--------------+------------------+|File|Position|Binlog_Do_DB|Binlog_Ignore_DB|+------------------+----------+--------------+------------------+|MySQL-bin.000003|374|||+------------------+----------+--------------+------------------+1rowinset(0.00sec)
在192.168.1.202上将192.168.1.201设为自己的主服务器
MySQL>changemastertomaster_host=192.168.1.201,master_user=replication,master_password=replication,master_log_file=MySQL-bin.000003,master_log_pos=374;
QueryOK,0rowsaffected(0.05sec)
MySQL>startslave;
QueryOK,0rowsaffected(0.00sec)
MySQL>showslavestatusG
***************************1.row***************************
Slave_IO_State:Waitingformastertosendevent
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,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。