Setting up a cluster

This section discusses how to set up a cluster. However, let's first discuss the requirements of a cluster.

Requirements

As mentioned earlier, all cluster nodes must run on Linux systems.

There are no particular hardware requirements; in fact, if a server can smoothly run a standalone MariaDB server, it can also run on a Galera node. During normal operations, the additional amount of memory used for a Galera replication is minimal and wouldn't make much of a difference. The only exception is that the copying of the entire database from one node to another consumes a lot of memory. This happens when a new node joins the cluster, or when a disconnected node rejoins the cluster. However, when choosing the hardware of individual nodes, we should keep in mind that the cluster will be as slow as its slowest node.

The connection between nodes must be fast enough for the workload we are going to run. If possible, MariaDB Galera Cluster should run on a subnetwork that does not contain any other hosts. Since Galera replication implies constant communication between all the nodes, having non-related network traffic on the same network will reduce the performance. Also, preventing external hosts from directly connecting to the cluster nodes is an important security enhancement.

Of course, nodes that accept connections from the clients will need more memory to perform the queries. We might also want to use a load balancer to optimally distribute the queries over multiple nodes. This technique is described later in this chapter.

Installation

MariaDB Galera Cluster is included in the official MariaDB repositories. Generic Linux binaries can also be downloaded from the MariaDB site. The DEB and YUM packages are available for the officially supported Linux distributions: Debian, Ubuntu, Fedora, Red Hat, and CentOS. It is also possible to compile MariaDB Galera Cluster from sources, if necessary.

The packages that need to be installed are:

  • mariadb-galera-server: The MariaDB Galera Cluster itself
  • galera: The wsrep provider

Some dependencies will probably be installed. If the mariadb-server package is installed, it will be automatically removed.

MariaDB Galera Cluster nodes communicate using non-standard ports. By default, the ports it uses are:

  • 4567
  • 4568
  • 4444
  • 3306 (standard port)

If SELinux or AppArmor is installed, by default they will block all the communication on non-standard ports, preventing the cluster from working. In this case, we will need to add proper SELinux or AppArmor policies, or disable them all. Note that SELinux heavily affects the performance of database servers, so disabling it could be a good idea. SELinux is generally enabled, by default, on distributions derived from Red Hat. AppArmor is enabled by default on Ubuntu.

To disable SELinux, run the following command:

setenforce 0

To disable AppArmor, run the following commands:

cd /etc/apparmor.d/disable/
ln -s /etc/apparmor.d/usr.sbin.mysqld
service apparmor restart

In both cases, we must be a root user.

If iptables, or similar firewall software, is installed, it will probably need to be configured to allow access on non-standard ports.

At this point, we are ready to start our first MariaDB Galera Cluster!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.234.24