实验环境:

192.168.132.121   master1

192.168.132.122   master2

192.168.132.123   slave

使用gtid的方式

两个主分别是192.168.132.121和192.168.132.122,一个从端192.168.132.123分别从两个主端同步数据

192.168.132.121 master1配置

[root@master ~]# cat /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=
datadir=/data/mysql
socket=/data/mysql/mysql.sock
user=mysql
skip-name-resolve
slow_query_log=on
long_query_time=
slow_query_log_file=/data/mysql/mysql-slow.log
innodb-file-per-table=
innodb_flush_log_at_trx_commit =
log_warnings =
connect_timeout =
net_read_timeout =
performance_schema_max_table_instances =
server-id =
gtid_mode=on
enforce_gtid_consistency=on
log-slave-updates=
log-bin=master-bin
log-bin-index = master-bin.index
relay-log = relay-log
relay-log-index = relay-log.index
binlog_format=row
auto_increment_offset=
auto_increment_increment= [mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid

[root@master ~]# mysql -uroot -p123456
mysql> grant replication slave on *.* to 'replication'@'192.168.132.122' identified by '';
mysql> grant replication slave on *.* to 'replication'@'192.168.132.123' identified by '';

192.168.132.122 master2配置

[root@master2 ~]# cat /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=
datadir=/data/mysql
socket=/data/mysql/mysql.sock
user=mysql
skip-name-resolve
slow_query_log=on
long_query_time=
slow_query_log_file=/data/mysql/mysql-slow.log
innodb-file-per-table=
innodb_flush_log_at_trx_commit =
log_warnings =
connect_timeout =
net_read_timeout =
performance_schema_max_table_instances =
server-id =
gtid_mode=on
enforce_gtid_consistency=on
log-slave-updates=
log-bin=master-bin
log-bin-index = master-bin.index
relay-log = relay-log
relay-log-index = relay-log.index
binlog_format=row
auto_increment_offset=
auto_increment_increment= [mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid [root@master2 ~]# mysql -uroot -p123456
mysql> grant replication slave on *.* to 'replication'@'192.168.132.121' identified by '';
mysql> grant replication slave on *.* to 'replication'@'192.168.132.123' identified by '';

192.168.132.123 slave配置

[root@slave ~]# cat /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=
datadir=/data/mysql
socket=/data/mysql/mysql.sock
user=mysql
skip-name-resolve
slow_query_log=on
long_query_time=
slow_query_log_file=/data/mysql/mysql-slow.log
innodb-file-per-table=
innodb_flush_log_at_trx_commit =
log_warnings =
connect_timeout =
net_read_timeout =
performance_schema_max_table_instances =
server-id =
gtid_mode=on
enforce_gtid_consistency=on
log-slave-updates=
log-bin=master-bin
log-bin-index = master-bin.index
relay-log = relay-log
relay-log-index = relay-log.index
binlog_format=row
auto_increment_offset=
auto_increment_increment= [mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid
[root@slave ~]# mysql -uroot -p123456

配置从库

mysql> change master to master_host='192.168.132.121',master_user='replication',master_port=,master_password='',master_auto_position= for channel 'master-1';
ERROR (HY000): To have multiple channels, repository cannot be of type FILE; Please check the repository configuration and convert them to TABLE.
mysql> show variables like '%repository%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| master_info_repository | FILE |
| relay_log_info_repository | FILE |
+---------------------------+-------+

需要设置convert表

/etc/my.cnf
[mysqld] #添加
master_info_repository=TABLE
relay_log_info_repository=TABLE

[root@slave ~]# systemctl restart mysqld

[root@slave ~]# mysql -uroot -p123456

mysql> show variables like '%repository%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| master_info_repository | TABLE |
| relay_log_info_repository | TABLE |
+---------------------------+-------+
mysql> change master to master_host='192.168.132.121',master_user='replication',master_port=,master_password='',master_auto_position= for channel 'master-1';
mysql> change master to master_host='192.168.132.122',master_user='replication',master_port=,master_password='',master_auto_position= for channel 'master-2';

查看从端状态

mysql> start slave;
Query OK, rows affected (0.01 sec) mysql> show slave status\G;
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.132.121
Master_User: replication
Master_Port:
Connect_Retry:
Master_Log_File: master-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-log-master@002d1.
Relay_Log_Pos:
Relay_Master_Log_File: master-bin.
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:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 63a7f26f-a196-11e9-a2b2-000c2991dd19
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 63a7f26f-a196-11e9-a2b2-000c2991dd19:-
Executed_Gtid_Set: 5ad46c94-a197-11e9--000c29f004c9:,
63a7f26f-a196-11e9-a2b2-000c2991dd19:-,
662134df-a196-11e9-b432-000c2963fd11:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name: master-1 #通道1,连接master1
Master_TLS_Version:
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.132.122
Master_User: replication
Master_Port:
Connect_Retry:
Master_Log_File: master-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-log-master@002d2.
Relay_Log_Pos:
Relay_Master_Log_File: master-bin.
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:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 662134df-a196-11e9-b432-000c2963fd11
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 662134df-a196-11e9-b432-000c2963fd11:-
Executed_Gtid_Set: 5ad46c94-a197-11e9--000c29f004c9:,
63a7f26f-a196-11e9-a2b2-000c2991dd19:-,
662134df-a196-11e9-b432-000c2963fd11:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name: master-2 #通道2,连接master2
Master_TLS_Version:

查看进程

mysql> show processlist;
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| | root | localhost | NULL | Query | | starting | show processlist |
| | system user | | NULL | Connect | | Waiting for master to send event | NULL |
| | system user | | NULL | Connect | | Slave has read all relay log; waiting for more updates | NULL |
| | system user | | NULL | Connect | | Waiting for master to send event | NULL |
| | system user | | NULL | Connect | | Slave has read all relay log; waiting for more updates | NULL |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+

验证

master1
mysql> create database master1;
Query OK, row affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| master1 |
| mysql |
| performance_schema |
| sys |
+--------------------+
master2
mysql> create database master2;
Query OK, row affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| master2 |
| mysql |
| performance_schema |
| sys |
+--------------------+
slave查看 #已经同步
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| master1 |
| master2 |
| mysql |
| performance_schema |
| sys |
+--------------------+

多源复制,配置完成

mysql主从之多元复制的更多相关文章

  1. 高性能Mysql主从架构的复制原理及配置详解

    温习<高性能MySQL>的复制篇. 1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台 ...

  2. Mysql主从同步(复制)

    目录: mysql主从同步定义      主从同步机制 配置主从同步      配置主服务器      配置从服务器 使用主从同步来备份      使用mysqldump来备份      备份原始文件 ...

  3. 转:高性能Mysql主从架构的复制原理及配置详解

    温习<高性能MySQL>的复制篇. 1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台 ...

  4. 高性能Mysql主从架构的复制原理及配置详解(转)

    温习<高性能MySQL>的复制篇. 1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台 ...

  5. Mysql主从同步(复制)(转)

    文章转自:https://www.cnblogs.com/kylinlin/p/5258719.html 目录: mysql主从同步定义 主从同步机制 配置主从同步 配置主服务器 配置从服务器 使用主 ...

  6. 高性能Mysql主从架构的复制原理及配置

    1. 复制概述 1.1 mysql支持的复制类型 1.2 复制解决的问题 1.3 复制如何工作 2. 2 复制配置 2.1创建复制帐号 2.2拷贝数据 2.3配置master 2.4配置slave 2 ...

  7. MySQL主从双向同步复制

    本文介绍了mysql主从,实现mysql的双向同步复制. MySQL支持单向.异步复制,复制过程中一个服务器充当主服务器,而一个或多个其它服务器充当从服务器.主服务器将更新写入二进制日志文件,并维护日 ...

  8. Mysql学习总结(18)——Mysql主从架构的复制原理及配置详解

    一.复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台主机的数据复制到其它主机(slaves)上,并重 ...

  9. Mysql主从架构的复制

    复制类型 (1)基于语句的复制:  在主服务器上执行的SQL语句,在从服务器上执行同样的语句.MySQL默认采用基于语句的复制,效率比较高.  一旦发现没法精确复制时,会自动选着基于行的复制. (2) ...

随机推荐

  1. IO NIO AIO及常用框架概述

    概述 nio 同步: 自己亲自出马持银行卡到银行取钱(使用同步IO时,Java自己处理IO读写). 异步: 委托一小弟拿银行卡到银行取钱,然后给你(使用异步IO时,Java将IO读写委托给OS处理,需 ...

  2. Lambda plus: 云上大数据解决方案

    本文会简述大数据分析场景需要解决的技术挑战,讨论目前主流大数据架构模式及其发展.最后我们将介绍如何结合云上存储.计算组件,实现更优的通用大数据架构模式,以及该模式可以涵盖的典型数据处理场景. 大数据处 ...

  3. 对比MySQL,一文看透HBase的能力及使用场景

    MySQL + HBase 是我们日常应用中常用的两个数据库,分别解决应用的在线事务问题和大数据场景的海量存储问题. 本文内容适合初次理解HBase的读者,包括技术.功能及场景,也欢迎老司机们补充和温 ...

  4. Linux 运算符

    布尔运算符 下表列出了常用的布尔运算符,假定变量a为10 变量b为20: 运算符  说明 举例 ! 非运算 , 表达式为true 则返回false 否则返回true  [!false] 返回true. ...

  5. pytorch bert 源码解读

    https://daiwk.github.io/posts/nlp-bert.html 目录 概述 BERT 模型架构 Input Representation Pre-training Tasks ...

  6. @codeforces - 708D@ Incorrect Flow

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个有源点与汇点的图 G,并对于每一条边 (u, v) 给定 ...

  7. PHP实现图片的等比缩放和Logo水印功能示例

    文章来自于:脚本之家 文章链接:https://www.jb51.net/article/112909.htm 这篇文章主要介绍了PHP实现图片的等比缩放和Logo水印功能,结合实例形式分析了php图 ...

  8. 神经网络入门——7or 感知器

    OR 感知器 OR 感知器与 AND 感知器很类似,在下图中,OR 感知器与 AND 感知器有相同的分割线,只是 OR 感知器分割线下移了一段距离.对权重或者偏置做怎样的设置可以实现这个效果?用下面的 ...

  9. SQL server无法绑定由多个部分绑定的标示符

    原因https://blog.csdn.net/wolfalcon/article/details/54578215给了我启发,原来有犯错在insert和update的使用上了对于已存在的表(表中有字 ...

  10. JS精度问题,解决方案 math.js

    JS精度问题    Vue中使用 解决方案 math.js npm install mathjs import { create, all } from 'mathjs' const config = ...