MySQL Labs : 
Multi Source Replication 
Venkatesh Duggirala 
MySQL Replication Team 
1 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Safe Harbour Statement 
The following is intended to outline our general product direction. It is intended for 
information purposes only, and may not be incorporated into any contract. 
It is not a commitment to deliver any material, code, or functionality, and should not 
be relied upon in making purchasing decisions. The development, release, and 
timing of any features or functionality described for Oracle’s products remains at the 
sole discretion of Oracle. 
2 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
MySQL Labs features are not fit for production. 
They are provided solely for testing purposes, to try the latest bug fixes and 
generally to keep up with the development. 
Please, do not use these binaries in production. 
Instead, install them on a spare server. 
If you are looking for production ready binaries, please visit MySQL Downloads. 
3 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Agenda 
 Background: Why Use Replication? 
 Multi-source Replication 
– Introduction 
– Use cases 
– Internals 
– Monitoring 
 Reading More about Multi-source Replication 
4 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Background: What is Replication Used For? 
 Redundancy: If master crashes, promote slave to master 
Uh Oh! Whew! 
C 
B 
A 
C 
B 
CraAsh 
5 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
C 
B 
A 
B is the 
new master
Background: What is Replication Used For? 
 Read scale-out 
M S 
More 
reads? 
More 
slaves! 
6 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
S 
S 
S 
M 
write clients 
write clients read clients read clients
Background: What is Replication Used For? 
 On-line Backup and Reporting 
M 
7 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
S 
 write clients 
 business intelligent client apps 
 reporting client apps 
 big queries client apps
 
Different types of Replication servers setup 
M 
S 
1 
8 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
 
Different types of Replication servers setup 
M 
S 
M 
S1 S2 
1 2 
9 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
 
Different types of Replication servers setup 
M 
S 
M 
S1 S2 
M1 
M2 
S 
1 2 3 
10 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
 
Different types of Replication servers setup 
M 
S 
M 
S1 S2 
M1 
M2 
S 
M1 M2 
11 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
S 
1 2 3 4
 
Different types of Replication servers setup 
12 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
M 
M 
M 
M 
M S 
M 
S1 S2 
M1 
M2 
S 
M1 M2 
S 
1 2 3 4 5
Agenda 
 Background: Why Use Replication? 
 Multi-source Replication 
– Introduction 
– Use cases 
– Internals 
– Monitoring 
 Reading More about Multi-source Replication 
13 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Before Multi-source replication : 
● Time sharing replication, where a slave would connect to a master 
for a particular time slice. 
● Have a hierarchical replication, where a slave that is to receive 
updates from the several masters is at the end of replication 
hierarchy. (Like, M1->M2->M3->Slave) 
● Using several instances of mysqlbinlog + GTIDs. 
Multi-source replication feature aims to: 
● Receive transactions (in the form of binary log events) from 
several MySQL servers simultaneously via several 
communication channels. 
● Apply these received transactions (will not do any conflict 
detection or resolution) 
14 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Multi-Source Replication: Introduction 
 A Slave can have more than one master. 
M1 
M2 
M3 
15 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
S 
M4
Multi-Source Replication: Introduction 
 A Slave can have more than one master. 
db1 M1 
16 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Multi-Source Replication: Introduction 
 A Slave can have more than one master. 
M1 
M2 
db1 
db2 
17 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Multi-Source Replication: Introduction 
 A Slave can have more than one master. 
M1 
M2 
M3 
M4 
db1 
db2 
db3 
db4 
18 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Multi-Source Replication: Introduction 
 A Slave can have more than one master. 
M1 
M2 
M3 
db2 
db3 
19 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
S db1 db2 db3 db4 
M4 
db1 
db4
Agenda 
 Background: Why Use Replication? 
 Multi-source Replication 
– Introduction 
– Use cases 
– Internals 
– Monitoring 
 Reading More about Multi-source Replication 
20 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Multi-Source Replication: Use Cases 
The main use cases of Multi-source replication are related to data aggregation. 
M1 
21 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
Business Intelligence 
Data analytics 
Backup 
etc 
M2 S 
M3 
Database 2 
Database 3 
Database 1, 2, 3 
Database 1
Multi-Source Replication: Use Cases 
The main use cases of Multi-source replication are related to data aggregation. 
M 
M S 
M 
Shard 2 
Shard 3 
22 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
Full table 
Shard 1
Agenda 
 Background: Why Use Replication? 
 Multi-source Replication 
– Introduction 
– Use cases 
– Internals 
– Monitoring 
 Reading More about Multi-source Replication 
23 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Multi-Source Replication: More details.. 
M1 
M2 
M3 
24 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
S 
M4 
 Slave can have more than one 
master. 
– Receive transactions from 
several MySQL servers 
simultaneously. 
– Apply transactions from 
different masters 
simultaneously. 
– No conflict detection or 
resolution.
Multi-Source Replication: What is a Channel? 
 A channel is an an abstraction for a sender-receiver-applier path. 
Insert... 
Sender 
thread 
25 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
Insert... 
B 
binary log 
relay log 
Insert... 
Insert... 
A 
binary log 
Client 
Network 
Receiver 
thread Applier 
thread 
Channel
Multi-Source Replication: How Many Channels? 
 Number of channels on slave = Number of sources. 
