keepalived中怎么构建高可用MySQL

46次阅读
没有评论

共计 1987 个字符,预计需要花费 5 分钟才能阅读完成。

本篇文章给大家分享的是有关 keepalived 中怎么构建高可用 MySQL-HA,丸趣 TV 小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着丸趣 TV 小编一起来看看吧。

环境拓扑如下

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 配置

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  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   

  nbsp

以上就是 keepalived 中怎么构建高可用 MySQL-HA,丸趣 TV 小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注丸趣 TV 行业资讯频道。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-01发表,共计1987字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)