Note this is for Primary and Replica setups that are not running “Global Transaction IDs”
Run the following using sudo or root.
On The Primary Server:
FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS;
You will get an output that looks like below, please note the values shown here are examples only.
+--------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +--------------------+----------+--------------+------------------+ | master1-bin.000003 | 568 | | | +--------------------+----------+--------------+------------------+
On The Replica Server:
SHOW SLAVE STATUS\G;
You will get an output that looks like below showing the interesting parts only as the output is quite long.
Master_Log_File : master1-bin.000003 Read_Master_Log_Pos: 503 Relay_Log_Pos : 503 Replicate_Do_DB : database1,database2 Exec_Master_Log_Pos: 503
Important: Keep refreshing until the Replica matches the position of the Primary server, once they match you can take down the Primary server.
On The Primary Server:
shutdown now
Note: Consider changing the ip address on the new Primary making it easier to get up running fast.
On The Replica Server:
In MariaDB stop the old replication.
STOP ALL SLAVES; RESET SLAVE ALL; SHOW MASTER STATUS;
Imortant: If you have other “Replicas” or you are going to add new “Replicas” that needs to connect to the now “Promoted and new Primary” follow the instructions [Here]
Note: “New_Primary_Ip_Address” could be the Ip address of the old Primary actually it does not have to be an Ip address but could be a domain.
Notes on MySQL: The above should also work on MySQL except for the option “log-basename” which MySQL does not support.