多源复制和多主复制的区别:

多主复制示意图:

多源复制示意图:

在my.cnf中添加crash safe特性参数:
master_info_repository=TABLE;
relay_log_info_repository=TABLE;

mysql> change master to master_host="10.186.21.102", master_port=13306, master_user="repl",master_password="repl" for channel="master1";
Query OK, 0 rows affected(0.01 sec)

mysql> change master to master_host="10.186.21.102", master_port=13307, master_user="repl",master_password="repl" for channel="master2";
Query OK, 0 rows affected (0.01 sec)

mysql> select * from mysql.slave_master_info;
+-----------------+-----------------+----------------+---------------+-----------+---------------+-------+---------------+-------------+--------+------------+----------+------------+---------+------------------------+-----------+------+--------------------+------+-------------+---------+-------------+-----------------------+--------------+
| Number_of_lines | Master_log_name | Master_log_pos | Host          | User_name | User_password | Port  | Connect_retry | Enabled_ssl | Ssl_ca | Ssl_capath | Ssl_cert | Ssl_cipher | Ssl_key | Ssl_verify_server_cert | Heartbeat | Bind | Ignored_server_ids | Uuid | Retry_count | Ssl_crl | Ssl_crlpath | Enabled_auto_position | Channel_name |
+-----------------+-----------------+----------------+---------------+-----------+---------------+-------+---------------+-------------+--------+------------+----------+------------+---------+------------------------+-----------+------+--------------------+------+-------------+---------+-------------+-----------------------+--------------+
|              24 |                 |              4 | 10.186.21.102 | repl      | repl          | 13306 |            60 |           0 |        |            |          |            |         |                      0 |      1800 |      | 0                  |      |       86400 |         |             |                     0 | master1      |
|              24 |                 |              4 | 10.186.21.102 | repl      | repl          | 13307 |            60 |           0 |        |            |          |            |         |                      0 |      1800 |      | 0                  |      |       86400 |         |             |                     0 | master2      |
+-----------------+-----------------+----------------+---------------+-----------+---------------+-------+---------------+-------------+--------+------------+----------+------------+---------+------------------------+-----------+------+--------------------+------+-------------+---------+-------------+-----------------------+--------------+
2 rows in set (0.00 sec)

mysql> select * from slave_relay_log_info  ;
+-----------------+------------------------------------+---------------+-----------------+----------------+-----------+-------------------+----+--------------+
| Number_of_lines | Relay_log_name                     | Relay_log_pos | Master_log_name | Master_log_pos | Sql_delay | Number_of_workers | Id | Channel_name |
+-----------------+------------------------------------+---------------+-----------------+----------------+-----------+-------------------+----+--------------+
|               7 | ./mha-db1-relay-bin-master1.000001 |             4 |                 |              0 |         0 |                 0 |  1 | master1      |
|               7 | ./mha-db1-relay-bin-master2.000001 |             4 |                 |              0 |         0 |                 0 |  1 | master2      |
+-----------------+------------------------------------+---------------+-----------------+----------------+-----------+-------------------+----+--------------+

mysql> start slave for channel="master2";
Query OK, 0 rows affected (0.01 sec)

mysql> start slave for channel="master1";
Query OK, 0 rows affected (0.01 sec)

mysql> show slave status for channel="master1"\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.186.21.102
                  Master_User: repl
                  Master_Port: 13306
                Connect_Retry: 60
              Master_Log_File: log_bin.000001
          Read_Master_Log_Pos: 120
               Relay_Log_File: mha-db1-relay-bin-master1.000002
                Relay_Log_Pos: 281
        Relay_Master_Log_File: log_bin.000001
             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: 120
              Relay_Log_Space: 464
              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: 13306
                  Master_UUID: 546b04cc-9621-11e3-95d5-0a98756bb836
             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 the slave I/O thread to update it
           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:
                Auto_Position: 0
1 row in set (0.00 sec)

mysql> show slave status for channel="master2"\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.186.21.102
                  Master_User: repl
                  Master_Port: 13307
                Connect_Retry: 60
              Master_Log_File: log_bin.000001
          Read_Master_Log_Pos: 120
               Relay_Log_File: mha-db1-relay-bin-master2.000002
                Relay_Log_Pos: 281
        Relay_Master_Log_File: log_bin.000001
             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: 120
              Relay_Log_Space: 464
              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: 13307
                  Master_UUID: fba8d917-9621-11e3-95d9-0a98756bb836
             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 the slave I/O thread to update it
           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:
                Auto_Position: 0
1 row in set (0.00 sec)

master1:
mysql> create database master1;

master2:
mysql> create database master2;

slave:
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| master1            |
| master2            |
| mysql              |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.00 sec)

重启slave命令:
mysql> stop slave for channel="master1";
Query OK, 0 rows affected (0.00 sec)

mysql> stop slave for channel="master2";
Query OK, 0 rows affected (0.01 sec)

重做slave命令:
mysql> reset slave for channel="master2";
Query OK, 0 rows affected (0.33 sec)

mysql> reset slave for channel="master1";
Query OK, 0 rows affected (0.30 sec)

 

多源复制存在问题:

多源数据库不能有同名库,否则会导致复制失败

master1:

mysql> create database master1;

Query OK, 1 row affected (0.00 sec)

master2:

mysql> create database master2;

Query OK, 1 row affected (0.00 sec)

mysql> create database master1;

Query OK, 1 row affected (0.00 sec)

slave:

