SlideShare a Scribd company logo
1 of 40
Download to read offline
Pseudo-GTID and Easy MySQL
Replication Management
Shlomi Noach
Percona Live, April 2015
Overview:
● What? Why?
● Replication topologies, types
● Binary & relay logs
● GTID
● Pseudo GTID
● Failover with Pseudo GTID, bulk operations
● Orchestrator
● Pseudo GTID & orchestrator @ Booking.com
● Demo
● Considerations, gotchas & limitations
What? Why?
● Be happy!
● Avoid using GTID. Pseudo GTID offers what GTID offers, without GTID. This includes:
● Slave repointing
● Failover schemes
● With less requirements
● And, with larger topologies: faster!
● Without upgrading your servers; without installing anything on them; in short: not touching your
beloved existing setup
● No vendor lockdown; no migration paths
3
MySQL replication topologies
4
More complex topologies
5
Replication topologies, “classic replication”
● Single master, multiple slaves
● Nested replication: slaves of slaves
● Replication load on master, on network
● Intermediate masters:
● Upgrades
● Schema changes
● Switching datacenters
● Experiments
6
Replication topologies, “classic replication”
● Too many slaves on a single master:
● Can be too much load (network traffic, dedicated connections)
● What happens when the master goes down?
● Using intermediate masters:
● Reduced load
● Accumulating slave lag
● What happens when the intermediate master goes down?
7
Problem: master goes down
8
!!
?
Problem: intermediate master goes down
9
!!
?
MySQL binary & relay logs
10
Master
Slave
MySQL binary & relay logs: different languages
11
Master
Slave
MySQL binary & relay logs: even more languages
12
Master
Slave
Slave
GTID
● Every transaction has a unique identifier
● When a slave connects to a master, it looks for the last GTID statement it already executed
● Available in Oracle MySQL 5.6, MariaDB 10.0
● Completely different implementations; may cause lockup
● 5.6 migration path is unacceptable
● 5.6 requires binary logs & log-slave-updates enabled on all slaves
● 5.6 issues with errant transactions, unexecuted sequences, …
● 5.6 requires adaptation of tools / understanding
● 5.6 GTID will be the requirement in future Oracle features
● MariaDB GTID supports domains; easy to use
13
Pseudo GTID
● Application-side enhancement
● We inject a uniquely identified statement every X seconds. We call it Pseudo GTID.
● Pseudo GTID statements are searchable and identifiable in binary and relay logs
● Make for “markers” in the binary/relay logs
● Injection can be made via MySQL event scheduler or externally
● Otherwise non intrusive. No changes to topology/versions/methodologies
14
Injecting Pseudo-GTID
create event if not exists create_pseudo_gtid_event
on schedule every 5 second starts current_timestamp
on completion preserve enable
do begin
set @pseudo_gtid_hint := uuid();
set @_create_statement := concat('drop ',
'view if exists `meta`.`_pseudo_gtid_hint__', @pseudo_gtid_hint, '`');
PREPARE st FROM @_create_statement;
EXECUTE st;
DEALLOCATE PREPARE st;
end $$
15
In the binary logs
mysql> show binlog events in 'mysql-bin.015631' G
...
Log_name: mysql-bin.015631
Pos: 1632
Event_type: Query
Server_id: 1
End_log_pos: 1799
Info: use `meta`; drop view if exists `meta`.`_pseudo_gtid_hint__50731a22-9ca4-
11e4-aec4-e25ec4bd144f`
...
16
Recap: MySQL binary & relay logs
17
Master
Slave
MySQL binary & relay logs: a virtual contiguous log file
18
Master
Slave
MySQL binary & relay logs: Pseudo GTID injection
19
Master Slaveinsert
> PGTID 17
update
delete
create
> PGTID 82
delete
delete
> PGTID 56
insert
insert
update
drop
update
insert
> PGTID 17
update
delete
create
> PGTID 82
delete
delete
> PGTID 56
insert
insert
update
drop
insert
> PGTID 17
update
delete
create
> PGTID 82
delete
delete
> PGTID 56
insert
insert
insert
> PGTID 17
update
delete
create
> PGTID 82
delete
delete
> PGTID 56
insert
insert
Pseudo GTID: repoint, based on binary logs
20
Master Slaveinsert
> PGTID 17
update
delete
create
> PGTID 82
delete
delete
> PGTID 56
insert
insert
update
drop
update
insert
> PGTID 17
update
delete
create
> PGTID 82
delete
delete
> PGTID 56
insert
insert
update
drop
Pseudo GTID: repoint, based on relay logs
21
Master Slaveinsert
> PGTID 17
update
delete
create
> PGTID 82
delete
delete
> PGTID 56
insert
insert
update
drop
update
Multiple possible destinations
22
!!
Bulk operations
23
!!● If you’re aware of the topology,
● Identify slaves that crashed on the same position
● Or with the same last pseudo-gtid entry
● Significantly reduce access onto failover master
● Orchestrator does all that
MySQL @ Booking.com
● We are a big MySQL shop
● We have >2600 production servers (~3300 including experiments & tests) on >110 topologies
(aka chains, aka clusters)
● As small as 1 server per topology, as large as 400 servers per topology
● Two major data centers
● All chains are deployed with Pseudo-GTID and controlled by orchestrator
24
● command line, web API, web interface
● Crawls through your topologies, maps them, persists to backend database
● Understands replication, gathers metadata on replicating slaves (Which cluster? Depth?)
● Understands rules of replication (SBR, RBR, version compatibility, other configurations you wish
you had never heard of)
● Can refactor/manipulate topologies
● Understands Pseudo-GTID
● Detects and recovers outage scenarios
Orchestrator: MySQL replication management &
visualization tool
25
Orchestrator general architecture
26
orchestrator
service
backend db
web API
web xface
Orchestrator architecture @ Booking.com
27
app
leader
app
app
app
HTTP load
balancerorchestrator-cli on all MySQL nodes
● Stack:
● golang - in retrospect a very good choice: a lot of concurrency; easy deployment; rapid
development
● MySQL as backend database (duh)
● go-martini web framework
● Page generation via dirty JavaScript/jQuery (sue me)
● Twitter bootstrap
● Graphs via D3, integrated with bootstrap
● Development:
● Github, completely open source; as generic as possible
https://github.com/outbrain/orchestrator/
Orchestrator stack & development
28
Live demo
In-production experiments, trust
● Tested:
● 21,138 rematch experiments on 7 topologies (based on binlogs)
● 13,872 rematch experiments on 6 topologies (based on relay logs)
● 6,246 bounce up and back experiments on 6 topologies
● 8,699 regroup, bounce up and back experiments on 9 topologies
● ~180 intermediate master automated failover (clean shutdown)
● A few dozens intermediate master automated failover (kill -9 / iptables)
● Many intermediate master manual failovers
● Todo:
● Daily (!) controlled intermediate master failover
● Not so far in the future: daily (!) controlled master failover
30
Considerations, requirements
● Works with:
● MySQL, MariaDB, using standard, single threaded replication
● Supports SRB & RBR
● Supports Binlog Servers
● When slave has log-slave-updates & sync_binlog=1, implies crash safe replication
● log-slave-updates required when slave should be considered to be promoted
● Otherwise relay logs work well
● But change of master clears relay logs; an additional crash during < injection time may
render the instance lost
31
Considerations, requirements
● Will not work with 5.6 per-schema-parallel-replication (no intended work on that)
● Will work with In-order binlog statements applier on slave (true in MariaDB and in MySQL 5.7.5
with slave_preserve_commit_order)
● No thoughts yet on multisource
32
Considerations, requirements
● Allows for queries to execute on slave
● But not after the last Pseudo-GTID entry
● Will succeed when:
● Matching a slave up the topology
● Matching below a sibling known to be more advanced
● Can succeed when:
● Matching below an “uncle”/”cousin”/other relative
● If not - then the opposite direction should work
● Cannot move slave underneath its own sibling (singularity, universe will collapse)
● Replication filters are your own risk
33
Considerations, requirements
● Therefore, can always recover the death of an intermediate master
● (This is partly automated at Booking.com)
● Master death topology recovery possible when all immediate slaves have log-slave-updates
● Consider actually enforcing such a layer
34
Auto pick replacement master
35
!!
● Only from slaves with log_slave_updates
● Slaves without log_slave_updates might be lost
Considerations, requirements
● Recovery time depends on binary log parsing speed. Typically, you will need to search
throughout the last binary logs
● Reduce max_binlog_size, max_relay_log_size
● Means more files
● Orchestrator already tackled plenty issues involving scanning (many) binlog files
36
Gotchas, careful!
● SHOW BINLOG EVENTS lockdown! Keep chunk size small
http://bugs.mysql.com/bug.php?id=76618
● Make sure Pseudo-GTID injected on master only
● log-slave-updates have I/O overhead; incurs more lag; experiments with 5.7 show reduces
parallelism
● Replication filters may be a necessary evil -- but they are evil!
● Relay log purging is is not user-controlled
37
Further ideas
● Reduce binlog scan time by injecting the master’s binlog position (e.g. output of SHOW
MASTER STATUS) within the Pseugo-GTID entry
● This allows starting the scan from the given position
● Likely to end quickly
● Applies for masters only, not for intermediate masters
● Use monotonically increasing Pseudo-GTID values
● Allows skipping of binary logs that begin with later/greater value than desired one
● Agents:
● Index the binary logs
● Full visibility even with RBR (mysqlbinlog more detailed than SHOW BINLOG EVENTS)
38
● Binlog Servers at Booking.com
Jean-François Gagné
15 April 2:00PM - 2:50PM @ Ballroom G
● Booking.com: Evolution of MySQL System Design
Nicolai Plum
16 April 12:50PM - 1:40PM @ Ballroom E
See also
Questions?
@ShlomiNoach
http://openark.org
http://blog.booking.com
Thank you!

More Related Content

What's hot

M|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera ClusterM|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera ClusterMariaDB plc
 
M|18 Deep Dive: InnoDB Transactions and Replication
M|18 Deep Dive: InnoDB Transactions and ReplicationM|18 Deep Dive: InnoDB Transactions and Replication
M|18 Deep Dive: InnoDB Transactions and ReplicationMariaDB plc
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsJean-François Gagné
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialThe Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialJean-François Gagné
 
MySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.comMySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.comJean-François Gagné
 
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...Jean-François Gagné
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyJean-François Gagné
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsJean-François Gagné
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorAlmost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorJean-François Gagné
 
MySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitationsMySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitationsJean-François Gagné
 
MySQL 5.6 Replication Webinar
MySQL 5.6 Replication WebinarMySQL 5.6 Replication Webinar
MySQL 5.6 Replication WebinarMark Swarbrick
 
The consequences of sync_binlog != 1
The consequences of sync_binlog != 1The consequences of sync_binlog != 1
The consequences of sync_binlog != 1Jean-François Gagné
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentJean-François Gagné
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyJean-François Gagné
 
Riding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication StreamRiding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication StreamJean-François Gagné
 
M|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write PathsM|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write PathsMariaDB plc
 
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsMySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsJean-François Gagné
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyJean-François Gagné
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentJean-François Gagné
 

What's hot (20)

M|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera ClusterM|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera Cluster
 
MySQL 5.6 GTID in a nutshell
MySQL 5.6 GTID in a nutshellMySQL 5.6 GTID in a nutshell
MySQL 5.6 GTID in a nutshell
 
M|18 Deep Dive: InnoDB Transactions and Replication
M|18 Deep Dive: InnoDB Transactions and ReplicationM|18 Deep Dive: InnoDB Transactions and Replication
M|18 Deep Dive: InnoDB Transactions and Replication
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitations
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialThe Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
 
MySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.comMySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.com
 
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitations
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorAlmost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
 
MySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitationsMySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitations
 
MySQL 5.6 Replication Webinar
MySQL 5.6 Replication WebinarMySQL 5.6 Replication Webinar
MySQL 5.6 Replication Webinar
 
The consequences of sync_binlog != 1
The consequences of sync_binlog != 1The consequences of sync_binlog != 1
The consequences of sync_binlog != 1
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
Riding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication StreamRiding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication Stream
 
M|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write PathsM|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write Paths
 
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsMySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 

Similar to Pseudo-GTID and Easy MySQL Replication Management

Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityColin Charles
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningFromDual GmbH
 
Pg chameleon, mysql to postgresql replica made easy
Pg chameleon, mysql to postgresql replica made easyPg chameleon, mysql to postgresql replica made easy
Pg chameleon, mysql to postgresql replica made easyFederico Campoli
 
