Home CentMinMod Creating MariaDB Galera Clustering

Creating MariaDB Galera Clustering

MariaDB Galera Cluster is a synchronous multi-master cluster for MariaDB. It is available on Linux only, and only supports the XtraDB/InnoDB storage engines (although there is experimental support for MyISAM – see the wsrep_replicate_myisam system variable).

Features

  • Synchronous replication
  • Active-active multi-master topology
  • Read and write to any cluster node
  • Automatic membership control, failed nodes drop from the cluster
  • Automatic node joining
  • True parallel replication, on row level
  • Direct client connections, native MariaDB look & feel

Benefits

The above features yield several benefits for a DBMS clustering solution, including:

  • No slave lag
  • No lost transactions
  • Both read and write scalability
  • Smaller client latencies

First Create 3 Nodes of Centminmod Installation

Node1:192.168.1.1 (CMM Installed) (MariaDB Cluster 1)
Node2:192.168.1.2 (CMM Installed) (MariaDB Cluster 2)
Node3:192.168.1.3 (CMM Installed) (MariaDB Cluster 3)
Node4:192.168.1.4 (CMM Installed) (Haproxy)


Open These ports 4567,4568,4444,3306 under TCP in your firewall (CSF or IPTABLES) on All MariaDB Cluster nodes.


On 192.168.1.1 (CMM Installed) (MariaDB Cluster 1)

Edit my.cnf file and at the end add lines below

Must change
Replace wsrep_node_address=”192.168.1.1″ with your node1 IP address.
Replace wsrep_cluster_address=gcomm://192.168.1.1,192.168.1.2,192.168.1.3 with your node1,node2,node3 IP respectively.


Alternatively you can also

Replace wsrep_cluster_name=”bullten” as you want but do remember it should be same on all nodes.
Replace wsrep_node_name=”node1″ to any name you want.

vi /etc/my.cnf
 [galera]
 # Mandatory settings
 wsrep_on=ON
 wsrep_cluster_name="bullten"
 wsrep_node_name="node1"
 wsrep_node_address="192.168.1.1"
 #wsrep_provider_options='pc.recovery=ON'
 wsrep_provider=/usr/lib64/galera/libgalera_smm.so
 wsrep_cluster_address=gcomm://192.168.1.1,192.168.1.2,192.168.1.3
 binlog_format=row
 innodb_autoinc_lock_mode=2 

Stop MariaDB

systemctl stop mariadb

Start Galera Cluster

galera_new_cluster

Change the permission

chown -R mysql:mysql /var/lib/mysql

On 192.168.1.2 (CMM Installed) (MariaDB Cluster 2)

Edit my.cnf file and at the end add lines below

Must change
Replace wsrep_node_address=”192.168.1.2″ with your node2 IP address.
Replace wsrep_cluster_address=gcomm://192.168.1.1,192.168.1.2,192.168.1.3 with your node1,node2,node3 IP respectively.


Alternatively you can also

Replace wsrep_node_name=”node2″ to any name you want.

vi /etc/my.cnf
 [galera]
 # Mandatory settings
 wsrep_on=ON
 wsrep_cluster_name="bullten"
 wsrep_node_name="node2"
 wsrep_node_address="192.168.1.2"
 #wsrep_provider_options='pc.recovery=ON'
 wsrep_provider=/usr/lib64/galera/libgalera_smm.so
 wsrep_cluster_address=gcomm://192.168.1.1,192.168.1.2,192.168.1.3
 binlog_format=row
 innodb_autoinc_lock_mode=2

Change the permission

chown -R mysql:mysql /var/lib/mysql

Stop MariaDB

systemctl stop mariadb

Start MariaDB

systemctl start mariadb

On 192.168.1.3 (CMM Installed) (MariaDB Cluster 3)

Edit my.cnf file and at the end add lines below

Must change
Replace wsrep_node_address=”192.168.1.3″ with your node3 IP address.
Replace wsrep_cluster_address=gcomm://192.168.1.1,192.168.1.2,192.168.1.3 with your node1,node2,node3 IP respectively.


Alternatively you can also

Replace wsrep_node_name=”node3″ to any name you want.

vi /etc/my.cnf
[galera]
 # Mandatory settings
 wsrep_on=ON
 wsrep_cluster_name="bullten"
 wsrep_node_name="node3"
 wsrep_node_address="192.168.1.3"
 #wsrep_provider_options='pc.recovery=ON'
 wsrep_provider=/usr/lib64/galera/libgalera_smm.so
 wsrep_cluster_address=gcomm://192.168.1.1,192.168.1.2,192.168.1.3
 binlog_format=row
 innodb_autoinc_lock_mode=2 

Change the permission

chown -R mysql:mysql /var/lib/mysql

Stop MariaDB

systemctl stop mariadb

Start MariaDB

systemctl start mariadb

Now your Node is connected to check cluster size run the below command on any MariaDB node

SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';

wsrep_cluster_size = 3 shows three nodes are inter connected.

Must Read

Enable Logging in Haproxy

HAProxy can emit log message for processing by a syslog server. This is compatible with familiar syslog tools like Rsyslog, as well...

Getting real IP in Nginx when behind cloudflare Haproxy

Create a file named cloudflare_ips.ls and in that add all the cloudflare IP's vi /etc/haproxy/cloudflare_ips.ls 173.245.48.0/20 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22 141.101.64.0/18 108.162.192.0/18 190.93.240.0/20 188.114.96.0/20 197.234.240.0/22 198.41.128.0/17 162.158.0.0/15 104.16.0.0/12 172.64.0.0/13 131.0.72.0/22 2400:cb00::/32 2606:4700::/32 2803:f800::/32 2405:b500::/32 2405:8100::/32 2a06:98c0::/29 2c0f:f248::/32

Getting Real IP in HaproxyNginx configuration

Well its a little configuration can get real to nginx when haproxy is set as reverse proxy. Follow this...

Haproxy as Single Point to Failure Node With Glusterfs and MariaDB Maxscale Cluster

HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It...

GlusterFS Replication on CentOS 7

GlusterFS is a scalable network filesystem suitable for data-intensive tasks such as cloud storage and media streaming. GlusterFS is free and open...