26 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
S 
M1 binary log Network relay log1 
M2 binary log Network relay log2 
M3 binary log Network relay log3 
binary log
Multi-Source Replication: Slave Appliers 
 Each channel has its own single-threaded slave applier. 
M1 binary log Network relay log1 
M2 binary log Network relay log2 
M3 binary log Network relay log3 
27 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
binary log S
Multi-Source Replication: Slave Appliers 
 Each channel can also have its own multi-threaded slave applier. 
28 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
binary log 
M1 binary log Network 
M2 S 
M3 
Network relay log2 
Network rreellaayy lloogg33 
binary log 
binary log 
relay log1
Adding / Configuring A Channel 
 Each channel can be configured individually. 
 To add or alter a channel configuration use: 
CHANGE MASTER TO master_def … 
FOR CHANNEL ”<channel_name>” 
– Channel names are case insensitive 
– Special chars are allowed 
– maximum number of channels is 256 
29 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Replication Commands on a Channel 
 FOR CHANNEL ”<channel_name>” clause is added for: 
– start slave [thread_type] FOR CHANNEL ”<channel_name>" 
– stop slave [thread_type] FOR CHANNEL ”<channel_name>” 
– reset slave [all] FOR CHANNEL ”<channel_name>” 
– flush relay logs FOR CHANNEL ”<channel_name>” 
– show relay log events FOR CHANNEL ”<channel_name>” 
 An extra argument added for functions like 
– MASTER_POS_WAIT(<binlog_file>, <binlog_pos>, <time_out>, 
<channel_name>); 
– WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS(<gtid_set>, <time_out>, 
<channel_name>); 
30 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Working With All Channels 
 To make commands work on ALL CHANNELS 
– START SLAVE [thread_type] 
– STOP SLAVE [thread_type] 
– SHOW SLAVE STATUS 
– FLUSH RELAY LOGS 
 ER_SLAVE_MULTIPLE_CHANNELS_CMD(1964) 
– SHOW RELAYLOG EVENTS; 
– CHANGE MASTER 
– MASTER_POS_WAIT() 
– WAIT_FOR_SQL_THREAD_AFTER_GTIDS() 
31 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Compatibility With Other Replication Features 
Multi-Threaded Slaves Yes 
Global Transaction Identifiers Yes 
Semi-Synchronous Replication Yes* 
Slave Repositories Yes* 
Filters Yes* 
32 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Compatibility continued 2... 
Multi threaded slaves: 
slave_parallel_workers=k and M channels will have (k+1)*M applier threads running. 
GTIDs: 
A requirement as is the case with (normal master-slave replication), is that all the masters 
and the slave should have GTID_MODE=ON. 
Semi-Synchronous Replication: 
all the masters and the slave should be in semi sync mode 
Filters: 
replication filters are global in the labs release, ie. the applier threads of all channels will 
rely on a single global filter. 
33 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Compatibility continued 3... 
Slave Repositories: 
 Only TABLE repository is supported (Crash safe slave) 
 --mysqld= --master_info_repository= TABLE; 
 --mysqld= --relay_log_info_repository= TABLE; 
 Convert FILE repository to TABLE repository dynamically 
 STOP SLAVE; 
 SET GLOBAL master_info_repository= 'TABLE'; 
 SET GLOBAL relay_log_info_repository= 'TABLE'; 
