MySQL数据库主从及主主复制配置演示(3)

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;

MySQL数据库主从及主主复制配置演示

    19.48上使用同样的命令:

MySQL数据库主从及主主复制配置演示

  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

MySQL数据库主从及主主复制配置演示

MySQL数据库主从及主主复制配置演示

之后的复制演示这里不再演示,请大家自行尝试。至此,所有试验演示完毕,谢谢!

--------------------------------------分割线 --------------------------------------

Ubuntu下Nginx做负载实现高性能WEB服务器5---MySQL主主同步

生产环境MySQL主主同步主键冲突处理

MySQL主从失败 错误Got fatal error 1236

MySQL主从复制,单台服务器上实施

搭建MySQL代理服务器实现读写分离+主从同步

MySQL 5.5 主从双向同步

MySQL 5.5主从同步排错

MySQL主从复制异步半同步实例

--------------------------------------分割线 --------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/f7c2d27fcea7eed2eced9dbf7d3a0ac2.html