MariaDB Minor Patch Upgrade [ 10.4.10 to 10.4.21 ] with HA Topology

MariaDB Minor Patch Upgrade [ 10.4.10 to 10.4.21 ] with HA Topology 


x

This blog will be explain about , how to apply the Minor patch of MariaDB Version  [ For eg : from 10.4.10 to 10.4.21 ] with HA Topology. [ If it is Tarball Installation ]

Let us assume ,  We have Environment like this , 2 MariaDB Servers with GTID Replication running [ Main and Replica ] along with MaxScale 2 Servers  [ Active and Passive MaxScale Servers ] and keepalived is enabled .


High level steps

Details Explanation with commands for above steps

Rollback steps From 10.4.21 to 10.4.10

 High level steps

Patch Upgrade of MariaDB servers

Step - 1 :- Check the status of " maxctrl list servers " command in Both Active and Passive MaxScale servers [ Maintenance mode ]

Step - 2 :- In this step all Application are connected to Main server

Step - 3 :- Perform the MariaDB version 10.4.10 to 10.4.21 in Current Replica Server of MariaDB

Step - 4 :- Now clear the maintenance mode for replica [ Server 2 ] from Active MaxScale Node

Step - 5 :- Now promote the New version of MariaDB server to main and Old main to replica by using MaxScale commands [ Switch Over ]

Step - 6 :- Now follow the same steps in Step - 3 for  New replica [ i.e. Old Main MariaDB server ]

Step - 7 :- Now again Promote the Old Main status [ I.e. Original Status ] Before upgrading 


Details Explanation with commands for above steps

#####################################################################

