zoukankan      html  css  js  c++  java
  • 5.7-多源复制搭建

    基本环境

      Master1 Master2 Slave
    MySQL版本 MySQL-5.7.16-X86_64 MySQL-5.7.16-X86_64 MySQL-5.7.16-X86_64
    IP 192.168.56.156 192.168.56.156 192.168.56.157
    Port 3306 3307 3306

    数据库环境的部署:
    两边安装好相同的数据库软件,初始化,可以启动起来。
     
    检查事项:
    两边防火墙是否开启,对应的端口号是否通(可以通过telnet的方式,或者远程登录的方式验证)
    每个实例上DB名字不能一样。
    创建或是复制用户时名字不能一样,如果经常遇到一样的帐号若是为了规范创建的帐号是一样的,考虑在slave的过滤规则把mysql复制忽略掉。
    多源复制是支持GTID和Binlog+Position。推荐使用GTID的方式。
     
     
    主库Master1配置:
     
    开启 log_bin 、server_id、gtid_mode、enforce_gtid_consistency、skip-slave-start、log_slave_updates 参数。
    server_id=15633006
    gtid_mode=on
    enforce_gtid_consistency=1
    skip-slave-start=1
    log_slave_updates=1
     
    主库Master2配置:
     
    开启 log_bin 、server_id、gtid_mode、enforce_gtid_consistency、skip-slave-start、log_slave_updates 参数。
    server_id=15633007
    gtid_mode=on
    enforce_gtid_consistency=1
    skip-slave-start=1
    log_slave_updates=1
     
    另外需要注意的是:
    binlog_format 控制二进制文件格式,生成环境建议使用row格式。
    log_bin_basename 控制二进制文件的路径和命名规则。
    server_id建议使用:端口号+IP最后一位的形式。
     
    主库Master1和Master2创建复制账号:
     
    create user 'repl'@'192.168.56.%' identified by 'oracle';
    grant replication slave on *.* to 'repl'@'192.168.56.%';
    flush privileges;
     
    创建完之后,在另外一台服务器测试是否能连接上。
    mysql -h 192.168.56.156 -urepl -p
     
    从库配置:
     
    开启 log_bin 、server_id、gtid_mode、enforce_gtid_consistency、skip-slave-start、log_slave_updates 参数。
    server_id=15733006
    gtid_mode=on
    enforce_gtid_consistency=1
    skip-slave-start=1
    log_slave_updates=1
    master_info_repository  =table
    relay_log_info_repository =table
     
    注意:主库和从库的server_id不能一样。
     
    mysql> show master status G;
    *************************** 1. row ***************************
                 File: mysql-bin.000005
             Position: 194
         Binlog_Do_DB: 
     Binlog_Ignore_DB: 
    Executed_Gtid_Set: b16b53da-c1a1-11e6-915f-000c29355816:1-21
    1 row in set (0.02 sec)
     
    在从库上执行:
    change master to master_host='192.168.56.156',master_user='repl',master_password='oracle',master_port=3306,MASTER_AUTO_POSITION = 1 for channel 'master-1563306';
     
    change master to master_host='192.168.56.156',master_user='repl',master_password='oracle',master_port=3307,MASTER_AUTO_POSITION = 1 for channel 'master-1563307';
     
     
    在从库上执行:
    mysql> start slave;
    Query OK, 0 rows affected (0.01 sec)
     
    在从库上查看状态:
    mysql> show slave status G;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.56.156
                      Master_User: repl
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000002
              Read_Master_Log_Pos: 769
                   Relay_Log_File: relay-bin-master@002d1563306.000002
                    Relay_Log_Pos: 414
            Relay_Master_Log_File: mysql-bin.000002
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                  Replicate_Do_DB: 
              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: 769
                  Relay_Log_Space: 634
                  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: 1563306
                      Master_UUID: a7d97e64-ded9-11e6-8a38-000c29355816
                 Master_Info_File: mysql.slave_master_info
                        SQL_Delay: 0
              SQL_Remaining_Delay: NULL
          Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
               Master_Retry_Count: 86400
                      Master_Bind: 
          Last_IO_Error_Timestamp: 
         Last_SQL_Error_Timestamp: 
                   Master_SSL_Crl: 
               Master_SSL_Crlpath: 
               Retrieved_Gtid_Set: 
                Executed_Gtid_Set: 124a7ca4-ded9-11e6-9d8d-000c29355816:1-7,
    2002367e-deda-11e6-a0de-000c299e3b2b:1,
    a7d97e64-ded9-11e6-8a38-000c29355816:1-3
                    Auto_Position: 1
             Replicate_Rewrite_DB: 
                     Channel_Name: master-1563306
               Master_TLS_Version: 
    *************************** 2. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.56.156
                      Master_User: rep2
                      Master_Port: 3307
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000002
              Read_Master_Log_Pos: 1549
                   Relay_Log_File: relay-bin-master@002d1563307.000002
                    Relay_Log_Pos: 1762
            Relay_Master_Log_File: mysql-bin.000002
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                  Replicate_Do_DB: 
              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: 1549
                  Relay_Log_Space: 1982
                  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: 1563307
                      Master_UUID: 124a7ca4-ded9-11e6-9d8d-000c29355816
                 Master_Info_File: mysql.slave_master_info
                        SQL_Delay: 0
              SQL_Remaining_Delay: NULL
          Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
               Master_Retry_Count: 86400
                      Master_Bind: 
          Last_IO_Error_Timestamp: 
         Last_SQL_Error_Timestamp: 
                   Master_SSL_Crl: 
               Master_SSL_Crlpath: 
               Retrieved_Gtid_Set: 124a7ca4-ded9-11e6-9d8d-000c29355816:1-7
                Executed_Gtid_Set: 124a7ca4-ded9-11e6-9d8d-000c29355816:1-7,
    2002367e-deda-11e6-a0de-000c299e3b2b:1,
    a7d97e64-ded9-11e6-8a38-000c29355816:1-3
                    Auto_Position: 1
             Replicate_Rewrite_DB: 
                     Channel_Name: master-1563307
               Master_TLS_Version: 
    2 rows in set (0.00 sec)
     
    关注上面 Slave_IO_Running 和 Slave_SQL_Running都是 Yes,表示已经连接上了master,说明已经成功。
     
     
     
     
     
     
     
  • 相关阅读:
    洛谷p1017 进制转换(2000noip提高组)
    Personal Training of RDC
    XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Eurasia
    XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof.
    Asia Hong Kong Regional Contest 2019
    XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Siberia
    XVIII Open Cup named after E.V. Pankratiev. Ukrainian Grand Prix.
    XVIII Open Cup named after E.V. Pankratiev. GP of SPb
    卜题仓库
    2014 ACM-ICPC Vietnam National First Round
  • 原文地址:https://www.cnblogs.com/l10n/p/9400745.html
Copyright © 2011-2022 走看看