Galera replication

90 views

Published on

MySQL master-master replication with Galera

Published in: Engineering
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
90
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Galera replication

  1. 1. GaleraGalera Master-MasterMaster-Master ReplicationReplication Marian HackMan Marinov <mm@1h.com>
  2. 2. What is the BinaryLog? UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100 CLIENTCLIENT
  3. 3. What is the BinaryLog? UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100 CLIENTCLIENT
  4. 4. What is the BinaryLog? UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100 CLIENTCLIENT SUCCESS
  5. 5. What is the BinaryLog? UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100 CLIENTCLIENT SUCCESS
  6. 6. Types of Replication ● STATEMENT ● ROW ● MIXED ● Master-Slave ● Master-Master
  7. 7. Types of Replication ● STATEMENT UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100; INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1);
  8. 8. Types of Replication ● ROW table t1 change:table t1 change: ROW id=100 count=100ROW id=100 count=100 table t1 change:table t1 change: add row with id=102, count=1add row with id=102, count=1
  9. 9. Types of Replication ● MIXED UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100; table t1 change:table t1 change: ROW id=100 count=100ROW id=100 count=100 INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1); table t1 change:table t1 change: add row with id=102, count=1add row with id=102, count=1
  10. 10. What is Galera ● Write set replication - WSREPWrite set replication - WSREP ● Global Transaction ID - GTIDGlobal Transaction ID - GTID
  11. 11. What is Galera ● Write set replication - WSREPWrite set replication - WSREP UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100; INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1); Write setWrite set
  12. 12. What is Galera ● Write set replication - WSREPWrite set replication - WSREP UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100; INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1); Write setWrite set GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367
  13. 13. What is Galera ● Write set replication - WSREPWrite set replication - WSREP UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100; INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1); Write setWrite set GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367 Certification based replication???Certification based replication???
  14. 14. ● WSREP XXX-XXX – certificate that it can proceed – check based on table's primary key
  15. 15. How is it implemented?
  16. 16. How is it implemented?
  17. 17. How is it implemented? ● WSREP plugin – backing up data ● logs and files – conns between nodes – generating GTIDs – certification of WSETs WSREP
  18. 18. How is it implemented?
  19. 19. Node states
  20. 20. ● State Snapshot Transfer (SST) – Logical - mysqldump – Physical ● rsync/rsync_wan ● xtrabackup wsrep_sst_method=xtrabackupv2 ● Incremental State Transfer (IST) 5a76ef62-30ec-11e1-0800-dba504cf2aab:197222 5a76ef62-30ec-11e1-0800-dba504cf2aab:201913 – Write-set cache (GCache)
  21. 21. Requirements ● binlog_format=ROW ● Storage engine InnoDB/XtraDB ● All tables should have a primary key
  22. 22. Setup /etc/yum.repos.d/galera.repo [galera] name = Galera baseurl = http://releases.galeracluster.com/centos/6/x86_64 gpgkey = http://releases.galeracluster.com/GPG- KEY-galeracluster.com gpgcheck = 1
  23. 23. Setup yum install Percona-XtraDB-Cluster-server Percona-XtraDB-Cluster-client Percona-XtraDB-Cluster-galera-3.x86_64 galera socat pv pigz nc
  24. 24. Setup datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql binlog_format=ROW bind-address=0.0.0.0 default_storage_engine=innodb innodb_autoinc_lock_mode=2 innodb_flush_log_at_trx_commit=0 innodb_buffer_pool_size=122M
  25. 25. Setup wsrep_provider=/usr/lib64/galera3/libgalera_smm.so wsrep_provider_options="gcache.size=300M;gcache.p age_size=300M" wsrep_cluster_name="example_cluster" wsrep_cluster_address="gcomm://10.19.1.8,10.19.1.9" wsrep_sst_method=xtrabackup-v2 wsrep_sst_auth="root:ensurethehighest"
  26. 26. Setup [sst] progress=/var/log/mysql/sst.log streamfmt=xbstream transferfmt=socat encrypt=2 encrypt-algo=AES256 tkey=/etc/mysql/key.pem tcert=/etc/mysql/cert.pem compressor="pigz -6" decompressor="pigz -d"
  27. 27. First start # mysql_install_db # service mysql start --wsrep-new-cluster
  28. 28. Adding new node ● Add GRANTs for the new machine – GRANT ALL ON *.* TO 'root'@'10.19.1.10' IDENTIFIED BY 'ensurethehighest'; ● Copy the my.cnf from another node ● Fix the node_name and node_address ● Add the IP of the local node to cluster_address ● Start MySQL on the new node ● After the sync is done and the new node is in the cluster – update the cluster_address in the configuration of the other nodes – update the cluster_address in the running mysql instances: mysql> set global wsrep_cluster_address = 'gcomm://10.19.1.8,10.19.1.9,10.19.1.10';
  29. 29. Arbitrator # chkconfig garb on # cat /etc/sysconfig/garb GALERA_NODES="10.19.1.8:4567 10.19.1.9:4567 10.19.1.10:4567" GALERA_GROUP="gp_cluster" # /etc/init.d/garb restart
  30. 30. QUESTIONS???QUESTIONS??? Marian HackMan Marinov <mm@1h.com>

×