Training Video Exercises¶
Installing Galera Cluster with MariaDB¶
These exercises are part of the training video, Installing Galera Cluster with MariaDB. They correspond to what was taught, and should be done after each viewing section, unless otherwise noted.
Before starting these exercises, make sure you have all of the requirements and preparations in place.
Requirements & Preparation
- Test Servers: 3
- Operating System: Linux
- Software: Don’t install MariaDB or Galera Cluster in preparation.
Student Materials
Before starting an exercise, read it fully and carefully. The headings for each set of exercises corresponds to the section with the same name in training video. Make notes for yourself as you go along, for when you have to do these tasks for your job or for yourself.
Installing Software on Nodes
Do these exercises after viewing the first two sections of the training video: Galera Cluster Overview, and Installing Software on Nodes. Don’t configure the nodes until the next section.
- Use a web browser to go to The MariaDB Foundation’s web site (see link in margin) to use their repository generator to get the contents of a repository file for the latest version of MariaDB—at least version 10.4, which includes Galera Cluster. Use a text editor to create a repository file on each node, using the repo file contents from The Foundation site.
- Install MariaDB on each node. When finished, start
mysqld
on each—don’t bootstrap Galera. Then runmysql_secure_install
on each to set the root password—initially, there is no root password—as well as respond to the other questions the script asks. Then try logging into MariaDB with themysql
client as root with the new password. Exit and shutdownmysqld
.
Configuring Nodes & Opening Ports
Do these exercises after viewing the section with the two titles. MariaDB should be down on each node; don’t start mysqld
again until the next section.
- Edit the MariaDB configuration file to include settings needed for Galera Cluster. There’s a link in the Student Materials section at the top, for an example configuration file. Don’t start
mysqld
yet. Configure each node before proceeding to the next exercise. - Configure either SELinux or Firewalld or both to open the following ports: TCP 22, TCP 3306. TCP 4444, TCP and UDP 4567, and TCP 4568. If you intent to use only SELinux or only Firewalld, disable the one not used.
Starting Galera
This is the core of the training video. You may encounter problems as you do these exercises. Don’t let it frustrate you. It’s important. So don’t stop trying until you’re able to do them.
- Choose a node to be the seed node—anyone will be fine. Start MariaDB and Galera on it by using the
galera_new_cluster
script. If there are any errors, shutdownmysqld
and read the full error messages, as well as look through the MariaDB log for clues. Resolve any problems and keep trying until you get it started. ExecuteSHOW STATUS
with theLIKE
operator to see if Galera is running. - Once you have the first node running MariaDB and Galera, start mysqld on one of the other nodes—don’t use
galera_new_cluster
. If there are any errors, shutdown mysqld on the node and resolve the problems until you get it started. When it’s working properly,wsrep_cluster_size
status variable should have a value of 2. - Download the dump file containing the company database (see link at the top under Student Materials) onto the first node. Since it was made with
mysqldump
, use themysql
client to load the data. When it’s finished, check the second node to see if it replicated the data. - Start
mysqld
on the third node. After it has successfully joined the cluster, look to see if it has replicated the company database. Enter theCREATE DATABASE
statement to create a database without tables. Check that the other nodes replicated it. - Shut down all of the nodes and restart them, using
galera_new_cluster
to start only the first node, which should be the last one that was shutdown. If you have problems, check thegrastate.dat
file in the data directory to ensure thesafe_to_bootstrap
parameter is set to 1.
Note
If you struggled at any point in doing these exercises, especially in getting the Galera nodes started, you might want to do them again. Start with fresh installations of the servers, without MariaDB or Galera Cluster. If you use the same servers, before doing the exercises again, uninstall MariaDB and Galera, and delete MariaDB’s data directory. Do the exercises multiple times, until you’re able to install, configure, and start a Galera cluster without any problems.
Related Documents
- Firewall Settings
- firewalld
- Installing Galera
- Node Provisioning
- SELinux
- State Transfer
- wsrep Options
Other Resources