keepalived+mysql主主双备
程序员文章站
2024-03-23 11:44:40
...
my.cnf配置如下:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server-id=60
log-bin=mysql-bin
binlog-format=mixed
relay-log=mysql-relay
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
2、重起mysql服务(service mysqld restart)
3、授权grant replication slave, replication client on *.* to 'root'@'192.168.3.60' identified by '123456';
4、主服务的mysql执行show master status
5、将4的内容获取出来放在从服务的mysql 中执行change master to master_host='192.168.3.70',master_user='root',master_password='12354',master_log_file='mysql-bin.000021',master_log_pos=106;替换master_log_file和master_log_pos的内容
6、从服务执行show slave status查看Slave_IO_Running 和 Slave_SQL_Running是否为yes
keepalived的配置只需修改
安装过程看https://www.cnblogs.com/dcrq/p/5642680.html
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.3.88
192.168.3.99
}
}
可以添加如下的配置对mysql进行监控(可以使用nmap等工具进行监控,多次拉不起来则关闭本地的keepalived服务(service keepalived stop),在重试范围内则不需要)
vrrp_script chk_mysql_port {
script "sh脚本的地址"
interval 2
weight 2
}
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server-id=60
log-bin=mysql-bin
binlog-format=mixed
relay-log=mysql-relay
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
2、重起mysql服务(service mysqld restart)
3、授权grant replication slave, replication client on *.* to 'root'@'192.168.3.60' identified by '123456';
4、主服务的mysql执行show master status
5、将4的内容获取出来放在从服务的mysql 中执行change master to master_host='192.168.3.70',master_user='root',master_password='12354',master_log_file='mysql-bin.000021',master_log_pos=106;替换master_log_file和master_log_pos的内容
6、从服务执行show slave status查看Slave_IO_Running 和 Slave_SQL_Running是否为yes
keepalived的配置只需修改
安装过程看https://www.cnblogs.com/dcrq/p/5642680.html
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.3.88
192.168.3.99
}
}
可以添加如下的配置对mysql进行监控(可以使用nmap等工具进行监控,多次拉不起来则关闭本地的keepalived服务(service keepalived stop),在重试范围内则不需要)
vrrp_script chk_mysql_port {
script "sh脚本的地址"
interval 2
weight 2
}
推荐阅读
-
keepalived+mysql主主双备
-
redis cluster集群架构详解(十八)-高可用性与主备切换原理
-
Mysql(mariadb)实现主从复制(一主双从)以及简单故障排错
-
springboot+mycat数据库中间件+mysql(一主一备)主从复制
-
keepalived + redis 主备容灾部署
-
Mycat中间件实现一主一从和双主双从的读写分离
-
centos7下 Mysql+Keepalived 双主热备高可用图文配置详解
-
2020.9.16工作问题记录————Mysql5.7主主互备配置
-
基于mysql主主互备实现keepalived高可用 方案
-
简介keepalived及搭建主备切换环境