- Lab
- A Cloud Guru
Implement a Disaster Recovery Cluster Using MariaDB Galera Cluster and Galera Load Balancer
In this activity, you are working as a DBA and have been tasked with setting up a MariaDB Galera Cluster in a Disaster Recovery configuration. A POC (proof of concept) cluster has been started for you to configure. You will need to install the Galera Load Balancer and configure it appropriately.
Path Info
Table of Contents
-
Challenge
Set the root Database User's Password and Create a Database User Account
The database nodes are running and connected to the cluster, however the
root
user's password has not been set. You must first set theroot
user's password by running themysql_secure_installation
script:sudo mysql_secure_installation
Now you can connect to the database as the
root
user and create a user account:mysql -u root -p
Once connected, you can use the following SQL to create a user named
remote
who is able to log in remotely. Be sure to replace mypasswd with a password of your choice:create user remote identified by 'mypasswd'; grant usage on *.* to 'remote'@'%' identified by 'mypasswd';
-
Challenge
Install the Prerequisite Packages
sudo yum -y install git autoconf automake libtool gcc-c++ nmap-ncat
-
Challenge
Build the Binaries
git clone https://github.com/codership/glb cd glb ./bootstrap.sh ./configure make sudo make install
-
Challenge
Configure and Start Galera Load Balancer
The primary node will have a weight of 10. Adding the DR site with a lower weight provides automatic failover should the primary node fail.
Using the--single
option causes all connections to go to a single server with the highest weight of those available:sudo cp /home/cloud_user/glb/files/mysql.sh /usr/local/bin/mysql-check.sh sudo cp /home/cloud_user/glb/files/glbd.sh /etc/init.d/glb
sudo vim /etc/sysconfig/glbd # Address to listen for client connections at. Mandatory parameter. # To bind to all interfaces only port should be specified. LISTEN_ADDR="10.0.1.100:13306" # Address for controlling connection. Mandatory part is port. # If not specified control socket will not be opened CONTROL_ADDR="127.0.0.1:4444" # Target servers for client connections, space separated. # Target specification: IP[:PORT[:WEIGHT]] (WEIGHT and PORT optional) # WEIGHT defaults to 1, PORT defaults to LISTEN_ADDR port. DEFAULT_TARGETS="10.0.1.100:3306:10 10.0.1.110:3306:1" # Other glbd options if any as they would appear on the command line. OTHER_OPTIONS="--single --watchdog exec:'/usr/local/bin/mysql-check.sh -uremote -pmypasswd'"
Start the service:
sudo service glb start sudo service glb status
-
Challenge
Confirm Connections to Primary
Connect to the load balancer:
mysql -h 10.0.1.100 -P 13306 -u remote -p
The connection is sent to the single server with the highest weight of those available, in this case
node0
:sudo service glb status
-
Challenge
Failover to DR Site
A manual failover can be triggered by changing the weight of the node:
service glb add 10.0.1.100:3306:1 service glb add 10.0.1.110:3306:10
A failure of
node1
can be simulated by stopping themariadb
service:sudo systemctl stop mariadb.service
Connections will now be routed to the DR site automatically.
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.