34 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Simple Setup 
✔ Start 3 servers 
35 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Simple Setup 
36 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
13000 13001 
M1 M2 
13002 
S 
✔ Start 3 servers , M1 (13000), M2 (13001), S (13002)
Simple Setup 
37 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
13000 13001 
M1 M2 
13002 
S 
✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) 
✔ On Slave(S), 
> CHANGE MASTER TO MASTER_PORT=13000,..., 
FOR CHANNEL 'CHANNEL_M1'; 
✔CHANNEL_M1 is created 
channel_m1
Simple Setup 
38 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
master1-bin.000001 
13000 13001 
M1 M2 
13002 
S 
✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) 
✔ On Slave(S), 
> CHANGE MASTER TO MASTER_PORT=13000,..., 
FOR CHANNEL 'CHANNEL_M1'; 
✔CHANNEL_M1 is created 
> START SLAVE FOR CHANNEL 'CHANNEL_M1' 
✔ I/O thread for CHANNEL_M1 will be created 
✔ M1's binary log (table t1 changes) will be retrieved by I/O thread 
and written to slave-relay-bin-channel_m1.00001 relay log 
✔ SQL thread will start reading it from relay log and will start applying 
the data. 
channel_m1 
insert into t1(..) 
insert into t1(..) 
Slave-relay-bin-channel_ 
m1.000001
Simple Setup 
39 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
master1-bin.000001 
insert into t1(..) 
13000 13001 
M1 M2 
13002 
S 
✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) 
✔ On Slave(S), 
> CHANGE MASTER TO MASTER_PORT=13000,..., 
FOR CHANNEL 'CHANNEL_M1'; 
✔CHANNEL_M1 is created 
> START SLAVE FOR CHANNEL 'CHANNEL_M1' 
✔ I/O thread for CHANNEL_M1 will be created 
✔ M1's binary log (table t1 changes) will be retrieved by I/O thread 
and written to slave-relay-bin-channel_m1.00001 relay log 
✔ SQL thread will start reading it from relay log and will start applying 
the data. 
> CHANGE MASTER TO MASTER_PORT=13001,..., 
FOR CHANNEL 'CHANNEL_M2' 
✔ CHANNEL_M2 is created 
channel_m1 channel_m2 
insert into t1(..) 
Slave-relay-bin-channel_ 
m1.000001
Simple Setup 
40 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
master1-bin.000001 
insert into t1(..) 
master2-bin.000002 
insert into t2(..) 
13000 13001 
M1 M2 
13002 
S 
✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) 
✔ On Slave(S), 
> CHANGE MASTER TO MASTER_PORT=13000,..., 
FOR CHANNEL 'CHANNEL_M1'; 
✔CHANNEL_M1 is created 
> START SLAVE FOR CHANNEL 'CHANNEL_M1' 
✔ I/O thread for CHANNEL_M1 will be created 
✔ M1's binary log (table t1 changes) will be retrieved by I/O thread 
and written to slave-relay-bin-channel_m1.00001 relay log 
✔ SQL thread will start reading it from relay log and will start applying 
the data. 
> CHANGE MASTER TO MASTER_PORT=13001,..., 
FOR CHANNEL 'CHANNEL_M2' 
✔ CHANNEL_M2 is created 
> START SLAVE FOR CHANNEL 'CHANNEL_M2' 
✔ I/O thread for CHANNEL_M2 will be created 
✔ M2's binary log (table t2 changes) will be retrieved by I/O thread 
and written to slave-relay-bin-channel_m2.00001 relay log 
✔ SQL thread will start reading it from relay log and will start applying 
the data. 
channel_m1 channel_m2 
insert into t1(..) insert into t2(..) 
Slave-relay-bin-channel_ 
m1.000001 
Slave-relay-bin-channel_ 
m2.000001
Simple Setup 
41 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
master1-bin.000001 
insert into t1(..) 
insert into t1(..) 
master2-bin.000002 
insert into t2(..) 
insert into t2(..) 
13000 13001 
M1 M2 
13002 
S 
✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) 
✔ On Slave(S), 
> CHANGE MASTER TO MASTER_PORT=13000,..., 
FOR CHANNEL 'CHANNEL_M1'; 
✔CHANNEL_M1 is created 
> START SLAVE FOR CHANNEL 'CHANNEL_M1' 
✔ I/O thread for CHANNEL_M1 will be created 
✔ M1's binary log (table t1 changes) will be retrieved by I/O thread 
and written to slave-relay-bin-channel_m1.00001 relay log 
✔ SQL thread will start reading it from relay log and will start applying 
the data. 
> CHANGE MASTER TO MASTER_PORT=13001,..., 
FOR CHANNEL 'CHANNEL_M2' 
✔ CHANNEL_M2 is created 
> START SLAVE FOR CHANNEL 'CHANNEL_M2' 
✔ I/O thread for CHANNEL_M2 will be created 
✔ M2's binary log (table t2 changes) will be retrieved by I/O thread 
and written to slave-relay-bin-channel_m2.00001 relay log 
✔ SQL thread will start reading it from relay log and will start applying 
the data. 
channel_m1 channel_m2 
insert into t1(..) 
insert into t1(..) 
insert into t2(..) 
insert into t2(...) 
Slave-relay-bin-channel_ 
m1.000001 
Slave-relay-bin-channel_ 
m2.000001
Agenda 
 Background: Why Use Replication? 
 Multi-source Replication 
– Introduction 
– Use cases 
– Internals 
– Monitoring 
 Reading More about Multi-source Replication 
42 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Replication Monitoring: P_S Replication Tables 
Connection 
Configuration 
Connection 
Status 
43 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
Execution 
Configuration 
Execution 
Status 
Slave Status 
Applier / Coordinator 
Status 
Workers 
Status
Replication Monitoring: P_S Replication Tables 
 We have six performance schema tables for replication 
– replication_connection_configuration 
– replication_connection_status 
– replication_execute_configuration 
– replication_execute_status 
– replication_execute_status_by_coordinator 
– replication_execute_status_by_worker 
 Consistent semantics across tables. Lets explore one of them. 
