Installing Galera Cluster 8.0 on SUSE Linux Enterprise Server 15

Table of Contents

SUSE Linux Enterprise Server (SLES) is not a new distro in the market. It has been existed for the past 21 years ago, where the first release was based on Red Hat Linux (version 5.1) and KDE 1 in July 1998. It had since moved away from Red Hat’s distribution and became a completely separate distribution. As of today, SLES is one of the top ten favourite Linux distros listed for enterprise users.

In this blog post, we will show you on how to install Galera Cluster for MySQL 8.0 on SLES 15.

Before we proceed even further, please note that the Galera cluster minimum nodes requirement is 3.

Architecture

Consider the following 3-node Galera cluster 8.0 setup:

  • 192.168.66.101 – Master (galera1.local)
  • 192.168.66.102 – Master (galera2.local)
  • 192.168.66.103 – Master (galera3.local)

Installation Steps

1) Do note that SLES is a subscription-based product. Fortunately, it offers “evaluation license” for testing purposes.

2) After you are registered, you shall get a evaluation code, and we can proceed with registration or activating a system with the SUSE Customer Center (SCC).

SUSEConnect -r {YOUR EVAL CODE} 

3) Add these 2 lines for OSS and NON-OSS repositories:

$ zypper ar -f http://download.opensuse.org/source/distribution/leap/15.2/repo/oss/ 'Main Repository (OSS)'
$ zypper ar -f http://download.opensuse.org/source/distribution/leap/15.2/repo/non-oss/ 'Main Repository (NON-OSS)' 

4) Refresh and update repository:

$ zypper --gpg-auto-import-keys refresh
$ zypper -n up 

5) These are the packages needed for Galera Cluster installation. We will perform an online installation by downloading the packages from here:

  • galera-4-26.4.9-1.sl15_1.x86_64.rpm
  • mysql-wsrep-8.0-8.0.25-26.7.sl15.x86_64.rpm
  • mysql-wsrep-client-8.0.25-26.7.sl15.x86_64.rpm
  • mysql-wsrep-client-plugins-8.0.25-26.7.sl15.x86_64.rpm
  • mysql-wsrep-common-8.0.25-26.7.sl15.x86_64.rpm
  • mysql-wsrep-devel-8.0.25-26.7.sl15.x86_64.rpm
  • mysql-wsrep-libs-8.0.25-26.7.sl15.x86_64.rpm
  • mysql-wsrep-server-8.0.25-26.7.sl15.x86_64.rpm

6) Import GPG-KEY and install Galera Cluster packages using zypper:

$ rpm --import "https://releases.galeracluster.com/GPG-KEY-galeracluster.com"
$ zypper --gpg-auto-import-keys -n install *.rpm 

7) Back up the original /etc/my.cnf file:

$ mv /etc/my.cnf /etc/my.cnf.ori 

8) Create a new my.cnf below and replace the {@@SERVERID@@} with identical integer, e.g: 1,2 or 3 (It must be unique from each nodes). Also, replace {@@SERVERIP@@} with the node’s IP.

#
# Basic my.cnf template for Galera-4 
# Copyright (C) 2022 DataSpeed.com.my
#

[mysqld]
datadir			                = /var/lib/mysql
socket				            = /var/lib/mysql/mysql.sock
user 				            = mysql
binlog_format			        = ROW
bind-address			        = 0.0.0.0
default_storage_engine	        = Innodb
Innodb_autoinc_lock_mode        = 2
Innodb_flush_log_at_trx_commit  = 0
innodb_buffer_pool_size	        = 512M
wsrep_provider 		            = /usr/lib64/galera-4/libgalera_smm.so
wsrep_provider_options	        = "gcache.size=300M; gcache.page_size=300M"
wsrep_cluster_name		        = "example_cluster"
wsrep_cluster_address	        = "gcomm://192.168.66.101,192.168.66.102,192.168.66.103"
wsrep_sst_method		        = rsync
server_id                       = @@SERVERID@@
log_error                       = /var/log/mysqld.log
wsrep_node_address		        = @@SERVERIP@@
wsrep_node_name		            = @@SERVERIP@@
Wsrep_sst_receive_address       = @@SERVERIP@@
wsrep_sst_auth		            = "backup:P455w0rd"

[mysql_safe]
log-error				        = /var/log/mysqld.log
pid-file				        = /var/run/mysqld/mysqld.pid

[xtrabackup]
User                            = backup
Password                        = P455w0rd
socket				            = /var/lib/mysql/mysql.sock 

9) Place my.cnf at /etc/my.cnf. Change the ownership to mysql user:

$ chown mysql:mysql /etc/my.cnf 

10) Once everything complete, remember this. Only the first node needs to be bootstrap. Run the bootstrap command on 192.168.66.101:

$ mysqld_bootstrap 

11) Create backup and replication user, grant those users with necessary privileges:

mysql> CREATE USER backup@'%' IDENTIFIED BY "P455w0rd";
mysql> GRANT SELECT, INSERT, CREATE, BACKUP_ADMIN, PROCESS, RELOAD, PROCESS, SUPER, LOCK TABLES, REPLICATION CLIENT, SHOW VIEW, EVENT, CREATE TABLESPACE ON *.* TO backup@'%';
mysql> GRANT SELECT ON performance_schema.log_status TO backup@localhost;
mysql> GRANT SELECT ON performance_schema.keyring_component_status TO backup@'%';
mysql> CREATE USER slave@'%' IDENTIFIED BY "BF2d2Kc8Hid";
mysql> GRANT REPLICATION SLAVE ON *.* TO slave@'%';
mysql> FLUSH PRIVILEGES; 

12) Start the joiner nodes (192.168.66.102, 192.168.66.103), one node at a time:

$ systemctl start mysql 

13) Make sure your cluster size is equivalent to the number of nodes you have, indicating the cluster is fully formed. To check the cluster size, access to the mysql client and do:

mysql> SHOW STATUS LIKE "wsrep_cluster_size";

Make sure you get 3 for the cluster size value.

Related Post: