0
www.fromdual.com
1 / 31
MySQL always-up
with Galera Cluster
SLAC 2014
May 14, 2014, Berlin
by oli.sennhauser@fromdual.com
...
www.fromdual.com
2 / 31
About FromDual GmbH
● FromDual provides neutral and independent:
● Consulting for MySQL, Galera Cl...
www.fromdual.com
3 / 31
Always-up? :-(
● Its also about maintenance...
● Who loves night-shifts?
● Who loves weekend-work?...
www.fromdual.com
4 / 31
The Galera Cluster for MySQL
www.fromdual.com
5 / 31
Maintenance time...
App
Load balancing (LB)
Node 2Node 1
wsrep
Galera replication
wsrep
Node 3
wsr...
www.fromdual.com
6 / 31
Advantages / Disadvantages
Based on InnoDB SE
Synchronous replication → No lost transaction
Active...
www.fromdual.com
7 / 31
Quorum and Split-brain
● What is the problem?
● Split-brain → bad!
● Galera is a pessimistic Clust...
www.fromdual.com
8 / 31
Quorum
www.fromdual.com
9 / 31
Installation and Configuration
www.fromdual.com
10 / 31
Installation
● Galera Cluster consists of:
● A patched Codership MySQL (mysqld)
● Or MariaDB Gale...
www.fromdual.com
11 / 31
MySQL Configuration
my.cnf
[mysqld]
default_storage_engine         = InnoDB
binlog_format        ...
www.fromdual.com
12 / 31
Galera Configuration
my.cnf (conf.d/wsrep.cnf)
[mysqld]
# wsrep_provider = none
wsrep_provider = ...
www.fromdual.com
13 / 31
Operations
www.fromdual.com
14 / 31
Initial Cluster start
● Start very 1st node with:
wsrep_cluster_address = "gcomm://"
or
mysqld_sa...
www.fromdual.com
15 / 31
Rolling Restart
● Scenario:
● Hardware-, O/S-, DB- and Galera-Upgrade
● MySQL configuration chang...
www.fromdual.com
16 / 31
Demo?
www.fromdual.com
17 / 31
Load Balancing
● Connectors
● Connector/J
● PHP: MySQLnd replication and load balancing
plug-in
●...
www.fromdual.com
18 / 31
Location of Load Balancing
www.fromdual.com
19 / 31
Demo?
www.fromdual.com
20 / 31
Catch Node State Change
● Node State Change
● Initialized (0), Joining (1), Donor/Desynced (2), S...
www.fromdual.com
21 / 31
Demo?
www.fromdual.com
22 / 31
Online Schema Upgrade (OSU)
● Schema Upgrade = DDL run against the DB
● Change DB structure
● Non...
www.fromdual.com
23 / 31
Total Order Isolation (TOI)
● Default
● Part of the database is locked for the
duration of the DD...
www.fromdual.com
24 / 31
Rolling Schema Upgrade (RSU)
● DDL will be only processed locally at the
node.
● Node is desynchr...
www.fromdual.com
25 / 31
Other security related stuff
www.fromdual.com
26 / 31
Caution!
!
www.fromdual.com
27 / 31
Galera Network Configuration
www.fromdual.com
28 / 31
WAN – Cluster
● WAN = Wide Area Network
● Connect 2 or more locations over a public or
private Ne...
www.fromdual.com
29 / 31
Communication encryption
● 2 Possibilities:
1.) Make Network secure (V-LAN, VPN with SSL, stunnel...
www.fromdual.com
30 / 31
Wir suchen noch:
● Datenbank Enthusiast/in für
Support / remote-DBA / Beratung
www.fromdual.com
31 / 31
Q & A
Questions ?
Discussion?
We have time for some face-to-face talks...
● FromDual provides neu...
Upcoming SlideShare
Loading in...5
×

MySQL always-up with Galera Cluster

318

Published on

MySQL always-up with Galera Cluster. In this presentation we show how a highly available MySQL Cluster with Galera can be set-up.

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
318
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
21
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "MySQL always-up with Galera Cluster"

  1. 1. www.fromdual.com 1 / 31 MySQL always-up with Galera Cluster SLAC 2014 May 14, 2014, Berlin by oli.sennhauser@fromdual.com www.fromdual.com
  2. 2. www.fromdual.com 2 / 31 About FromDual GmbH ● FromDual provides neutral and independent: ● Consulting for MySQL, Galera Cluster, MariaDB and Percona Server ● Support for all MySQL and Galera Cluster ● Remote-DBA Services for all MySQL ● MySQL Training ● Open Source Business Alliance (OSBA) ● Member of SOUG, DOAG, /ch/open www.fromdual.com
  3. 3. www.fromdual.com 3 / 31 Always-up? :-( ● Its also about maintenance... ● Who loves night-shifts? ● Who loves weekend-work? ● Who does regular upgrade (DB, kernel, etc.)? ● Who does regular reboots (after kernel upgrade)? ● Why are you not doing it in your office hours?
  4. 4. www.fromdual.com 4 / 31 The Galera Cluster for MySQL
  5. 5. www.fromdual.com 5 / 31 Maintenance time... App Load balancing (LB) Node 2Node 1 wsrep Galera replication wsrep Node 3 wsrep Upgrade RAM/HW O/S DB?
  6. 6. www.fromdual.com 6 / 31 Advantages / Disadvantages Based on InnoDB SE Synchronous replication → No lost transaction Active-active multi-master Cluster → Read and write to any cluster node (no r/w split any more!) Read scalability and higher write throughput (Flash-Cache?) Automatic node membership control Rolling Restart (Upgrade of Hardware, O/S, DB release, etc.) True parallel replication, on row level → No slave lag A bit more complicated than normal MySQL, but similar complexity as M/S Replication! No original MySQL binaries → Codership MySQL binaries Be aware of Hot Spots on rows: Higher probability of deadlocks
  7. 7. www.fromdual.com 7 / 31 Quorum and Split-brain ● What is the problem? ● Split-brain → bad! ● Galera is a pessimistic Cluster → good! ● Quorum: FLOOR(n/2+1) → more than half! → 3-node Cluster (or 2+1) ?
  8. 8. www.fromdual.com 8 / 31 Quorum
  9. 9. www.fromdual.com 9 / 31 Installation and Configuration
  10. 10. www.fromdual.com 10 / 31 Installation ● Galera Cluster consists of: ● A patched Codership MySQL (mysqld) ● Or MariaDB Galera Cluster ● Or Percona XtraDB Cluster ● The Galera Plugin (libgalera_smm.so) ● Ways of installation ● Packets (RPM, DEB) ● Binary tar-ball ● Patch MySQL source and compile both ● Download http://galeracluster.com/downloads/
  11. 11. www.fromdual.com 11 / 31 MySQL Configuration my.cnf [mysqld] default_storage_engine         = InnoDB binlog_format                  = row innodb_autoinc_lock_mode       = 2   # parallel applying innodb_flush_log_at_trx_commit = 0   # performance only! query_cache_size               = 0   # Galera 3   experimental→ query_cache_type               = 0   # Mutex! Consistency!
  12. 12. www.fromdual.com 12 / 31 Galera Configuration my.cnf (conf.d/wsrep.cnf) [mysqld] # wsrep_provider = none wsrep_provider = …/lib/plugin/libgalera_smm.so # wsrep_cluster_address = "gcomm://" wsrep_cluster_address = "gcomm://ip_node2,ip_node3" wsrep_cluster_name = 'Galera Cluster' wsrep_node_name = 'Node A' wsrep_sst_method = mysqldump wsrep_sst_auth = sst:secret
  13. 13. www.fromdual.com 13 / 31 Operations
  14. 14. www.fromdual.com 14 / 31 Initial Cluster start ● Start very 1st node with: wsrep_cluster_address = "gcomm://" or mysqld_safe ­­wsrep­cluster­address="gcomm://" ● → this tells the node to be the first one! ● All other nodes normal: service mysqld start
  15. 15. www.fromdual.com 15 / 31 Rolling Restart ● Scenario: ● Hardware-, O/S-, DB- and Galera-Upgrade ● MySQL configuration change ● During full operation!!! (99.999% HA, 5x9 HA) ● → Rolling Restart ● Start one node after the other in a cycle ● New features or settings are used after Rolling Restart is completed
  16. 16. www.fromdual.com 16 / 31 Demo?
  17. 17. www.fromdual.com 17 / 31 Load Balancing ● Connectors ● Connector/J ● PHP: MySQLnd replication and load balancing plug-in ● SW Load Balancer ● GLB, LVS/IPVS/Ldirector, HAProxy ● HW Load Balancer
  18. 18. www.fromdual.com 18 / 31 Location of Load Balancing
  19. 19. www.fromdual.com 19 / 31 Demo?
  20. 20. www.fromdual.com 20 / 31 Catch Node State Change ● Node State Change ● Initialized (0), Joining (1), Donor/Desynced (2), Synced (4), ... ● Galera node acts as follows; ● ERROR 2013 (HY000): Lost connection to MySQL  server at 'reading initial communication packet',  system error: 2 ● ERROR 1047 (08S01) at line 1: Unknown command → this is ugly! ● Catch the state change with: ● wsrep_notify_cmd ● To start Firewall Rules (REJECT) ● To take node out of Load Balancer
  21. 21. www.fromdual.com 21 / 31 Demo?
  22. 22. www.fromdual.com 22 / 31 Online Schema Upgrade (OSU) ● Schema Upgrade = DDL run against the DB ● Change DB structure ● Non transactional ● 2 Methods: ● Total Order Isolation (TOI) (default) ● Rolling Schema Upgrade (RSU) ● wsrep_osu_method = {TOI|RSU}
  23. 23. www.fromdual.com 23 / 31 Total Order Isolation (TOI) ● Default ● Part of the database is locked for the duration of the DDL. + Simple, predictable and guaranteed data consistency. - Locking operation ● Good for fast DDL operations
  24. 24. www.fromdual.com 24 / 31 Rolling Schema Upgrade (RSU) ● DDL will be only processed locally at the node. ● Node is desynchronized ● After DDL, delayed write sets are applied ● DDL should be manually executed at each node. + only blocking one node at a time - potentially unsafe and may fail if new and old schema are incompatible ● Good for slow DDL operations
  25. 25. www.fromdual.com 25 / 31 Other security related stuff
  26. 26. www.fromdual.com 26 / 31 Caution! !
  27. 27. www.fromdual.com 27 / 31 Galera Network Configuration
  28. 28. www.fromdual.com 28 / 31 WAN – Cluster ● WAN = Wide Area Network ● Connect 2 or more locations over a public or private Network ● What are the problems? ● Round Trip Time (RTT) ● Throughput ● Network Stability ● Wrong set-ups
  29. 29. www.fromdual.com 29 / 31 Communication encryption ● 2 Possibilities: 1.) Make Network secure (V-LAN, VPN with SSL, stunnel) 2.) Encrypt Galera communication with SSL ● Caution: only Galera replication is affected! ● NOT State Snapshot Transfer (SST, mysqldump | mysql,  rsync) ● NOT Client connection (mysql), use MySQL SSL encryption! ● But Incremental State Transfer (IST) IS affected (= Galera Protocol)! ● We recommend for ease of use: Do it on Network level!
  30. 30. www.fromdual.com 30 / 31 Wir suchen noch: ● Datenbank Enthusiast/in für Support / remote-DBA / Beratung
  31. 31. www.fromdual.com 31 / 31 Q & A Questions ? Discussion? We have time for some face-to-face talks... ● FromDual provides neutral and independent: ● Consulting ● Remote-DBA ● Support for MySQL, Galera, Percona Server and MariaDB ● Training www.fromdual.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×