{"id":2283,"date":"2012-02-05T07:30:42","date_gmt":"2012-02-05T12:30:42","guid":{"rendered":"http:\/\/www.bytebot.net\/blog\/?p=2283"},"modified":"2012-02-05T07:30:46","modified_gmt":"2012-02-05T12:30:46","slug":"mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser","status":"publish","type":"post","link":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser","title":{"rendered":"MySQL synchronous replication in practice with Galera by Oli Sennhauser"},"content":{"rendered":"<p><a href=\"http:\/\/www.shinguz.ch\/\">Oli Sennhauser<\/a> of <a href=\"http:\/\/fromdual.com\/\">FromDual<\/a>.<\/p>\n<p>Synchronous multi-master replication with the Galera plugin. Your application connects to the load balancer and it redirects read\/write traffic to the various MySQL Galera nodes. Tested a setup with 17 SQL nodes and you can have even more. Scaling reads and also a little bit for scaling writes is what Galera is good for.<\/p>\n<p>If one node fails, the other two nodes still communicates with each other and the load balancer is aware of the failed node.<\/p>\n<p>Why Galera? There is master-slave replication but its not multi-master, and its asynchronous and you can get inconsistencies. There is master-master replication but its asynchronous and can have inconsistencies and conflicts if you write on both nodes. MHA\/MMM\/Tungsten are not providing new technology but are based on the MySQL replication technology. MySQL Cluster is another solution but its not InnoDB storage &amp; your need new know-how for Cluster. Also Cluster has problems with fast JOINs. Active\/Passive failover clustering, but too often you have resources idling. Schooner being closed &amp; expensive is hard to know much about what they&#8217;re doing.<\/p>\n<p>Galera is synchronous &amp; based on InnoDB (others should in theory be possible). Active-active real multi-master topology. True parallel replication on row level. Cluster speaks with each other. There is no slave lag. Won&#8217;t lose transactions. Read\/write scalability, write throughput can be improved but can&#8217;t scale in the way like MySQL Cluster.<\/p>\n<p>Disadvantages? Its not native MySQL binaries\/sources but a patch. Codership provides binaries. Higher probability of deadlocks. When you do a full sync (like when a node comes back after downtime), one node is blocked. This is why the minimum you need a 3-node cluster. Also if you do a full sync with a database larger than 50GB, the recommended method is to use mysqldump (which can be very slow). You can use rsync. Percona is working on xtrabackup to do a full sync between nodes.<\/p>\n<p>Setup: 3 nodes are recommended. Or just 2 nodes and one for garbd (Galera Arbitrator Daemon). 2 nodes works but pay attention to a split brain scenario. Go to the Codership website, download their binaries and wsrep (the Galera plug-in). Create your own user on all nodes (don&#8217;t use the default root user). You then need to configure my.cnf (there have been discussions for a galera.conf, but Oli just uses my.cnf). Galera works only with InnoDB, so in my.cnf make the default storage engine InnoDB (don&#8217;t for example, by accident have MyISAM tables).<\/p>\n<p>The demo has a strange Galera start script, but its not been easy to work. Just start MySQL usually like you would do.<\/p>\n<p>SST is Snapshot State Transfer (SST). Its the initial full sync between the 1st and the other node. SST blocks the donor node (hence why you need 3 nodes). With Galera v2.0, there is also incremental state transfer. It should be GA in February 2012. You can get deltas as opposed to the full sync. You can configure which will be the donor node.<\/p>\n<p>Currently there are 27 variables about Galera in v1.1. You can do it just by doing SHOW GLOBAL VARIABLES LIKE &#8216;wsrep%&#8217;;. The plugin itself, wsrep_provider_options has plenty of options &amp; plenty of room for tuning. SHOW GLOBAL STATUS LIKE &#8216;wsrep%&#8217;; currently has 38 status information fields in Galera v1.1.<\/p>\n<p>For load balancing, you can do it in your application (on your own). You can also use Connector\/J which provides load balancing. There is also a PHP MySQLnd that works.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20MySQL%20synchronous%20replication%20in%20practice%20with%20Galera%20by%20Oli%20Sennhauser&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2012%2F02%2F05%2Fmysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"150cb46b28\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-2283\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-2283\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-2283\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Oli Sennhauser of FromDual. Synchronous multi-master replication with the Galera plugin. Your application connects to the load balancer and it redirects read\/write traffic to the various MySQL Galera nodes. Tested a setup with 17 SQL nodes and you can have even more. Scaling reads and also a little bit for scaling writes is what Galera [&hellip;]<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20MySQL%20synchronous%20replication%20in%20practice%20with%20Galera%20by%20Oli%20Sennhauser&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2012%2F02%2F05%2Fmysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"150cb46b28\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-2283\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-2283\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-2283\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-synchronous-replication-in-practice-with-galera-by-oli-sennhauser?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[23],"tags":[1332,1346,1334],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4vJD-AP","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2253,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-ha-reloaded-by-ivan-zoratti","url_meta":{"origin":2283,"position":0},"title":"MySQL HA reloaded by Ivan Zoratti","date":"5\/2\/2012","format":false,"excerpt":"MySQL HA reloaded - old tricks and cool new tools to guarantee high availability to your MySQL Servers by Ivan Zoratti of SkySQL. This talk is a little longer, so check out: HA Reloaded - many ways to provide High Availability. The slides are already online. Questions to ask: which\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2265,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mysql-cluster-by-ralf-gebhardt","url_meta":{"origin":2283,"position":1},"title":"MySQL Cluster by Ralf Gebhardt","date":"5\/2\/2012","format":false,"excerpt":"Ralf Gebhardt of SkySQL. Cluster: shared nothing architecture (no single point of failure), synchronous replication between nodes, ACID transactions, row level locking. In-memory storage (some data can be stored on disk, but indexes must be in-memory). Checkpointing to disk for durability. It supports two types of indexes - ordered T-trees,\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2262,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/building-simple-complex-replication-clusters-with-tungsten-replicator-by-giuseppe-maxia","url_meta":{"origin":2283,"position":2},"title":"Building simple &#038; complex replication clusters with Tungsten Replicator by Giuseppe Maxia","date":"5\/2\/2012","format":false,"excerpt":"Giuseppe Maxia of Continuent. MySQL replication is single threaded. Multi-master replication is complex with MySQL. Circular replication works but is very fragile. Once you've achieved the feat, how do you avoid conflicts? The lack of global transaction ID today also means you may have slaves that may not be synchronized\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":562,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/06\/05\/ticketmaster-thrives-on-mysql-replication","url_meta":{"origin":2283,"position":3},"title":"Ticketmaster thrives on MySQL Replication","date":"5\/6\/2007","format":false,"excerpt":"Even though the conference is long over, I still have unpublished notes sitting on my ~\/Desktop, and it only makes sense that I clean it out. These are notes from Ed Presz's session, titled For Ticketmaster, MySQL Replication is the Ticket! They are as always, pretty raw.We were all given\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":537,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/04\/26\/mysql-at-google","url_meta":{"origin":2283,"position":4},"title":"MySQL at Google","date":"26\/4\/2007","format":false,"excerpt":"MySQL: The Real Grid Database, Mark Callaghan, Chip Turner A tremendous amount of work also done by Wei Li and Gene Pang. Google has a large MySQL deployment, and they enhance it as needed. MySQL@Google: too many queries, transactions, data, and rapid growth. Real workload with OLTP and reporting. Workload\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2295,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/replication-features-of-2011-by-sergey-petrunia","url_meta":{"origin":2283,"position":5},"title":"Replication features of 2011 by Sergey Petrunia","date":"5\/2\/2012","format":false,"excerpt":"Sergey Petrunia of the\u00a0MariaDB project & Monty Program. MySQL 5.5 GA at the end of 2010. MariaDB 5.3 RC towards the end of 2011 (beta in June 2011). MySQL 5.5 is merged to Percona Server 5.5 which included semi-sync replication, slave fsync options, atuomatic relay log recovery, RBR slave type\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/2283"}],"collection":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/comments?post=2283"}],"version-history":[{"count":2,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/2283\/revisions"}],"predecessor-version":[{"id":2285,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/2283\/revisions\/2285"}],"wp:attachment":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/media?parent=2283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/categories?post=2283"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/tags?post=2283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}