Step-by-Step: How to Create a 2-Node MySQL Cluster Without Shared Storage, Part 1

HIgh Availability
Reading Time: 3 minutes

The primary advantage of running a MySQL cluster is obviously high availability (HA). To get the most from this type of solution, you will want to eliminate as many potential single points of failure as possible. Conventional wisdom says that you can’t form a cluster without some type of shared storage, which technically represents a single point of failure in your clustering architecture. However, there are solutions, such as the SIOS LifeKeeper for Linux, that allow you to eliminate storage as a single point of failure by providing real-time data replication between cluster nodes. SIOS LifeKeeper is sold in a bundle called SIOS Protection Suite (SPS), which includes SIOS LifeKeeper, application recovery kit(s), and DataKeeper replication.

Let’s look at a typical scenario: You form a cluster that leverages local, replicated storage to protect a MySQL database.

This step-by-step discussion presumes that you’re working with an evaluation copy of LIfeKeeper in a lab environment. We’re also presuming that you’ve confirmed that the primary and secondary servers and the network all meet the requirements for running this type of setup.

Getting started

Before you begin setting up your cluster, you’ll need to configure the storage. The data that you want to replicate need to reside on a separate file system or logical volume. Keep in mind that the size of the target disk, whether you’re using a partition or logical volume, must be equal to or larger than the source.

In this example, we presume that you’re using a disk partition. (However, LVM is also fully supported.) First, partition the local storage for use with SIOS DataKeeper. On the primary server, identify a free, unused disk partition to use as the MySQL repository or create a new partition. Use the fdisk utility to partition the disk, then format the partition and temporarily mount it at /mnt. Move any existing data from /var/lib/mysql/ into this new disk partition (assuming a default MySQL configuration). Unmount and then remount the partition at /var/lib/mysql. You don’t need to add this partition to /etc/fstab, as it will be mounted automatically by LifeKeeper.

On the secondary server, configure your disk as you did on the primary server.

Installing MySQL

Next you’ll deal with MySQL. On the primary server, install both the mysql and mysql-server RPM packages (if they don’t already exist on the system) and apply any required dependencies. Verify that your local disk partition is still mounted at /var/lib/mysql. If necessary, initialize a sample MySQL database. Ensure that all the files in your MySQL data directory (/var/lib/mysql) have the correct permissions and ownership, and then manually start the MySQL daemon from the command line.

(Note: Do not start MySQL via the service command or the /etc/init.d/ script.)

Connect with the mysql client to verify that MySQL is running.

Update and verify the root password for your MySQL configuration. Then create a MySQL configuration file, such as the sample file shown here:
———-
# cat /var/lib/mysql/my.cnf
[mysqld]datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid-file=/var/lib/mysql/mysqld.pid
user=root
port=3306
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]user=root
password=SteelEye
———-
In this example, we place this file in the same directory that we will later replicate (/var/lib/mysql/my.cnf). Delete the original MySQL configuration file (in /etc).
On the secondary server, install both the mysql and mysql-server RPM packages if necessary, apply any dependencies, and ensure that all the files in your MySQL data directory (/var/lib/mysql) have the correct permissions and ownership.

Installing SIOS Protection Suite for Linux

Next, install SIOS LifeKeeper for Linux. For ease of installation, SIOS provides a unified installation script (called “setup”) for SIOS Protection Suite for Linux. Instructions for how to obtain this software are in an email that comes with the SIOS Protection Suite for Linux evaluation license keys.

Download the software and evaluation license keys on both the primary and secondary servers. On each server, run the installer script, which will install a handful of prerequisite RPMs, the core clustering software, and any optional ARKs that are needed. In this case, you will want to install the MySQL ARK (steeleye-lkSQL) and the DataKeeper (i.e., Data Replication) ARK (steeleye-lkDR). Apply the license key via the /opt/LifeKeeper/bin/lkkeyins command and start SPS for Linux via its start script, /opt/LifeKeeper/lkstart.

At this point you have SIOS LifeKeeper installed, licensed, and running on both of your nodes, and your disk and the MySQL database that you want to protect are configured.

In the next post, we’ll look at the remaining steps in the shared-nothing clustering process:

  • Creating communication (Comm) paths, i.e. heartbeats, between the primary and target servers
  • Creating an IP resource
  • Creating the mirror and launching data replication
  • Creating the MySQL database resource
  • Creating the MySQL IP address dependency

Recent Posts

CloudStrike Downtime Debrief: Practical Ways To Use HA For Patching

As a company dedicated to protecting critical applications from downtime, we want to share some context and practical advice about IT patching policies […]

Read More

Maintain HA and DR When Converting a Shared Storage Cluster to a SANless Cluster with DataKeeper

1. Prepare the Environment 2. Put the Shared Storage Cluster into Maintenance Mode 3. Adjust Shared Disk Access 4. Remove the Shared Storage […]

Read More
SIOS Documentation

Find it faster: 8 Secrets to Navigating Product Documentation

Here are a few ways you can find exactly what you are looking for in Product Documentation. Product documentation is very thorough and […]

Read More