← All insights
database

Installing Galera Cluster 8.0 on SUSE Linux Enterprise Server 15

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…

Installing Galera Cluster 8.0 on SUSE Linux Enterprise Server 15

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

flowchart TD App --> lb1(<b>lb1</b><br>ProxySQL) --> db1[(<b>192.168.66.101</b><br>Galera Cluster for MySQL)] & db2[(<b>192.168.66.102</b><br>Galera Cluster for MySQL)] & db3[(<b>192.168.66.103</b><br>Galera Cluster for MySQL)] subgraph "Galera Replication" db1 db2 db3 end

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
  1. 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 
  2. Back up the original /etc/my.cnf file:

    $ mv /etc/my.cnf /etc/my.cnf.ori 
  3. 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 
  4. Place my.cnf at /etc/my.cnf. Change the ownership to mysql user:

    $ chown mysql:mysql /etc/my.cnf 
  5. Once everything complete, remember this. Only the first node needs to be bootstrap. Run the bootstrap command on 192.168.66.101:

    $ mysqld_bootstrap 
  6. 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; 
  7. Start the joiner nodes (192.168.66.102, 192.168.66.103), one node at a time:

    $ systemctl start mysql 
  8. 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.

Let’s build something reliable

Your next chapter.
A stronger database.

Tell us what you’re working on. We’ll take it from there.

Let’s talk