zoukankan      html  css  js  c++  java
  • MySQL主主配置及并行复制搭建

    思路:

    两台机器互为主从。

    机器1:192.168.1.160

    机器2:192.168.1.164

    修改两台机器的my.cnf文件,server-id,log-bin,auto-increment-increment,auto-increment-offset   后面两个参数为防止主键冲突而设置。

    主主配置有两个要点:

    1、复制账号

    2、定位master信息。

    所以,在两台机器上分别执行:

    show master status;查看二进制文件的名称与位置,然后执行:

    机器1:GRANT REPLICATION SLAVE ON *.* TO 'bau1'@'192.168.1.164' IDENTIFIED BY '123456';        change master to master_host='192.168.1.164',master_user='bau1',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=452;      

    机器2:GRANT REPLICATION SLAVE ON *.* TO 'bau1'@'192.168.1.160' IDENTIFIED BY '123456';        change master to master_host='192.168.1.160',master_user='bau1',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=452;

    在机器 1上创建一个表,在机器2上查看。

    在机器2上创建一个表,在机器1上查看。

    如果都可以创建,那主主配置完成。

    并行复制:

    my.cnf配置(主):

    gtid_mode=ON

    enforce-gtid-consistency

    binlog_format=row

    my.cnf配置(从):

    slave-parallel-type=LOGICAL_CLOCK
    slave-parallel-workers=6
    master_info_repository = TABLE
    relay_log_info_repository = TABLE
    gtid_mode=ON
    log-slave-updates=ON
    enforce-gtid-consistency

    binlog_format=row

    其他都一样,唯一不一样的地方是:

    change master to master_host='192.168.18.102',master_user='backup',master_password='123456',master_port=3306,master_auto_position=1;

     

  • 相关阅读:
    第一个博客——python通过值传递函数参数
    JAVA并发体系-1.1-终结任务或线程
    JAVA并发体系-1.4-线程池
    JAVA并发体系-1.3-线程之间的协作
    JAVA并发体系-2-锁机制
    并发实现机制-1-综述
    JAVA并发体系-3-并发容器
    并发实现机制-2-互斥实现
    并发实现机制-3-死锁和饥饿
    JAVA持有对象
  • 原文地址:https://www.cnblogs.com/magmell/p/8438167.html
Copyright © 2011-2022 走看看