文档详情

利用keepalived构建高可用MYSQL-HA..doc

发布:2017-01-08约9.09千字共10页下载文档
文本预览下载声明
利用keepalived构建高可用MySQL-HA 在MySQL-HA环境中,MySQL互为主从关系,这样就保证了两台MySQL数据的一致性,然后用keepalived实现虚拟IP,通过keepalived自带的服务监控功能来实现MySQL故障时自动切换。 环境拓扑如下 MySQL-VIP: ? MySQL-master1: ? MySQL-master2: ?? OS版本: MySQL版本:5.0.89 ? Keepalived版本:1.1.20? 一、MySQL master-master配置 1、修改MySQL配置文件 两台MySQL均如要开启binlog日志功能,开启方法:在MySQL配置文件[MySQLd]段中加上log-bin=MySQL-bin选项 两台MySQL的server-ID不能一样,默认情况下两台MySQL的serverID都是1,需将其中一台修改为2即可 2、将设为的主服务器 在上新建授权用户 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)? 在172.168.1.7上将设为自己的主服务器 MySQL?change?master?to?master_host=,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?status\G ? ***************************?1.?row?*************************** ? ?????????????Slave_IO_State:?Waiting?for?master?to?send?event ? ????????????????Master_Host:?172.168.1.6 ? ????????????????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_Tab
显示全部
相似文档