Deploying a Galera Cluster in Ubuntu 18.04

Setup APT repositories

apt-key adv — keyserver http://keyserver.ubuntu.com — recv BC19DDBA
deb https://releases.galeracluster.com/galera-4/ubuntu bionic main
deb https://releases.galeracluster.com/mysql-wsrep-8.0/ubuntu bionic main

Install Packages

apt-get updateapt-get install galera-4 mysql-wsrep-8.0

Disable apparmor for mysqld

apt install apparmor-utilsaa-disable mysqld

Gelera Configuration

binlog_format=ROWdefault-storage-engine=innodbinnodb_autoinc_lock_mode=2bind-address=0.0.0.0wsrep_on=ONwsrep_provider=/usr/lib/galera/libgalera_smm.sowsrep_cluster_name=”<Database Name>”wsrep_cluster_address=”gcomm://<Add your database nodes IP Addresses>”wsrep_sst_method=rsyncwsrep_node_address=“<Current Node IP address>”wsrep_node_name=“<Current node name>”

High Availability(HA) Consideration

wsrep_provider_options="gmcast.segment=1"

Bootstrap Galera Cluster

systemctl stop mysqlmysqld_bootstrap --wsrep-new-cluster
mysql -u root -p -r "show status like 'wsrep_cluster_size'"
+ — — — — — — — — — — + — — — -+| Variable_name        | Value |+ — — — — — — — — — — + — — — -+| wsrep_cluster_size  |      1 |+ — — — — — — — — — — + — — — -+
vim /var/lib/mysql/grastate.dat
# GALERA  saved  state
...(other configurations)
safe_to_bootstrap: 1
mysqld_bootstrap
systemctl status mysql
mysql.service  - MySQL  Wsrep  Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled;vendor preset: enabled)
Active: active (running) since Mon 2022 -01 -31 23:25:11 UTC; 4 days ago

Start the remaining nodes

systemctl restart mysql
mysql -u root -p -r "show status like 'wsrep_cluster_size'"
+ — — — — — — — — — — + — — — -+| Variable_name       |  Value |+ — — — — — — — — — — + — — — -+| wsrep_cluster_size  |      2 |+ — — — — — — — — — — + — — — -+

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store