MySQL Multi Master replication with GaleraIvan Mora Pérez | Clustering, Database, GNU/Linux | 6 Galera is a synchronous multi-master cluster for MySQL/InnoDB databases. Some features and benefits of Galera are:
The motivation to implement Galera instead MySQL master/slave replication, comes that the reads to a database can be balanced between the nodes, but not the writers, that have to be executed by the master node. Another reason to use Galera is for the synchronous replication, in a scenario with a master/slave the replication is asynchronous this means that the binary log files may be different on the different nodes. To install galera cluster it’s necessary a MySQL version patched with wsrep API, provided by codership. wsrep is a project to develop a generic replication plugin interface for databases, defining a set of application callbacks and replication library calls. Wsrep can load dynamically different wsrep providers, that is simply a library working under wsrep and calling to the different functionalities of wsrep API’s, one example of it is Galera used in this post. For galera, an application state is a set of data that the application decides to replicate (databases) and is identified by a global transaction id (GTID), consists of: There are different ways to transfer a state from one node to another, one possibility may be mysqldump but can be the slowest method due to mysqldump block the tables of the server from possible changes during the transfer. Another method can be rsync (used in this post) or xtrabackup, that consist in copying data files directly and is the fastest method. The scenario proposed in this post is with three nodes (minimum recomended to avoid a split brain situation). The ip address used are:
In the configuration cluster mysql2 is connected with mysql1 and mysql3 will connect with mysql2. When the connection between mysql2 and mysql3 was established, the group communication address for mysql1 will configured with the address of mysql3 creating an unidirectional communication with all the nodes in the cluster. Implementation of MySQL Galera on MySQL 1, MySQL 2 and MySQL 3 - Installing some mysql dependencies:
- Install MySQL server with wsrep patch: - 32 bits:
- 64 bits:
- Download and install Galera : - 32 bits:
- 64 bits:
- Preparing initial mysql setup:
- Start mysql at boot time:
Configuring MySQL 1
- For the first node gcomm:// address is empty to create the new cluster. Later We’ll reconnect with the MySQL3 node. Configuring MySQL 2
Configuring MySQL 3
Reconfiguring MySQL 1
Checking wsrep variables
The most important variables are wsrep_ready, if the value is ON it means that the cluster is working, and wsrep_cluster_size that is equals to the number of nodes that is composed the cluster. Sources http://www./wiki/doku.php?id=info Google+Related Posts
galera, multi-master, mysql, wsrep
Making Iptables easier with Shorewall Configuring Galera arbitrator 6 thoughts on “MySQL Multi Master replication with Galera”
|
|