• mysql主主复制


    主主复制原理:

    在这篇文章( http://www.cnblogs.com/whereareyoufrom/p/5240380.html )中讲解主从复制的原理,而主主复制的原理更加简单,只需要将主从复制中master的配置操作再在slave中配置一遍,将slave的配置操作在master中配置一遍即可。

    配置:

    salve配置(将slave配置成master):

    1.修改slave mysql配置文件,加入如下内容

    server-id=2
    log-bin=mysqlbinlog  #开始binlog,binlog文件命名为mysqlbinlog
    binlog_format=fixed  #binlog格式
    
    binlog-do-db=mydata
    #binlog-ignore-db=xxx
    auto-increment-offset=2
    auto-increment-increment=2
    

    2.创建binlog操作用户

    >>> create user replicator@'%' identified by 'xxxxxx';
    >>> grant replication slave on *.* to 'replicator'@'%' identified by 'xxxxxx';
    >>> flush privileges;
    

    3.查看binlog文件名和文件指针位置

    >>> show master status;
    +--------------------+----------+--------------+------------------+
    | File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +--------------------+----------+--------------+------------------+
    | mysqlbinlog.000001 |      245 | mydata       |                  |
    +--------------------+----------+--------------+------------------+
    1 row in set (0.00 sec)
    
    master 配置(将master配置成slave):

    1.修改master 配置文件(重启mysql)

    replicate-do-db=mydata
    

    2.配置binlog文件信息

    >>> change master to
    master_host='192.168.252.18',
    master_user='replicator',
    master_password='xxxxx',
    master_log_file='mysqlbinlog.000001',
    master_log_pos='245';
    >>> start slave;
    >>> show slave status;
    MariaDB [mydata]> show slave statusG;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.252.18
                      Master_User: replicator
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysqlbinlog.000001
              Read_Master_Log_Pos: 1157
                   Relay_Log_File: mariadb-relay-bin.000002
                    Relay_Log_Pos: 1078
            Relay_Master_Log_File: mysqlbinlog.000001
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                  Replicate_Do_DB: mydata
              Replicate_Ignore_DB: 
               Replicate_Do_Table: 
           Replicate_Ignore_Table: 
          Replicate_Wild_Do_Table: 
      Replicate_Wild_Ignore_Table: 
                       Last_Errno: 0
                       Last_Error: 
                     Skip_Counter: 0
              Exec_Master_Log_Pos: 1157
                  Relay_Log_Space: 1374
                  Until_Condition: None
                   Until_Log_File: 
                    Until_Log_Pos: 0
               Master_SSL_Allowed: No
               Master_SSL_CA_File: 
               Master_SSL_CA_Path: 
                  Master_SSL_Cert: 
                Master_SSL_Cipher: 
                   Master_SSL_Key: 
            Seconds_Behind_Master: 0
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
                    Last_IO_Error: 
                   Last_SQL_Errno: 0
                   Last_SQL_Error: 
      Replicate_Ignore_Server_Ids: 
                 Master_Server_Id: 2
    1 row in set (0.00 sec)
    
    ERROR: No query specified
    slave 两个线程启动正确。o啦
    
  • 相关阅读:
    二维码的生成细节和原理
    java写入文件的几种方法分享
    实例讲解虚拟机3种网络模式(桥接、nat、Host-only)
    ARM平台安装Docker的方法
    ARM 平台Docker运行RabbitMQ 以及迁移的简单办法
    Oracle12c(未更新任何补丁) 使用compression=all 参数导出之后导入失败
    CentOS7 通过移植二进制文件的方式安装redis、nginx以及dotnet core的简单办法
    Oracle 以及 达梦数据库简单查询所有表行数的存储过程
    Java内存模型(转载)
    深入探讨 Java 类加载器(转载)
  • 原文地址:https://www.cnblogs.com/whereareyoufrom/p/5242802.html
Copyright © 2020-2023  润新知