44 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
One row per CHANNEL 
One row per CHANNEL per WORKER
45 
Replication Monitoring: Connection Status 
mysql> select * from performance_schema.replication_connection_statusG 
*************************** 1. row *************************** 
CHANNEL_NAME : channel1 
SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b 
THREAD_ID : 13 
SERVICE_STATE : ON 
RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 
LAST_ERROR_NUMBER : 0 
LAST_ERROR_MESSAGE : 
LAST_ERROR_TIMESTAMP : 0000-00-00 00:00:00 
*************************** 2. row *************************** 
CHANNEL_NAME : channel2 
... 
45 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
One row per CHANNEL
46 
Replication Monitoring: Connection Status 
mysql> select * from performance_schema.replication_connection_statusG 
*************************** 1. row *************************** 
CHANNEL_NAME : channel1 
SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b 
THREAD_ID : 13 
SERVICE_STATE : ON 
RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 
LAST_ERROR_NUMBER : 0 
LAST_ERROR_MESSAGE : 
LAST_ERROR_TIMESTAMP : 0000-00-00 00:00:00 
*************************** 2. row *************************** 
CHANNEL_NAME : channel2 
... 
46 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
Receiver thread & 
its service state
47 
Replication Monitoring: Connection Status 
mysql> select * from performance_schema.replication_connection_statusG 
*************************** 1. row *************************** 
CHANNEL_NAME : channel1 
SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b 
THREAD_ID : 13 
SERVICE_STATE : ON 
RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 
LAST_ERROR_NUMBER : 0 
LAST_ERROR_MESSAGE : 
LAST_ERROR_TIMESTAMP : 0000-00-00 00:00:00 
*************************** 2. row *************************** 
CHANNEL_NAME : channel2 
... 
47 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
Set of transactions received 
through this channel
48 
Replication Monitoring: Connection Status 
mysql> select * from performance_schema.replication_connection_statusG 
*************************** 1. row *************************** 
CHANNEL_NAME : channel1 
SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b 
THREAD_ID : 13 
SERVICE_STATE : ON 
RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 
LAST_ERROR_NUMBER : 1045 
LAST_ERROR_MESSAGE : error connecting to master 'replssl@127.0.0.1:13000' ... 
LAST_ERROR_TIMESTAMP : 2013-11-04 13:37:23 
*************************** 2. row *************************** 
CHANNEL_NAME : channel2 
... 
Oops! There was an error in the 
receiver thread on this channel 
48 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
49 
Replication Monitoring: Connection Status 
mysql> select * from performance_schema.replication_connection_statusG 
*************************** 1. row *************************** 
CHANNEL_NAME : channel1 
SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b 
THREAD_ID : NULL 
SERVICE_STATE : OFF 
RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 
LAST_ERROR_NUMBER : 1045 
LAST_ERROR_MESSAGE : error connecting to master 'replssl@127.0.0.1:13000' ... 
LAST_ERROR_TIMESTAMP : 2013-11-04 13:37:23 
*************************** 2. row *************************** 
CHANNEL_NAME : channel2 
... 
49 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 
Receiver thread on this 
channel stopped serving...
Agenda 
 Background: Why Use Replication? 
 Multi-source Replication 
– Introduction 
– Use cases 
– Internals 
– Monitoring 
 Reading More about Multi-source Replication 
50 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
Read More About Multi Source Replication 
 Read a feature preview of Multi-source replication on Rith's blog: 
http://on-mysql-replication.blogspot.in/2013/09/feature-preview-mysql-multi 
-source-replication.html 
 Read more about Multi-source replication on Rith's blog: 
http://mysqlhighavailability.com/5-7-5-labs-multi-source-replication/ 
 Read more about replication P_S tables on Shiv's blogs: 
http://shivjijha.blogspot.com/2013/09/Monitoring-Replication-with-the-NEW-pe 
rformance-schema-tables.html 
http://mysqlhighavailability.com/global-variables-in-rpl-ps/ 
 Official MySQL documentation for replication P_S tables: 
http://dev.mysql.com/doc/refman/5.7/en/performance-schema-replication-tables 
.html 
51 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |

More Related Content

