数据库
首页 > 数据库> > mysql主主复制

mysql主主复制

作者:互联网

  1. M1和M2服务器
    grant replication slave,replication client on *.* to 'hanlf'@'%' identified by '123456';
  2. M1服务器配置
    vim /etc/my.cnf
    server-id=23
    log-bin=mysql-bin
    gtid-mode=ON
    enforce-gtid-consistency=ON
    auto_increment_increment=2
    auto_increment_offset=1
  3. M2服务器配置
    vim /etc/my.cnf
    server-id=24
    log-bin=mysql-bin
    gtid-mode=ON
    enforce-gtid-consistency=ON
    auto_increment_increment=2
    auto_increment_offset=2
  4. M1服务器
    change master to master_host='192.168.2.23',master_port=3306,master_user='hanlf',master_password='123456',master_auto_position=1;
    start slave;
  5. M2服务器
    change master to master_host='192.168.2.24',master_port=3306,master_user='hanlf',master_password='123456',master_auto_position=1;
    start slave;

标签:bin,主主,auto,复制,master,increment,mysql,服务器,gtid
来源: https://blog.csdn.net/felon527/article/details/122794238