zoukankan      html  css  js  c++  java
  • mysql主主同步方案

    第一台机器

    vim /etc/my.cnf

     插入内容:

    server-id=1
    log-bin=mysql-binlog
    log-slave-updates=true
    max_binlog_size=1024M
    auto_increment_offset = 1
    auto_increment_increment = 2

    replicate-ignore-db = information_schema
    replicate-ignore-db = performance_schema
    replicate-ignore-db = test
    replicate-ignore-db = mys

    max_connections = 3000
    max_connect_errors = 30

    skip-character-set-client-handshake
    init-connect='SET NAMES utf8'
    character-set-server=utf8
    wait_timeout=1800
    interactive_timeout=1800
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

    relay-log=relay-log-bin
    relay-log-index=slave-relay-bin.index

    systemctl start mariadb    //重启mariadb

    mysql -uroot -p000000      //连接mysql

     grant replication slave on *.* to 'repl'@'192.168.96.4' identified by '123456';

    flush privileges;    //重新声明

    show master status;

     第二台机器:

    vim /etc/my.cnf

    插入内容;

    server-id = 2
    log-bin=mysql-binlog
    log-slave-updates=true
    max_binlog_size=1024M
    auto_increment_offset = 2
    auto_increment_increment = 2
    replicate-ignore-db = information_schema
    replicate-ignore-db = performance_schema
    replicate-ignore-db = test
    replicate-ignore-db = mysql

    max_connections = 3000
    max_connect_errors = 30

    skip-character-set-client-handshake
    init-connect='SET NAMES utf8'
    character-set-server=utf8
    wait_timeout=1800
    interactive_timeout=1800
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

    relay-log=relay-log-bin
    relay-log-index=slave-relay-bin.index

    systemctl start mariadb    //重启mariadb

    mysql -uroot -p000000      //连接mysql

     grant replication slave on *.* to 'repl'@'192.168.96.5' identified by '123456';

    flush privileges;    //重新声明

    show master status;

    特殊参数说明:

    log-slave-updates = true     #将复制事件写入binlog,一台服务器既做主库又做从库此选项必须要开启

    masterA自增长ID

    auto_increment_offset = 1
    auto_increment_increment = 2 #奇数ID
    masterB自增加ID
    auto_increment_offset = 2
    auto_increment_increment = 2 #偶数ID

    第一台机器:

    stop slave;

    change master to master_host='192.168.96.4',master_port=3306,master_user='repl',master_password='123456',master_log_file='mysql-binlog.000001',master_log_pos=595;

     start slave;

    show slave statusG;

    第二台机器;

    stop slave;

    change master to master_host='192.168.96.5',master_port=3306,master_user='repl',master_password='123456',master_log_file='mysql-binlog.000001',master_log_pos=483;

     start slave;

    show slave statusG;

    第一台机器;

    create database test01;

    第二台机器:

    show databases;

    第二台机器:

    create database test02;

    第一台机器:

    show databases;

  • 相关阅读:
    DOM练习2动态增删表格行
    JS
    JS动态获取当前时间,并写到指定的区域
    DOM练习3选项批量移动
    JS练习显示隐藏图像
    修改MyEclipse默认工作路径
    Aptana 安装与配置
    DOM入门基本概念
    SecureCRT终端显示gcc编译错误提示乱码问题
    使用静态成员函数的一个错误。
  • 原文地址:https://www.cnblogs.com/XXXX001/p/11690625.html
Copyright © 2011-2022 走看看