vim /etc/my.cnf
-------------------------------------------
[mysqld]
server-id=2
log-bin=/mydata/data/mysql2-bin
relay_log=/mydata/data/relay-log
auto-increment-increment = 2
auto-increment-offset = 2
3.创建具有复制权限的用户:
19.43上:
service mysqld start
/usr/local/mysql/bin/mysql
------------------------------------------
GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO mmm@192.168.19.48 IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
19.48上:
service mysqld start
/usr/local/mysql/bin/mysql
------------------------------------------
GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO mmm@192.168.19.43 IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
4.查看二进制位置:
19.43上:
SHOW MASTER LOGS;
19.48上使用同样的命令:
5.配置CHANGE MASTER:
19.43上:
CHANGE MASTER TO MASTER_HOST='192.168.19.48',MASTER_USER='mmm',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql2-bin.000001',MASTER_LOG_POS=642;
START SLAVE;
19.48上:
CHANGE MASTER TO MASTER_HOST='192.168.19.43',MASTER_USER='mmm',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql1-bin.000001',MASTER_LOG_POS=642;
START SLAVE;
6.查看状态:
SHOW SLAVE STATUS\G
之后的复制演示这里不再演示,请大家自行尝试。至此,所有试验演示完毕,谢谢!
--------------------------------------分割线 --------------------------------------
Ubuntu下Nginx做负载实现高性能WEB服务器5---MySQL主主同步
MySQL主从失败 错误Got fatal error 1236
MySQL主从复制,单台服务器上实施
MySQL主从复制异步半同步实例
--------------------------------------分割线 --------------------------------------