PPTX
Containers and workload security an overview
PDF
Java is Container Ready - Vaibhav - Container Conference 2018
PDF
Kubernetes Networking - Sreenivas Makam - Google - CC18
PPTX
[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫
PPTX
Introduction of tomcat
PPTX
Terraform day 1
PDF
Power of Choice in Docker EE 2.0 - Anoop - Docker - CC18
PDF
Galera Cluster: Synchronous Multi-Master Replication for MySQL HA
Containers and workload security an overview
Java is Container Ready - Vaibhav - Container Conference 2018
Kubernetes Networking - Sreenivas Makam - Google - CC18
[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫
Introduction of tomcat
Terraform day 1
Power of Choice in Docker EE 2.0 - Anoop - Docker - CC18
Galera Cluster: Synchronous Multi-Master Replication for MySQL HA

Similar to Multi source replication pdf (20)

PDF
Open source India - MySQL Labs: Multi-Source Replication
PDF
MySQL User Camp: Multi-threaded Slaves
PDF
MySQL Developer Day conference: MySQL Replication and Scalability
ODP
MySQL Group Replication @osi days 2014
PDF
Webinar: MariaDB Provides the Solution to Ease Multi-Source Replication
PDF
MySQL User Camp: GTIDs
PDF
Replication featuresinmysql5.7andbeyond osi-final
PDF
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
PDF
Confoo 202 - MySQL Group Replication and ReplicaSet
PDF
Mysql Replication Excerpt 5.1 En
PDF
MySQL 5.6 Replication Webinar
PDF
MySQL user camp march 11th 2016
PDF
MySQL Replication Basics -Ohio Linux Fest 2016
PDF
MySQL 5.7: Focus on Replication
PDF
MySQL Replication Update -- Zendcon 2016
PDF
MySQL Cluster Asynchronous replication (2014)
PDF
MySQL High Availability with Replication New Features
PDF
MySQL Group Replication - an Overview
PDF
2012 replication
PPTX
MySQL Replication Overview -- PHPTek 2016
Open source India - MySQL Labs: Multi-Source Replication
MySQL User Camp: Multi-threaded Slaves
MySQL Developer Day conference: MySQL Replication and Scalability
MySQL Group Replication @osi days 2014
Webinar: MariaDB Provides the Solution to Ease Multi-Source Replication
MySQL User Camp: GTIDs
Replication featuresinmysql5.7andbeyond osi-final
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Confoo 202 - MySQL Group Replication and ReplicaSet
Mysql Replication Excerpt 5.1 En
MySQL 5.6 Replication Webinar
MySQL user camp march 11th 2016
MySQL Replication Basics -Ohio Linux Fest 2016
MySQL 5.7: Focus on Replication
MySQL Replication Update -- Zendcon 2016
MySQL Cluster Asynchronous replication (2014)
MySQL High Availability with Replication New Features
MySQL Group Replication - an Overview
2012 replication
MySQL Replication Overview -- PHPTek 2016
Ad

More from Mysql User Camp (10)

PDF
Json improvements in my sql 8.0
PDF
EXPERIENCE WITH MYSQL HA SOLUTION AND GROUP REPLICATION
ODP
Doc store
PPTX
My sql8 innodb_cluster
PDF
Mysql8for blr usercamp
PDF
MySQL docker with demo by Ramana Yeruva
PDF
Customer Experience: InnoDB Cluster Implementation by PR Karthik
PDF
Optimizer overviewoow2014
PDF
Mysql User Camp : 20-June-14 : Mysql New features and NoSQL Support
PDF
Mysql User Camp : 20-June-14 : Mysql Fabric
Json improvements in my sql 8.0
EXPERIENCE WITH MYSQL HA SOLUTION AND GROUP REPLICATION
Doc store
My sql8 innodb_cluster
Mysql8for blr usercamp
MySQL docker with demo by Ramana Yeruva
Customer Experience: InnoDB Cluster Implementation by PR Karthik
Optimizer overviewoow2014
Mysql User Camp : 20-June-14 : Mysql New features and NoSQL Support
Mysql User Camp : 20-June-14 : Mysql Fabric
Ad

Recently uploaded (20)

PPT
Lessons from Presentation Zen_ how to craft your story visually
PPTX
Lesson 2 (Technology and Transmission) - Terms.pptx
PPTX
Animal Farm powerpointpresentation- Kopie – Kopie.pptx
PDF
Building event-driven application with RAP Business Events in ABAP Cloud
PPTX
Ruth Week 1 - Hope in Barren Places.pptx
PPTX
Brief presentation for multiple products
PPTX
CASEWORK Power Point Presentation - pointers
PDF
Books and book chapters(CITATIONS AND REFERENCING) (LORENA).pdf
PPTX
Training for Village Watershed Volunteers.pptx
DOCX
CLASS XII bbbbbnjhcvfyfhfyfyhPROJECT.docx
PPTX
Presentacion lugares conocidos ingles sena.pptx
PPTX
Analytics in Human Resource Management FY
PPTX
Knowledge Knockout ( General Knowledge Quiz )
PDF
Echoes of AccountabilityComputational Analysis of Post-Junta Parliamentary Qu...
PDF
Financial Managememt CA1 for Makaut Student
PDF
Lessons Learned building a product with clean core abap
PPTX
Paraphrasing Sentence To Make Your Writing More Interesting
PPTX
Ease_of_Paying_Taxes_Act_Presentation.pptx
PPTX
ECO VAULT AUTOMATIC DIAPER DISPENSER AND SHREDDER
Lessons from Presentation Zen_ how to craft your story visually
Lesson 2 (Technology and Transmission) - Terms.pptx
Animal Farm powerpointpresentation- Kopie – Kopie.pptx
Building event-driven application with RAP Business Events in ABAP Cloud
Ruth Week 1 - Hope in Barren Places.pptx
Brief presentation for multiple products
CASEWORK Power Point Presentation - pointers
Books and book chapters(CITATIONS AND REFERENCING) (LORENA).pdf
Training for Village Watershed Volunteers.pptx
CLASS XII bbbbbnjhcvfyfhfyfyhPROJECT.docx
Presentacion lugares conocidos ingles sena.pptx
Analytics in Human Resource Management FY
Knowledge Knockout ( General Knowledge Quiz )
Echoes of AccountabilityComputational Analysis of Post-Junta Parliamentary Qu...
Financial Managememt CA1 for Makaut Student
Lessons Learned building a product with clean core abap
Paraphrasing Sentence To Make Your Writing More Interesting
Ease_of_Paying_Taxes_Act_Presentation.pptx
ECO VAULT AUTOMATIC DIAPER DISPENSER AND SHREDDER

Multi source replication pdf

  • 1. MySQL Labs : Multi Source Replication Venkatesh Duggirala MySQL Replication Team 1 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 2. Safe Harbour Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 3. MySQL Labs features are not fit for production. They are provided solely for testing purposes, to try the latest bug fixes and generally to keep up with the development. Please, do not use these binaries in production. Instead, install them on a spare server. If you are looking for production ready binaries, please visit MySQL Downloads. 3 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 4. Agenda  Background: Why Use Replication?  Multi-source Replication – Introduction – Use cases – Internals – Monitoring  Reading More about Multi-source Replication 4 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 5. Background: What is Replication Used For?  Redundancy: If master crashes, promote slave to master Uh Oh! Whew! C B A C B CraAsh 5 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | C B A B is the new master
  • 6. Background: What is Replication Used For?  Read scale-out M S More reads? More slaves! 6 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | S S S M write clients write clients read clients read clients
  • 7. Background: What is Replication Used For?  On-line Backup and Reporting M 7 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | S  write clients  business intelligent client apps  reporting client apps  big queries client apps
  • 8.  Different types of Replication servers setup M S 1 8 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 9.  Different types of Replication servers setup M S M S1 S2 1 2 9 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 10.  Different types of Replication servers setup M S M S1 S2 M1 M2 S 1 2 3 10 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 11.  Different types of Replication servers setup M S M S1 S2 M1 M2 S M1 M2 11 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | S 1 2 3 4
  • 12.  Different types of Replication servers setup 12 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | M M M M M S M S1 S2 M1 M2 S M1 M2 S 1 2 3 4 5
  • 13. Agenda  Background: Why Use Replication?  Multi-source Replication – Introduction – Use cases – Internals – Monitoring  Reading More about Multi-source Replication 13 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 14. Before Multi-source replication : ● Time sharing replication, where a slave would connect to a master for a particular time slice. ● Have a hierarchical replication, where a slave that is to receive updates from the several masters is at the end of replication hierarchy. (Like, M1->M2->M3->Slave) ● Using several instances of mysqlbinlog + GTIDs. Multi-source replication feature aims to: ● Receive transactions (in the form of binary log events) from several MySQL servers simultaneously via several communication channels. ● Apply these received transactions (will not do any conflict detection or resolution) 14 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 15. Multi-Source Replication: Introduction  A Slave can have more than one master. M1 M2 M3 15 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | S M4
  • 16. Multi-Source Replication: Introduction  A Slave can have more than one master. db1 M1 16 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 17. Multi-Source Replication: Introduction  A Slave can have more than one master. M1 M2 db1 db2 17 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 18. Multi-Source Replication: Introduction  A Slave can have more than one master. M1 M2 M3 M4 db1 db2 db3 db4 18 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 19. Multi-Source Replication: Introduction  A Slave can have more than one master. M1 M2 M3 db2 db3 19 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | S db1 db2 db3 db4 M4 db1 db4
  • 20. Agenda  Background: Why Use Replication?  Multi-source Replication – Introduction – Use cases – Internals – Monitoring  Reading More about Multi-source Replication 20 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 21. Multi-Source Replication: Use Cases The main use cases of Multi-source replication are related to data aggregation. M1 21 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | Business Intelligence Data analytics Backup etc M2 S M3 Database 2 Database 3 Database 1, 2, 3 Database 1
  • 22. Multi-Source Replication: Use Cases The main use cases of Multi-source replication are related to data aggregation. M M S M Shard 2 Shard 3 22 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | Full table Shard 1
  • 23. Agenda  Background: Why Use Replication?  Multi-source Replication – Introduction – Use cases – Internals – Monitoring  Reading More about Multi-source Replication 23 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 24. Multi-Source Replication: More details.. M1 M2 M3 24 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | S M4  Slave can have more than one master. – Receive transactions from several MySQL servers simultaneously. – Apply transactions from different masters simultaneously. – No conflict detection or resolution.
  • 25. Multi-Source Replication: What is a Channel?  A channel is an an abstraction for a sender-receiver-applier path. Insert... Sender thread 25 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | Insert... B binary log relay log Insert... Insert... A binary log Client Network Receiver thread Applier thread Channel
  • 26. Multi-Source Replication: How Many Channels?  Number of channels on slave = Number of sources. 26 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | S M1 binary log Network relay log1 M2 binary log Network relay log2 M3 binary log Network relay log3 binary log
  • 27. Multi-Source Replication: Slave Appliers  Each channel has its own single-threaded slave applier. M1 binary log Network relay log1 M2 binary log Network relay log2 M3 binary log Network relay log3 27 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | binary log S
  • 28. Multi-Source Replication: Slave Appliers  Each channel can also have its own multi-threaded slave applier. 28 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | binary log M1 binary log Network M2 S M3 Network relay log2 Network rreellaayy lloogg33 binary log binary log relay log1
  • 29. Adding / Configuring A Channel  Each channel can be configured individually.  To add or alter a channel configuration use: CHANGE MASTER TO master_def … FOR CHANNEL ”<channel_name>” – Channel names are case insensitive – Special chars are allowed – maximum number of channels is 256 29 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 30. Replication Commands on a Channel  FOR CHANNEL ”<channel_name>” clause is added for: – start slave [thread_type] FOR CHANNEL ”<channel_name>" – stop slave [thread_type] FOR CHANNEL ”<channel_name>” – reset slave [all] FOR CHANNEL ”<channel_name>” – flush relay logs FOR CHANNEL ”<channel_name>” – show relay log events FOR CHANNEL ”<channel_name>”  An extra argument added for functions like – MASTER_POS_WAIT(<binlog_file>, <binlog_pos>, <time_out>, <channel_name>); – WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS(<gtid_set>, <time_out>, <channel_name>); 30 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 31. Working With All Channels  To make commands work on ALL CHANNELS – START SLAVE [thread_type] – STOP SLAVE [thread_type] – SHOW SLAVE STATUS – FLUSH RELAY LOGS  ER_SLAVE_MULTIPLE_CHANNELS_CMD(1964) – SHOW RELAYLOG EVENTS; – CHANGE MASTER – MASTER_POS_WAIT() – WAIT_FOR_SQL_THREAD_AFTER_GTIDS() 31 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 32. Compatibility With Other Replication Features Multi-Threaded Slaves Yes Global Transaction Identifiers Yes Semi-Synchronous Replication Yes* Slave Repositories Yes* Filters Yes* 32 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 33. Compatibility continued 2... Multi threaded slaves: slave_parallel_workers=k and M channels will have (k+1)*M applier threads running. GTIDs: A requirement as is the case with (normal master-slave replication), is that all the masters and the slave should have GTID_MODE=ON. Semi-Synchronous Replication: all the masters and the slave should be in semi sync mode Filters: replication filters are global in the labs release, ie. the applier threads of all channels will rely on a single global filter. 33 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 34. Compatibility continued 3... Slave Repositories:  Only TABLE repository is supported (Crash safe slave)  --mysqld= --master_info_repository= TABLE;  --mysqld= --relay_log_info_repository= TABLE;  Convert FILE repository to TABLE repository dynamically  STOP SLAVE;  SET GLOBAL master_info_repository= 'TABLE';  SET GLOBAL relay_log_info_repository= 'TABLE'; 34 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 35. Simple Setup ✔ Start 3 servers 35 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 36. Simple Setup 36 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 13000 13001 M1 M2 13002 S ✔ Start 3 servers , M1 (13000), M2 (13001), S (13002)
  • 37. Simple Setup 37 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | 13000 13001 M1 M2 13002 S ✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) ✔ On Slave(S), > CHANGE MASTER TO MASTER_PORT=13000,..., FOR CHANNEL 'CHANNEL_M1'; ✔CHANNEL_M1 is created channel_m1
  • 38. Simple Setup 38 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | master1-bin.000001 13000 13001 M1 M2 13002 S ✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) ✔ On Slave(S), > CHANGE MASTER TO MASTER_PORT=13000,..., FOR CHANNEL 'CHANNEL_M1'; ✔CHANNEL_M1 is created > START SLAVE FOR CHANNEL 'CHANNEL_M1' ✔ I/O thread for CHANNEL_M1 will be created ✔ M1's binary log (table t1 changes) will be retrieved by I/O thread and written to slave-relay-bin-channel_m1.00001 relay log ✔ SQL thread will start reading it from relay log and will start applying the data. channel_m1 insert into t1(..) insert into t1(..) Slave-relay-bin-channel_ m1.000001
  • 39. Simple Setup 39 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | master1-bin.000001 insert into t1(..) 13000 13001 M1 M2 13002 S ✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) ✔ On Slave(S), > CHANGE MASTER TO MASTER_PORT=13000,..., FOR CHANNEL 'CHANNEL_M1'; ✔CHANNEL_M1 is created > START SLAVE FOR CHANNEL 'CHANNEL_M1' ✔ I/O thread for CHANNEL_M1 will be created ✔ M1's binary log (table t1 changes) will be retrieved by I/O thread and written to slave-relay-bin-channel_m1.00001 relay log ✔ SQL thread will start reading it from relay log and will start applying the data. > CHANGE MASTER TO MASTER_PORT=13001,..., FOR CHANNEL 'CHANNEL_M2' ✔ CHANNEL_M2 is created channel_m1 channel_m2 insert into t1(..) Slave-relay-bin-channel_ m1.000001
  • 40. Simple Setup 40 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | master1-bin.000001 insert into t1(..) master2-bin.000002 insert into t2(..) 13000 13001 M1 M2 13002 S ✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) ✔ On Slave(S), > CHANGE MASTER TO MASTER_PORT=13000,..., FOR CHANNEL 'CHANNEL_M1'; ✔CHANNEL_M1 is created > START SLAVE FOR CHANNEL 'CHANNEL_M1' ✔ I/O thread for CHANNEL_M1 will be created ✔ M1's binary log (table t1 changes) will be retrieved by I/O thread and written to slave-relay-bin-channel_m1.00001 relay log ✔ SQL thread will start reading it from relay log and will start applying the data. > CHANGE MASTER TO MASTER_PORT=13001,..., FOR CHANNEL 'CHANNEL_M2' ✔ CHANNEL_M2 is created > START SLAVE FOR CHANNEL 'CHANNEL_M2' ✔ I/O thread for CHANNEL_M2 will be created ✔ M2's binary log (table t2 changes) will be retrieved by I/O thread and written to slave-relay-bin-channel_m2.00001 relay log ✔ SQL thread will start reading it from relay log and will start applying the data. channel_m1 channel_m2 insert into t1(..) insert into t2(..) Slave-relay-bin-channel_ m1.000001 Slave-relay-bin-channel_ m2.000001
  • 41. Simple Setup 41 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | master1-bin.000001 insert into t1(..) insert into t1(..) master2-bin.000002 insert into t2(..) insert into t2(..) 13000 13001 M1 M2 13002 S ✔ Start 3 servers , M1 (13000), M2 (13001), S (13002) ✔ On Slave(S), > CHANGE MASTER TO MASTER_PORT=13000,..., FOR CHANNEL 'CHANNEL_M1'; ✔CHANNEL_M1 is created > START SLAVE FOR CHANNEL 'CHANNEL_M1' ✔ I/O thread for CHANNEL_M1 will be created ✔ M1's binary log (table t1 changes) will be retrieved by I/O thread and written to slave-relay-bin-channel_m1.00001 relay log ✔ SQL thread will start reading it from relay log and will start applying the data. > CHANGE MASTER TO MASTER_PORT=13001,..., FOR CHANNEL 'CHANNEL_M2' ✔ CHANNEL_M2 is created > START SLAVE FOR CHANNEL 'CHANNEL_M2' ✔ I/O thread for CHANNEL_M2 will be created ✔ M2's binary log (table t2 changes) will be retrieved by I/O thread and written to slave-relay-bin-channel_m2.00001 relay log ✔ SQL thread will start reading it from relay log and will start applying the data. channel_m1 channel_m2 insert into t1(..) insert into t1(..) insert into t2(..) insert into t2(...) Slave-relay-bin-channel_ m1.000001 Slave-relay-bin-channel_ m2.000001
  • 42. Agenda  Background: Why Use Replication?  Multi-source Replication – Introduction – Use cases – Internals – Monitoring  Reading More about Multi-source Replication 42 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 43. Replication Monitoring: P_S Replication Tables Connection Configuration Connection Status 43 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | Execution Configuration Execution Status Slave Status Applier / Coordinator Status Workers Status
  • 44. Replication Monitoring: P_S Replication Tables  We have six performance schema tables for replication – replication_connection_configuration – replication_connection_status – replication_execute_configuration – replication_execute_status – replication_execute_status_by_coordinator – replication_execute_status_by_worker  Consistent semantics across tables. Lets explore one of them. 44 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | One row per CHANNEL One row per CHANNEL per WORKER
  • 45. 45 Replication Monitoring: Connection Status mysql> select * from performance_schema.replication_connection_statusG *************************** 1. row *************************** CHANNEL_NAME : channel1 SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b THREAD_ID : 13 SERVICE_STATE : ON RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 LAST_ERROR_NUMBER : 0 LAST_ERROR_MESSAGE : LAST_ERROR_TIMESTAMP : 0000-00-00 00:00:00 *************************** 2. row *************************** CHANNEL_NAME : channel2 ... 45 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | One row per CHANNEL
  • 46. 46 Replication Monitoring: Connection Status mysql> select * from performance_schema.replication_connection_statusG *************************** 1. row *************************** CHANNEL_NAME : channel1 SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b THREAD_ID : 13 SERVICE_STATE : ON RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 LAST_ERROR_NUMBER : 0 LAST_ERROR_MESSAGE : LAST_ERROR_TIMESTAMP : 0000-00-00 00:00:00 *************************** 2. row *************************** CHANNEL_NAME : channel2 ... 46 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | Receiver thread & its service state
  • 47. 47 Replication Monitoring: Connection Status mysql> select * from performance_schema.replication_connection_statusG *************************** 1. row *************************** CHANNEL_NAME : channel1 SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b THREAD_ID : 13 SERVICE_STATE : ON RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 LAST_ERROR_NUMBER : 0 LAST_ERROR_MESSAGE : LAST_ERROR_TIMESTAMP : 0000-00-00 00:00:00 *************************** 2. row *************************** CHANNEL_NAME : channel2 ... 47 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | Set of transactions received through this channel
  • 48. 48 Replication Monitoring: Connection Status mysql> select * from performance_schema.replication_connection_statusG *************************** 1. row *************************** CHANNEL_NAME : channel1 SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b THREAD_ID : 13 SERVICE_STATE : ON RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 LAST_ERROR_NUMBER : 1045 LAST_ERROR_MESSAGE : error connecting to master '[email protected]:13000' ... LAST_ERROR_TIMESTAMP : 2013-11-04 13:37:23 *************************** 2. row *************************** CHANNEL_NAME : channel2 ... Oops! There was an error in the receiver thread on this channel 48 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 49. 49 Replication Monitoring: Connection Status mysql> select * from performance_schema.replication_connection_statusG *************************** 1. row *************************** CHANNEL_NAME : channel1 SOURCE_UUID : 7cff7406-23ca-11e3-ac3e-5c260a83b12b THREAD_ID : NULL SERVICE_STATE : OFF RECEIVED_TRANSACTION_SET : 7cff7406-23ca-11e3-ac3e-5c260a83b12b:1-4 LAST_ERROR_NUMBER : 1045 LAST_ERROR_MESSAGE : error connecting to master '[email protected]:13000' ... LAST_ERROR_TIMESTAMP : 2013-11-04 13:37:23 *************************** 2. row *************************** CHANNEL_NAME : channel2 ... 49 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. | Receiver thread on this channel stopped serving...
  • 50. Agenda  Background: Why Use Replication?  Multi-source Replication – Introduction – Use cases – Internals – Monitoring  Reading More about Multi-source Replication 50 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |
  • 51. Read More About Multi Source Replication  Read a feature preview of Multi-source replication on Rith's blog: http://on-mysql-replication.blogspot.in/2013/09/feature-preview-mysql-multi -source-replication.html  Read more about Multi-source replication on Rith's blog: http://mysqlhighavailability.com/5-7-5-labs-multi-source-replication/  Read more about replication P_S tables on Shiv's blogs: http://shivjijha.blogspot.com/2013/09/Monitoring-Replication-with-the-NEW-pe rformance-schema-tables.html http://mysqlhighavailability.com/global-variables-in-rpl-ps/  Official MySQL documentation for replication P_S tables: http://dev.mysql.com/doc/refman/5.7/en/performance-schema-replication-tables .html 51 | Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL User Camp| Bangalore, India, October 17th, 2014. |