Best practices for MySQL High Availability
Best practices for MySQL High AvailabilityBest practices for MySQL High Availability
Best practices for MySQL High AvailabilityColin Charles
 
Tips & Tricks for Apache Kafka®
Tips & Tricks for Apache Kafka®Tips & Tricks for Apache Kafka®
Tips & Tricks for Apache Kafka®confluent
 
Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019Dieter Adriaenssens
 
MySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdfMySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdfYunusShaikh49
 
Eko10 Workshop Opensource Database Auditing
Eko10  Workshop Opensource Database AuditingEko10  Workshop Opensource Database Auditing
Eko10 Workshop Opensource Database AuditingJuan Berner
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGEko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGPablo Garbossa
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerkuchinskaya
 
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...Boško Devetak
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability SolutionsLenz Grimmer
 
Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02Louis liu
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability SolutionsLenz Grimmer
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterSeveralnines
 
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin FrankfurtMariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin FrankfurtMariaDB Corporation
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagJean-François Gagné
 

Similar to Pseudo-GTID and Easy MySQL Replication Management (20)

Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High Availability
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL Tuning
 
MySQL DBA
MySQL DBAMySQL DBA
MySQL DBA
 
Pg chameleon, mysql to postgresql replica made easy
Pg chameleon, mysql to postgresql replica made easyPg chameleon, mysql to postgresql replica made easy
Pg chameleon, mysql to postgresql replica made easy
 
Best practices for MySQL High Availability
Best practices for MySQL High AvailabilityBest practices for MySQL High Availability
Best practices for MySQL High Availability
 
Tips & Tricks for Apache Kafka®
Tips & Tricks for Apache Kafka®Tips & Tricks for Apache Kafka®
Tips & Tricks for Apache Kafka®
 
Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019
 
MySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdfMySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdf
 
Eko10 Workshop Opensource Database Auditing
Eko10  Workshop Opensource Database AuditingEko10  Workshop Opensource Database Auditing
Eko10 Workshop Opensource Database Auditing
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGEko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
 
The Accidental DBA
The Accidental DBAThe Accidental DBA
The Accidental DBA
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
 
nebulaconf
nebulaconfnebulaconf
nebulaconf
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
 
Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera Cluster
 
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin FrankfurtMariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lag
 

More from Shlomi Noach

MySQL DevOps at Outbrain
MySQL DevOps at OutbrainMySQL DevOps at Outbrain
MySQL DevOps at OutbrainShlomi Noach
 
common_schema 2.2: DBA's framework for MySQL (April 2014)
common_schema 2.2: DBA's framework for MySQL (April 2014)common_schema 2.2: DBA's framework for MySQL (April 2014)
common_schema 2.2: DBA's framework for MySQL (April 2014)Shlomi Noach
 
