MariaDB - replica update

Updating the primary/master host address on a MariaDB replication server involves several steps on both the master and replica servers. Below is an improved and expanded guide with detailed comments to help you understand and execute the process effectively. 1) On master/primary host: ```sql FLUSH TABLES WITH READ LOCK; ``` > This command locks all tables on the master server, preventing any write operations during the update process. This ensures data consistency between the master and replica. Keep the tables locked only for the duration necessary to minimize downtime. ```sql SHOW MASTER STATUS; +--------------------+----------+----------------------------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +--------------------+----------+----------------------------------+------------------+ | master-bin.000119 | 343 | ghost,gitea,semaphore,photoprism | | +--------------------+----------+----------------------------------+------------------+ ``` > The SHOW MASTER STATUS command displays the current binary log file and position, which are essential for configuring the replica. Note down the values of File and Position as they will be used to update the replica's configuration. 2) On replica host: ```sql SHOW SLAVE STATUS; +----------------------------------+-------------+-------------------+---------------------+------------------+-------------------+ | Slave_IO_State | Master_Host | Master_Log_File | Read_Master_Log_Pos | Slave_IO_Running | Slave_SQL_Running | +----------------------------------+-------------+-------------------+---------------------+------------------+-------------------+ | Waiting for master to send event | mariadb | master-bin.000119 | 343 | Yes | Yes | +----------------------------------+-------------+-------------------+---------------------+------------------+-------------------+ STOP SLAVE; CHANGE MASTER TO MASTER_HOST='mariadb', MASTER_USER='replication', MASTER_PASSWORD='******************', MASTER_PORT=3306, MASTER_LOG_FILE='master-bin.000119', MASTER_LOG_POS=343, MASTER_CONNECT_RETRY=60; CHANGE MASTER TO MASTER_USE_GTID = no; START SLAVE; SHOW SLAVE STATUS; +----------------------------------+-------------+-------------------+---------------------+------------------+-------------------+ | Slave_IO_State | Master_Host | Master_Log_File | Read_Master_Log_Pos | Slave_IO_Running | Slave_SQL_Running | +----------------------------------+-------------+-------------------+---------------------+------------------+-------------------+ | Waiting for master to send event | mariadb | master-bin.000119 | 343 | Yes | Yes | +----------------------------------+-------------+-------------------+---------------------+------------------+-------------------+ ``` Master host ```sql UNLOCK TABLES; ```