• mysql--replication复制集典型配置


    一:主从

    机器a:192.168.1.100

    机器b: 192.168.1.101

    1,给a :my.cnf添加以下配置

    server-id=100
    
    log-bin=mysql-bin
    
    binlog-format=mixed |row|statement
    

     2,在a上新建帐号

    grant replication slave,replication client on *.* to 'repl'@'192.168.1.%' identified by 'repl';
    

    3,给b:my.cnf添加以下配置

    server-id=101
    
    relay-log=mysql-relay
    
    read-only=1
    

     4,b上执行:

    change master to 
    master_host = '192.168.1.100',
    master_host = 'repl', 
    master_password='repl',
    master_log_file='mysql-bin.000001',
    master_log_pos='xxx'
    

     其中master_log_file和master_log_pos通过在master上执行show master status确定,也可以直接在os上查看文件名确定file

    5, b上执行

    slave start
    

    二:主主

    机器a:192.168.1.100

    机器b: 192.168.1.101

    1,添加a:my.cnf 

    server-id=100
    log-bin=mysql-bin
    binlog-format=mixed  #statement/row/mixed
    
    relay-log=mysql-relay
    log-slave-updates=1  #保证同步过来的数据写入自己的bin-log
    
    auto_increment_increment=2 #自增步长
    auto_increment_offset=1  #自增初始偏移量

     2,添加b:my.cnf

    server-id=101
    log-bin=mysql-bin
    binlog-format=mixed  #statement/row/mixed
    
    relay-log=mysql-relay
    log-slave-updates=1  #保证同步过来的数据写入自己的bin-log
    
    auto_increment_increment=2 #自增步长
    auto_increment_offset=2  #自增初始偏移量
    

    3 ,a,b建立帐号:

    grant replication slave,replication client on *.* to 'repl'@'192.168.1.%' identified by 'repl';
    

     4,a执行:

    change master to 
    master_host = '192.168.1.101',
    master_host = 'repl', 
    master_password='repl',
    master_log_file='mysql-bin.000001',
    master_log_pos='xxx';
    
    slave start;
    

     5,b执行:

    change master to 
    master_host = '192.168.1.100',
    master_host = 'repl', 
    master_password='repl',
    master_log_file='mysql-bin.000001',
    master_log_pos='xxx';
    
    slave start;
    

     搞定!

  • 相关阅读:
    codeforces 169 div2 C
    poj 1062(最短路)
    sgu 118
    sgu 101
    poj 2446二分图匹配
    ural 1129 (求数据)
    C#中抽象类和接口的区别(转)
    在.net(C# or vb.net)中,Appplication.Exit 还是 Form.Close有什么不同?
    一道爱出的题目,就是前面两个数相加 用递归方法实现
    C#冒泡排序
  • 原文地址:https://www.cnblogs.com/phper007/p/3562952.html
Copyright © 2020-2023  润新知