show slave status for channel="master2"\G;

Last_SQL_Error: Error 'Can't create database 'master2'; database exists' on query. Default database: 'master2'. Query: 'create database master2'

初试mysql5.7.2新特性:多源复制(MySQL 5.7 multi-source replication)的更多相关文章

  1. MySQL5.6 GTID新特性实践

    MySQL5.6 GTID新特性实践 GTID简介 搭建 实验一:如果slave所需要事务对应的GTID在master上已经被purge了 实验二:忽略purged的部分,强行同步 本文将简单介绍基于 ...

  2. MySQL5.7的新特性

    MySQL 5.7版本据说已经在了很大的性能提升以及做得更加安全了,想了解更多MySQL 5.7的新特性可以参考我转载叶金荣老师的MySQL 5.7的新特性说明.这里我简单演示一下MySQL 5.7的 ...

  3. 利用Mysql5.7的新特性实现多机房高可用架构【转】

    再牛逼的架构也敌不过挖掘机,无论单机房内你的架构多么的高可用,多么的完善,当挖掘机挖下去那一瞬间,都是扯蛋,楼主所在的公司也被挖掘机挖断过光纤.电力线. 为什么大家都在谈论服务冗余,缓存击穿等高可用时 ...

  4. MySQL5.6新特性Index conditontion pushdow

    index condition pushdown是MySQL5.6的新特性,主要是对MySQL索引使用的优化. Index condition push简称ICP,索引条件下推,将索引条件从serve ...

  5. 重新想象 Windows 8.1 Store Apps (84) - 图像处理的新特性, Share Contract 的新特性

    [源码下载] 重新想象 Windows 8.1 Store Apps (84) - 图像处理的新特性, Share Contract 的新特性 作者:webabcd 介绍重新想象 Windows 8. ...

  6. MySql5.7-多源复制(多主单从)

    1.1.主库配置 my.cnf   #确保唯一 server-id=1 #作为Master要开启binlog log-bin=mysql-bin #binlog format有三种形式:Stateme ...

  7. MySQL新特性MTS

    一.MTS:多线程复制 MTS简介 在MySQL 5.6版本之前,Slave服务器上有两个线程I/O线程和SQL Thread线程.I/O线程负责接收二进制日志(Binary Log,更准确的说是二进 ...

  8. MySQL多源复制(八)

    一.什么是多源复制 MySQL 5.7发布后,在复制方面有了很大的改进和提升.比如开始支持多源复制(multi-source)以及真正的支持多线程复制了.多源复制可以使用基于二进制日志的复制或者基于事 ...

  9. MySQL 5.7--多源复制(非GTID模式)

    ==================================================== 在MYSQL5.7版本中引入多源复制,一个从库允许复制多个主库的数据,每个主库被配置为一个单独 ...

随机推荐

  1. CentOS使用安装光盘建立本地软件源

    本实验的目的是使用CentOS的两张DVD安装光盘作为本地软件源,避免执行yum安装命令时每次都要从网络重新下载. 安装createrepo软件包 createrepo是制作软件源所需要的一个工具,默 ...

  2. Shader的函数公式以及使用的场景

    Shader 是干什么的? 它的作用可以先简单理解为对屏幕上的物体,进行颜色处理. 而大家都知道,所有计算机,处理颜色的当然是显卡,也就是 GPU . 所以我们写 Shader 的目的就是告诉 GPU ...

  3. rm: 无法删除"xxxx.dir": 是一个目录

    rm命令 -f:在删除过程中不给任何指示,直接删除. -r:将参数中列出的全部目录和子目录都递归地删除. -i:与-f选项相反,交互式删除,在删除每个文件时都给出提示. 删除文件可以直接使用rm命令, ...

  4. CTF之当铺密码

    当铺密码即:汉字的笔画有几笔出头,则代表数字几 例如:由=1 王=6 大=5

  5. 2018-2019-2 20165212《网络对抗技术》Exp1 PC平台逆向破解

    2018-2019-2 20165212<网络对抗技术>Exp1  缓冲区溢出实验 实验点1:逆向及Bof基础实践 实践任务 用一个pwn1文件. 该程序正常执行流程是:main调用foo ...

  6. 解决安装vmware-tools出现的“The path "" is not a valid path to the 3.2.0-4-amd64 kernel headers”问题

    在用虚拟机安装使用64位Crunchbang(一种Debian GNU/Linux 的linux)的过程中出现很多小问题.其中vmware-tools安装就是第一个问题. 在使用终端安装vmware- ...

  7. RPC好,还是RESTful好?

    看到知乎上有这样一个问题 WEB开发中,使用JSON-RPC好,还是RESTful API好? 还有其他优秀的推荐方案吗? -------------------------------------- ...

  8. Android和Linux下设备节点的创建笔记

    1. Linux kernel创建的/dev/下的设备节点是不对的, 其实是kernel仅负责在/sys/(基于内存的虚拟文件系统)创建一大堆下目录和文件,而真正的设备节点是在用户空间程序创建的,应该 ...

  9. Oracle plsql乱码

    方法1.执行  set NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK 方法2.执行--regedit--查找--NLS_LANG--设置值 SIMPLIFIED ...

  10. 廖雪峰 ---- Python教程

    这是小白的Python新手教程,具有如下特点: 中文,免费,零起点,完整示例,基于最新的Python 3版本. Python是一种计算机程序设计语言.你可能已经听说过很多种流行的编程语言,比如非常难学 ...