MySQL高可用性之Keepalived+Mysql
程序员文章站
2022-04-19 18:08:13
...
环境描述:OS:CentOS6.5_X64MASTER:192.168.0.202BACKUP:192.168.0.203VIP:192.168.0.2041、配置两台Mysql主主同步[root@master~]#yuminstallmysql-servermy
环境描述:
OS:CentOS6.5_X64
MASTER:192.168.0.202
BACKUP:192.168.0.203
VIP:192.168.0.204
1、配置两台Mysql主主同步
[root@master ~]# yum install mysql-server mysql -y [root@master ~]# service mysqld start [root@master ~]# mysqladmin -u root password 123.com [root@master ~]# vi /etc/my.cnf #开启二进制日志,设置id [mysqld] log-bin=mysql-bin server-id=1 #backup这台设置2 [root@master ~]# service mysqld restart#先查看下log bin日志和pos值位置
master配置如下:
[root@ master ~]# mysql -u root -p123.com mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.0.%' IDENTIFIED BY 'replication'; mysql> flush privileges; mysql> change master to -> master_host='192.168.0.203', -> master_user='replication', -> master_password='replication', -> master_log_file='mysql-bin.000002', -> master_log_pos=106; #对端状态显示的值 mysql> start slave; #启动同步backup配置如下:
[root@backup ~]# mysql -u root -p123.com mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.0.%' IDENTIFIED BY 'replication'; mysql> flush privileges; mysql> change master to -> master_host='192.168.0.202', -> master_user='replication', -> master_password='replication', -> master_log_file='mysql-bin.000002', -> master_log_pos=106; mysql> start slave;上一篇: php中四舍五入取整函数详细介绍
下一篇: 故障切换的10篇内容推荐