Step - 1 :- Check the status of "maxctrl list servers " command in Both Active and Passive Maxscale servers  [ Maintenance mode 

#####################################################################

Note :- Better to add slave as a "maintenance mode" before starting the upgrade. It will prevent to route Application connections on replica.

Based on " maxctrl list servers " command output , we can set slave to Maintenance Mode by using below commands.

maxctrl set server server2[replica server should be] maintenance   [ In this command if we see Main DB as Server1 and replica as Server2 ]

maxctrl set server server1[replica server should be] maintenance   [ In this command if we see Main DB as Server2 and replica as Server1 ]

Run again "maxctrl list servers" Command and see the status of Slave [ Server 2 / Server 1 ]


#####################################################################

Step - 2 :- In this step all Application are connected to Main server

#####################################################################

 

#####################################################################

Step - 3 :- Perform the MariaDB version 10.4.10 to 10.4.21 in Current Replica Server of MariaDB

#####################################################################

If your using a tarball installaion, we can decompress the 10.4 tarball just like in the installation instructions per:

https://mariadb.com/kb/en/installing-mariadb-binary tarballs/#installing-mariadb-as-root-in-usrlocalmysql

--> Connect to the Replica MariaDB server , and perform the patch apply .

--> Download the S/w from the below link and keep it in /usr/local folder

wget https://downloads.mariadb.com/MariaDB/mariadb-10.4.21/bintar-linux-x86_64/mariadb-10.4.21-linux-x86_64.tar.gz

--> Extract the new Version of MariaDB Version by using below command

                cd /usr/local
                tar -zxvpf mariadb-10.4.21-linux-x86_64.tar.gz

The next two steps are to change the symbolic link of the mysql pointer.

So at this point you have the 10.4.10 and 10.4.21 version in /usr/local. We are not going to run mysql_install_db because the data already exists.

Once you are ready to perform the upgrade you will need to perform these steps:

(i)   shut down the 10.4.10 DB service in replica server.

(ii)  change the symbolic link (ln -s mariadb-VERSION-OS mysql) like in the page from earlier.

(iii) Start up the 10.4.21 server.

(iv)  run mysql_upgrade per: https://mariadb.com/kb/en/mysql_upgrade/

Implementation Steps:-

(i) Once extract is done , stop the Replica MariaDB by using below commands .

             MariaDB > show replica status\G
             MariaDB > stop replica;
             MariaDB > show replica status\G

--> Stop the Replica of MariaDB service .
             service mysql status
             ps -ef | grep -i mysql
             service mysql stop
             service mysql status
             ps -ef | grep -i mysql
 
#####################################################################
Step - 4 :- Now clear the maintenance mode for Slave [ Server 2 ] from Active MaxScale Node
#####################################################################
 

--> Connect to the Active MaxScale Node , and run the below command to clear the Maintenance Mode for replica [ Server 2 ]

maxctrl clear server server2 maintenance  [ This command for if server2 running as a replica  ]

maxctrl clear server server1 maintenance  [ This command for if server1 running as a replica  ]

  

#####################################################################
Step - 5 :- Now promote the New version of MariaDB server to Master and Old Master to Slave by using MaxScale commands
#####################################################################

Note :- In order to do Step - 5 , We should check the status of replica for second_behine_master = 0 , Until we get 0 value , then perform the below steps.

 --> Connect to the Active MaxScale Server , and run the below commands to check which server is acting as a Main .

 
                      maxctrl list servers
 
If we see Main is Server1 and replica is Server2 , then run the below command to switchover Process between MariaDB servers.
 
#: What Maxscale logs says, default location /var/log/maxscale/maxscale.log
 
                 tail -f /var/log/maxscale/maxscale.log
#: switchover process
#: listing servers and current status

maxctrl list servers
------------+-----------------+-------+-------------+----------------
Server      | Address         | Port  | Connections | Status
------------+-----------------+-------+-------------+----------------
server1     | 10.xx.xx.12     |  3306 |      0      | Master, Running
server2     | 10.xx.xx.13     |  3306 |      0      | Slave, Running
------------+-----------------+-------+-------------+----------------

#: command to make the current slave a new master

maxctrl call command mariadbmon switchover TheMonitor server2 server1 [ If above command output belongs to Main is server1 and Replica is server2 ]

maxctrl call command mariadbmon switchover TheMonitor server1 server2 [ If above command output belongs to Main is server2 and Replica is server1 ]
#: listing servers again
maxctrl list servers
------------+-----------------+-------+-------------+----------------
Server      | Address         | Port  | Connections | Status
------------+-----------------+-------+-------------+----------------
server1     | 10.xx.xx.12     |  3306 |      0      | Slave, Running
server2     | 10.xx.xx.13     |  3306 |      0      | Master, Running
------------+-----------------+-------+-------------+----------------

Setting a replica MariaDB database server in maintenance is simple and easy. Simply do the following command using maxctrl and MaxScale will stop sending any queries to this server. For example,

 

maxctrl set server server1 maintenance    [ If server1 is Replica ]
maxctrl set server server2 maintenance    [ If server2 is Replica ]
 
                        maxctrl list servers
 
Now we can see server1 [ Old Master ] become a Maintenance Mode ...


#####################################################################Step - 6 :- Now follow the same steps in Step - 3 for  New replica [ i.e. Old Main MariaDB server ]
#####################################################################
 
If your using a tarball installation, you can decompress the 10.4 tarball just like in the installation instructions per:

https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/#installing-mariadb-as-root-in-usrlocalmysql
 
--> Connect to the New Replica [ Old Master ] MariaDB server , and perform the patch apply .
 
--> Download the S/w from the below link and keep it in /usr/local folder
 
wget https://downloads.mariadb.com/MariaDB/mariadb-10.4.21/bintar-linux-x86_64/mariadb-10.4.21-linux-x86_64.tar.gz

--> Extract the new Version of MariaDB Version by using below command

               cd /usr/local
               tar -zxvpf mariadb-10.4.21-linux-x86_64.tar.gz

The next steps are to change the symbolic link of the mysql pointer.

So at this point you have the 10.4.10 and 10.4.21 version in /usr/local. We are not going to run mysql_install_db because the data already exists.

Once you are ready to perform the upgrade you will need to perform these steps:

(i)   shut down the 10.4.10 server.
(ii)  change the symbolic link (ln -s mariadb-VERSION-OS mysql) like 
      in the page from earlier.
(iii) Start up the 10.4.21 server.
(iv)  run mysql_upgrade per: https://mariadb.com/kb/en/mysql_upgrade/

Implementation Steps (i) Once extract is done , stop the New slave [ Old Master ] MariaDB by using below commands.

                    MariaDB > show replica status\G
                    MariaDB > stop replica;
                    MariaDB > show replica status\G
 
--> Stop the New Replica [ Old Master ] of MariaDB service .
 
                    service mysql status
                    ps -ef | grep -i mysql
                    service mysql stop
                    service mysql status
                    ps -ef | grep -i mysql
 
#####################################################################
Step - 7 :- Now again Promote the Old Master status [ I.e Original Status ] Before upgrading
#####################################################################

--> Connect to the Active Maxscale Server , and run the below commands to check which server is acting as a Master .
 
                    maxctrl list servers
                    maxctrl clear server server1 maintenance  [ This command for if server1 running as a replica  ]
                    maxctrl clear server server2 maintenance  [ This command for if server2 running as a replica  ] 
 
If we see Main is Server2 and replica is Server1 , then run the below command to switchover Process between MariaDB servers.

 

#: what MaxScale logs says, default location /var/log/maxscale/maxscale.log
 
tail -f /var/log/maxscale/maxscale.log
 
#: switchover process
#: listing servers and current status
maxctrl list servers
------------+-----------------+-------+-------------+----------------
Server      | Address         | Port  | Connections | Status
------------+-----------------+-------+-------------+----------------
server1     | 10.xx.xx.12     |  3306 |      0      | Slave, Running
server2     | 10.xx.xx.13     |  3306 |      0      | Master, Running
------------+-----------------+-------+-------------+----------------
 

#: command to make the current slave a new master

maxctrl call command mariadbmon switchover TheMonitor server1 server2 [ If above command output belongs to Main is server2 and Replica is server1 ]

maxctrl call command mariadbmon switchover TheMonitor server2 server1 [ If above command output belongs to Main is server1 and Replica is server2 ]

 

#: listing servers again
maxctrl list servers
------------+-----------------+-------+-------------+----------------
Server      | Address         | Port  | Connections | Status
------------+-----------------+-------+-------------+----------------
server1     | 10.xx.xx.12     |  3306 |      0      | Master, Running
server2     | 10.xx.xx.13     |  3306 |      0      | Slave, Running
------------+-----------------+-------+-------------+----------------

Rollback steps From 10.4.21 to 10.4.10


We need to  installation freshly  and restore the old backup and not the new backup from higher version

                                       No rollback from higher to lower version


Thank you for visiting my blog..


Comments

Post a Comment

Popular posts from this blog

PostgreSQL Database Version 13.4 To MySQL Database Version 8.0.20 Migration by using SQLines Tool

RDS MySQL / MariaDB SSL Connection by using Workbench and command line

Install Mydumper and Myloader Software for Backup of MySQL / MariaDB Databases and Usage of commands