Documente Academic
Documente Profesional
Documente Cultură
Multithreaded Replication
PRESENTED BY Stacy Yuan, Yashada Jadhav
October 2015
About Yahoo
Ad Products Team
MySQL at Yahoo
About Stacy
About Yashada
Operational issues
Monitoring and HA
Backups using xtrabackup
GTID Replication
File-based Replication
Enables data from one MySQL database server (the master) to be
replicated to one or more MySQL database servers (the slaves) through
MySQL log file and its position
Needs replication user, binlog is enabled
Needs a copy of master database
Connect to master through master_host, port, replication user,
master log file and its position.
Each slave pulls the data from the master, and execute the events
to the slave.
GTID Replication
A global transaction identifier (GTID) is a unique identifier created and
associated with each transaction committed on the server of origin
(master).
GTID is unique not only to the server on which it originated, but is
unique across all servers in a given replication setup.
GTID = source_id:transaction_id
The source_id identifies the originating server.
The transaction_id is a sequence number determined by the order in
which the transaction was committed on this server.
Example:
5c7401d3-3623-11e5-ae8c-78e7d15fd641:1-13476
master_auto_position=1
Failover is simplified
Increase performance in relay slave - set sync_binlog=0
Managing multi-tiered replication is easier
S2
S1
S2
S1
S3
S4
S3
S4
S5
S5
Master
Slave
Master
Slave
MTS Prerequisites
Master
db1, db2, db3
Slave
db1, db2, db3
Configure MTS
STOP SLAVE;
SET GLOBAL slave_parallel_workers=3;
START SLAVE;
Advantages:
Take advantage of multi-core servers
Changes to each schema applied and committed independently by
worker threads
Smaller risk of data loss
Limitations:
START SLAVE UNTIL no longer support
Foreign Keys cross-referencing DBs will disable MTS
No implicit transaction retry after transient failure
MTS Caveats
Slave1
Slave2
DNS
Prod master
BCP master
Prod slave
BCP slave
DNS
BCP master
Prod master
GTID_deployme
nt_step=on
Prod slave
GTID_deployme
nt_step=on
DNS
5. BCP master:
set global gtid_deployment_step = off;
set global read_only=off;
6. The replication from BCP master to
BCP master
Prod master
GTID_deployme
nt_step=off
BCP slave
Prod slave
GTID_deployme
nt_step=on
DNS
Prod master
GTID enabled
BCP master
GTID_deployme
nt_step=off
Prod slave
GTID enabled
BCP slave
GTID_deployme
nt_step=on
Prod master
GTID enabled
Prod slave
GTID enabled
BCP master
GTID_deployme
nt_step=off
BCP slave
GTID_deployme
nt_step=off
Switchover Steps
Failover:
Errant Transaction
The errant transactions are:
They are only executed in slaves.
Could result from a mistake
Could be intentionally by design, such as report tables
Why they cause problem
When the slave becomes the master during failover, it exchanges its own
set of executed GTIDs, then send any missing transactions to the slaves.
Seconds_Behind_Master
A good approximation of how late the slave is only when the slave
actively processes updates.
If the network is slow or not much updates in the master, this is NOT
a good measurement.
How to fix
RESET MASTER;
RESET SLAVE;
START SLAVE;
Summary
GTID
MTS
GTID with MTS performance comparison
GTID with MTS online rollout
Things to watch out
Rebuild slave
http://mysqlatyahoo.tumblr.com
YJ
yashada@yahoo-inc.com
https://www.linkedin.com/pub/yashada-jadhav/18/659/a6
Stacy Yuan
syuan@yahoo-inc.com
https://www.linkedin.com/pub/stacy-yuan/53/577/324
Appendix