- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Install Galera Load Balancer on This Running MariaDB Galera Cluster
In this activity, you are a DBA working for a large financial company and have been tasked with installing the Galera Load Balancer on a proof of concept MariaDB Galera Cluster.

Lab Info
Table of Contents
-
Challenge
Set the root Database User's Password and Create a Database User Account
-
Run the
mysql_secure_installation
script using the provided lab credentials:sudo mysql_secure_installation
-
Configure the following settings:
- Enter current password for root (enter for none): Enter
- Switch to unix_socket authentication: y
- Change the root password: y
- New password: Any new password
- Remove anonymous users? y
- Disallow root login remotely? y
- Remove test database and access to it? y
- Reload privilege tables now? y
-
Connect to the database as the
root
user and create a user account, using the newly createdroot
password:mysql -u root -p
-
Create a
remote
user, replacing "mypasswd" with a password of your choice:create user remote identified by 'mypasswd';
-
Grant
remote
usage on all objects and allow user to log in from any host:grant usage on *.* to 'remote'@'%' identified by 'mypasswd';
-
Enter
quit
to quit the program.
-
-
Challenge
Install the Prerequisite Packages and Build the Binaries
-
Install the packages for building Galera Load Balancer, using the password provided for
node0
on the lab page:sudo yum -y install git autoconf automake libtool gcc-c++ nmap-ncat
-
Clone the GitHub repository:
git clone https://github.com/codership/glb
-
Move into the
glb
repository:cd glb/
-
Run the Bootstrap script:
./bootstrap.sh
-
Run the configure script:
./configure
-
Create the binaries:
make
-
Install the binaries:
sudo make install
-
-
Challenge
Start Galera Load Balancer
-
Start the GLB manually on the command line:
glbd -v -c 127.0.0.1:4444 10.0.1.100:13306 10.0.1.100:3306:1
-
Open a second terminal window and log in to
node1
using the provided lab credentials:ssh cloud_user@<PUBLIC_IP_ADDRESS>
-
Connect to the cluster on
node1
using the newly createdremote
user login credentials:mysql -u remote -h 10.0.1.100 -P 13306 -p
-
Return to the
node0
terminal and confirm the connection was made.
-
-
Challenge
Add Nodes and Query Stats
-
Open up a new terminal window and log in to
node0
using the provided lab credentials:ssh cloud_user@<PUBLIC_IP_ADDRESS>
-
Add a node using port 4444:
Note: This command must be run on the same node as the load balancer.
echo "10.0.1.110:3306:1" | nc 127.0.0.1 4444
-
Return to the first
node0
terminal (the one running the load balancer) and confirm the second node is running. -
Query for statistics on the control port:
echo "getstat" | nc 127.0.0.1 4444
-
Close the first
node0
terminal window to stop the service.
-
-
Challenge
Configure and Start Galera Load Balancer as a Daemon
-
On
node0
, move into thefiles
directory of the cloned GitHub repository:cd glb/files
-
Copy the Galera Load Balancer shell script file and log in using provided lab credentials:
sudo cp glbd.sh /etc/init.d/glb
-
Copy the configuration file to
/etc/sysconfig/glbd
:sudo cp glbd.cfg /etc/sysconfig/glbd
-
Edit the configuration file:
sudo vim /etc/sysconfig/glbd
-
Uncomment and edit the following file parameters:
- Set the listen address:
LISTEN_ADDR="13306"
- Change the control address:
CONTROL_ADDR="127.0.0.1:4444"
- Set both nodes as default targets:
DEFAULT_TARGETS="10.0.1.100:3306:1 10.0.1.110:3306:1"
- Set the listen address:
-
Hit
:wq!
to save and exit the file. -
Start the service and check its status:
sudo service glb start sudo service glb status
-
Query for load balancer statistics:
sudo service glb getstats
-
Remove nodes:
sudo service glb remove 10.0.1.100:3306
-
Add nodes:
sudo service glb add 10.0.1.100:3306:1
-
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.