common_schema 2.0: DBA's Framework for MySQL
common_schema 2.0: DBA's Framework for MySQLcommon_schema 2.0: DBA's Framework for MySQL
common_schema 2.0: DBA's Framework for MySQLShlomi Noach
 
openark-kit: MySQL utilities for everyday use
openark-kit: MySQL utilities for everyday useopenark-kit: MySQL utilities for everyday use
openark-kit: MySQL utilities for everyday useShlomi Noach
 
Programmatic queries: things you can code with sql
Programmatic queries: things you can code with sqlProgrammatic queries: things you can code with sql
Programmatic queries: things you can code with sqlShlomi Noach
 
common_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQLcommon_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQLShlomi Noach
 

More from Shlomi Noach (6)

MySQL DevOps at Outbrain
MySQL DevOps at OutbrainMySQL DevOps at Outbrain
MySQL DevOps at Outbrain
 
common_schema 2.2: DBA's framework for MySQL (April 2014)
common_schema 2.2: DBA's framework for MySQL (April 2014)common_schema 2.2: DBA's framework for MySQL (April 2014)
common_schema 2.2: DBA's framework for MySQL (April 2014)
 
common_schema 2.0: DBA's Framework for MySQL
common_schema 2.0: DBA's Framework for MySQLcommon_schema 2.0: DBA's Framework for MySQL
common_schema 2.0: DBA's Framework for MySQL
 
openark-kit: MySQL utilities for everyday use
openark-kit: MySQL utilities for everyday useopenark-kit: MySQL utilities for everyday use
openark-kit: MySQL utilities for everyday use
 
Programmatic queries: things you can code with sql
Programmatic queries: things you can code with sqlProgrammatic queries: things you can code with sql
Programmatic queries: things you can code with sql
 
common_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQLcommon_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQL
 

