How to install and configure MariaDB Galera as master to master replication cluster on Ubuntu 16.04 LTS
Here's how you can install and configure MariaDB Galera as a master-to-master replication cluster on Ubuntu 16.04 LTS:
- Install MariaDB on each node in the cluster:
sudo apt-get update
sudo apt-get install software-properties-commonrnsudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.3/ubuntu xenial main'
sudo apt-get update
sudo apt-get install mariadb-server mariadb-client- Start the MariaDB service on the first node:
sudo systemctl start mariadb- Configure MariaDB on the first node by running the following command:
sudo mysql_secure_installation- Stop the MariaDB service on the first node:
sudo systemctl stop mariadb- On the first node, add the following lines to the
/etc/mysql/my.cnffile to configure Galera replication:
binlog_format=ROWrndefault-storage-engine=innodbrninnodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_provider=/usr/lib/galera/libgalera_smm.sornrn# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://<node1_ip>,<node2_ip>,<node3_ip>"
# Galera Node Configuration
wsrep_node_address="<this_node_ip>"
wsrep_node_name="<this_node_hostname>"
# Galera Synchronization Configuration
wsrep_sst_method=rsyncReplace <node1_ip>, <node2_ip>, and <node3_ip> with the IP addresses of all nodes in the cluster, <this_node_ip> with the IP address of the current node, and <this_node_hostname> with the hostname of the current node.
- Repeat steps 2 to 5 on each node in the cluster.
- Start the MariaDB service on the first node:
sudo systemctl start mariadb- Start the MariaDB service on the other nodes in the cluster, one node at a time.
