Installing MariaDB, Creating a Cluster, and Database Redundancy - jwells24/Tech-Journal GitHub Wiki
Installing MariaDB, Creating a Cluster, and Database Redundancy
- In this tech journal, we will be getting MariaDB installed on our three database servers. Then, we will cluster them together and create a virtual IP for redundancy.
Installing MariaDB & Setting Up the cluster
-
For U1, U2, and U3 (Our three Ubuntu Database servers), log into the box and change the password for champuser. Also, using netplan, get the three boxes connected to the internet.
-
Now, let's install MariaDB. Use the commands below to do this on each database server. For our purposes, answer no to the first four prompts from the final command, and yes to the last two.
sudo apt update
sudo apt install mariadb-server
sudo systemctl start mariadb.service
sudo mysql_secure_installation
- Now, let's configure our cluster file with galera. Access your the galera configuration file with the command below, and make sure to change the configuration file for each node to look like the file image below.
sudo vi /etc/mysql/mariadb.conf.d/60-galera.conf
- Now, let's open up our firewall so our nodes can communicate. Use the commands below to do so on each node. Make sure to allow in each node and the node itself in the firewall.
sudo ufw enable
sudo ufw allow in from 10.0.5.201
sudo ufw allow in from 10.0.5.202
sudo ufw allow in from 10.0.5.203
- Now, on our first node db1, let's create the cluster using the commands below.
sudo systemctl stop mariadb
sudo galera_new_cluster
Now that the new cluster has been created, on the other nodes restart mariadb with the command below.
sudo systemctl restart mariadb
Check if the nodes and cluster are successfully created by logging into mariadb and checking the cluster size with the commands below.
mysql -u root -p
show status like 'wsrep_cluster_size';
Database Redundancy
- For redundancy between our database servers, I am using keepalived. Here is a link to the tech journal entry which I used to setup keepalived for my database servers: keepalived