Recently uploaded

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Recently uploaded (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Pseudo-GTID and Easy MySQL Replication Management

  • 1. Pseudo-GTID and Easy MySQL Replication Management Shlomi Noach Percona Live, April 2015
  • 2. Overview: ● What? Why? ● Replication topologies, types ● Binary & relay logs ● GTID ● Pseudo GTID ● Failover with Pseudo GTID, bulk operations ● Orchestrator ● Pseudo GTID & orchestrator @ Booking.com ● Demo ● Considerations, gotchas & limitations
  • 3. What? Why? ● Be happy! ● Avoid using GTID. Pseudo GTID offers what GTID offers, without GTID. This includes: ● Slave repointing ● Failover schemes ● With less requirements ● And, with larger topologies: faster! ● Without upgrading your servers; without installing anything on them; in short: not touching your beloved existing setup ● No vendor lockdown; no migration paths 3
  • 6. Replication topologies, “classic replication” ● Single master, multiple slaves ● Nested replication: slaves of slaves ● Replication load on master, on network ● Intermediate masters: ● Upgrades ● Schema changes ● Switching datacenters ● Experiments 6
  • 7. Replication topologies, “classic replication” ● Too many slaves on a single master: ● Can be too much load (network traffic, dedicated connections) ● What happens when the master goes down? ● Using intermediate masters: ● Reduced load ● Accumulating slave lag ● What happens when the intermediate master goes down? 7
  • 8. Problem: master goes down 8 !! ?
  • 9. Problem: intermediate master goes down 9 !! ?
  • 10. MySQL binary & relay logs 10 Master Slave
  • 11. MySQL binary & relay logs: different languages 11 Master Slave
  • 12. MySQL binary & relay logs: even more languages 12 Master Slave Slave
  • 13. GTID ● Every transaction has a unique identifier ● When a slave connects to a master, it looks for the last GTID statement it already executed ● Available in Oracle MySQL 5.6, MariaDB 10.0 ● Completely different implementations; may cause lockup ● 5.6 migration path is unacceptable ● 5.6 requires binary logs & log-slave-updates enabled on all slaves ● 5.6 issues with errant transactions, unexecuted sequences, … ● 5.6 requires adaptation of tools / understanding ● 5.6 GTID will be the requirement in future Oracle features ● MariaDB GTID supports domains; easy to use 13
  • 14. Pseudo GTID ● Application-side enhancement ● We inject a uniquely identified statement every X seconds. We call it Pseudo GTID. ● Pseudo GTID statements are searchable and identifiable in binary and relay logs ● Make for “markers” in the binary/relay logs ● Injection can be made via MySQL event scheduler or externally ● Otherwise non intrusive. No changes to topology/versions/methodologies 14
  • 15. Injecting Pseudo-GTID create event if not exists create_pseudo_gtid_event on schedule every 5 second starts current_timestamp on completion preserve enable do begin set @pseudo_gtid_hint := uuid(); set @_create_statement := concat('drop ', 'view if exists `meta`.`_pseudo_gtid_hint__', @pseudo_gtid_hint, '`'); PREPARE st FROM @_create_statement; EXECUTE st; DEALLOCATE PREPARE st; end $$ 15
  • 16. In the binary logs mysql> show binlog events in 'mysql-bin.015631' G ... Log_name: mysql-bin.015631 Pos: 1632 Event_type: Query Server_id: 1 End_log_pos: 1799 Info: use `meta`; drop view if exists `meta`.`_pseudo_gtid_hint__50731a22-9ca4- 11e4-aec4-e25ec4bd144f` ... 16
  • 17. Recap: MySQL binary & relay logs 17 Master Slave
  • 18. MySQL binary & relay logs: a virtual contiguous log file 18 Master Slave
  • 19. MySQL binary & relay logs: Pseudo GTID injection 19 Master Slaveinsert > PGTID 17 update delete create > PGTID 82 delete delete > PGTID 56 insert insert update drop update insert > PGTID 17 update delete create > PGTID 82 delete delete > PGTID 56 insert insert update drop insert > PGTID 17 update delete create > PGTID 82 delete delete > PGTID 56 insert insert
  • 20. insert > PGTID 17 update delete create > PGTID 82 delete delete > PGTID 56 insert insert Pseudo GTID: repoint, based on binary logs 20 Master Slaveinsert > PGTID 17 update delete create > PGTID 82 delete delete > PGTID 56 insert insert update drop update
  • 21. insert > PGTID 17 update delete create > PGTID 82 delete delete > PGTID 56 insert insert update drop Pseudo GTID: repoint, based on relay logs 21 Master Slaveinsert > PGTID 17 update delete create > PGTID 82 delete delete > PGTID 56 insert insert update drop update
  • 23. Bulk operations 23 !!● If you’re aware of the topology, ● Identify slaves that crashed on the same position ● Or with the same last pseudo-gtid entry ● Significantly reduce access onto failover master ● Orchestrator does all that
  • 24. MySQL @ Booking.com ● We are a big MySQL shop ● We have >2600 production servers (~3300 including experiments & tests) on >110 topologies (aka chains, aka clusters) ● As small as 1 server per topology, as large as 400 servers per topology ● Two major data centers ● All chains are deployed with Pseudo-GTID and controlled by orchestrator 24
  • 25. ● command line, web API, web interface ● Crawls through your topologies, maps them, persists to backend database ● Understands replication, gathers metadata on replicating slaves (Which cluster? Depth?) ● Understands rules of replication (SBR, RBR, version compatibility, other configurations you wish you had never heard of) ● Can refactor/manipulate topologies ● Understands Pseudo-GTID ● Detects and recovers outage scenarios Orchestrator: MySQL replication management & visualization tool 25
  • 27. Orchestrator architecture @ Booking.com 27 app leader app app app HTTP load balancerorchestrator-cli on all MySQL nodes
  • 28. ● Stack: ● golang - in retrospect a very good choice: a lot of concurrency; easy deployment; rapid development ● MySQL as backend database (duh) ● go-martini web framework ● Page generation via dirty JavaScript/jQuery (sue me) ● Twitter bootstrap ● Graphs via D3, integrated with bootstrap ● Development: ● Github, completely open source; as generic as possible https://github.com/outbrain/orchestrator/ Orchestrator stack & development 28
  • 30. In-production experiments, trust ● Tested: ● 21,138 rematch experiments on 7 topologies (based on binlogs) ● 13,872 rematch experiments on 6 topologies (based on relay logs) ● 6,246 bounce up and back experiments on 6 topologies ● 8,699 regroup, bounce up and back experiments on 9 topologies ● ~180 intermediate master automated failover (clean shutdown) ● A few dozens intermediate master automated failover (kill -9 / iptables) ● Many intermediate master manual failovers ● Todo: ● Daily (!) controlled intermediate master failover ● Not so far in the future: daily (!) controlled master failover 30
  • 31. Considerations, requirements ● Works with: ● MySQL, MariaDB, using standard, single threaded replication ● Supports SRB & RBR ● Supports Binlog Servers ● When slave has log-slave-updates & sync_binlog=1, implies crash safe replication ● log-slave-updates required when slave should be considered to be promoted ● Otherwise relay logs work well ● But change of master clears relay logs; an additional crash during < injection time may render the instance lost 31
  • 32. Considerations, requirements ● Will not work with 5.6 per-schema-parallel-replication (no intended work on that) ● Will work with In-order binlog statements applier on slave (true in MariaDB and in MySQL 5.7.5 with slave_preserve_commit_order) ● No thoughts yet on multisource 32
  • 33. Considerations, requirements ● Allows for queries to execute on slave ● But not after the last Pseudo-GTID entry ● Will succeed when: ● Matching a slave up the topology ● Matching below a sibling known to be more advanced ● Can succeed when: ● Matching below an “uncle”/”cousin”/other relative ● If not - then the opposite direction should work ● Cannot move slave underneath its own sibling (singularity, universe will collapse) ● Replication filters are your own risk 33
  • 34. Considerations, requirements ● Therefore, can always recover the death of an intermediate master ● (This is partly automated at Booking.com) ● Master death topology recovery possible when all immediate slaves have log-slave-updates ● Consider actually enforcing such a layer 34
  • 35. Auto pick replacement master 35 !! ● Only from slaves with log_slave_updates ● Slaves without log_slave_updates might be lost
  • 36. Considerations, requirements ● Recovery time depends on binary log parsing speed. Typically, you will need to search throughout the last binary logs ● Reduce max_binlog_size, max_relay_log_size ● Means more files ● Orchestrator already tackled plenty issues involving scanning (many) binlog files 36
  • 37. Gotchas, careful! ● SHOW BINLOG EVENTS lockdown! Keep chunk size small http://bugs.mysql.com/bug.php?id=76618 ● Make sure Pseudo-GTID injected on master only ● log-slave-updates have I/O overhead; incurs more lag; experiments with 5.7 show reduces parallelism ● Replication filters may be a necessary evil -- but they are evil! ● Relay log purging is is not user-controlled 37
  • 38. Further ideas ● Reduce binlog scan time by injecting the master’s binlog position (e.g. output of SHOW MASTER STATUS) within the Pseugo-GTID entry ● This allows starting the scan from the given position ● Likely to end quickly ● Applies for masters only, not for intermediate masters ● Use monotonically increasing Pseudo-GTID values ● Allows skipping of binary logs that begin with later/greater value than desired one ● Agents: ● Index the binary logs ● Full visibility even with RBR (mysqlbinlog more detailed than SHOW BINLOG EVENTS) 38
  • 39. ● Binlog Servers at Booking.com Jean-François Gagné 15 April 2:00PM - 2:50PM @ Ballroom G ● Booking.com: Evolution of MySQL System Design Nicolai Plum 16 April 12:50PM - 1:40PM @ Ballroom E See also