Sunday, February 28, 2016

A quick intro of Galera Cluster for Mariadb on Debian 8 Jessie

This will be very quick. Make sure you have this in  your my.cnf

[mysqld]
#mysql settings
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
query_cache_size=0
query_cache_type=0
bind-address=0.0.0.0
#galera settings
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="my_wsrep_cluster"
wsrep_cluster_address="gcomm://nodeA,nodeB,nodeC"
wsrep_sst_method=rsync
Adjust SST Method to whatever you prefer, read more here: http://galeracluster.com/documentation-webpages/sst.html

SST=State Transfer Method= The way of how to transfer the initial complete image of the databases.
IST= Incremental State Transfer = The replication stream across the nodes

Adjust Clustername and Node Adresses in gcomm line. You can, and I recommend to use hostnames (be sure to define them in /etc/hosts)! The reason for this is that other wsrep variables like "prefered donor" or "node name" expect a hostname and ip can cause issues (I learnt that the hard way).

Make sure following ports are open on all nodes:
http://support.severalnines.com/entries/22654676-firewall-ports

To start a new cluster you need a bootstrap node that acts as the initial starting point, yet later is just a simple node.
On Debian start a new cluster by running "galera_new_cluster" script.

MUST READ:
Monitoring the cluster:
http://galeracluster.com/documentation-webpages/monitoringthecluster.html

Now the best way to learn about all possible failure/shutdown scenarios is to read this: https://www.percona.com/blog/2014/09/01/galera-replication-how-to-recover-a-pxc-cluster/

Also read up on all wsrep vars: https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/

You can read yours with running "SHOW STATUS LIKE 'wsrep%';"

No comments:

Post a Comment