zoukankan      html  css  js  c++  java
  • 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;
    

     搞定!

  • 相关阅读:
    如何让研发团队保持敏捷并不断进步?
    敏捷方法适合什么样的团队?
    规模化敏捷中的“三要”和“三不要”
    敏捷开发中如何使用看板方法创造价值
    4.0 初步预计更新内容
    3.0 环境应用(待更新)
    5.0 Genymotion安装以及基础使用
    2.0 python+appium环境搭建
    1.0 python-client以及ui自动化介绍
    教你一招另辟蹊径抓取美团火锅数据
  • 原文地址:https://www.cnblogs.com/phper007/p/3562952.html
Copyright © 2011-2022 走看看