# backup to mariadb-bkp directory
mkdir mariadb-bkp && cd mariadb-bkp
mariadb-backup --backup --target-dir=.
# prepare a backup for restore
mariadb-backup --prepare --target-dir=.
# restore a backup
systemctl stop mariadb
rm -rf /var/lib/mysql/*
mariadb-backup --move-back --target-dir=. --datadir=/var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
systemctl start mysql
The GTID can be found in the xtrabackup_binlog_info
file. E.g. mariadb-bin.000002 54000173 0-92-441693
. You would then use the 0-92-441693
GTID as the MASTER_GTID.
set global gtid_slave_pos='MASTER_GTID';
change master to master_host='MASTER_IP', master_user='maxscale_monitor', master_password='DB_PASSWORD', master_port=3307, master_use_gtid=slave_pos;
start slave;
show slave status\G;
mysql -u admin -p
> stop slave;
> CHANGE MASTER TO MASTER_HOST='<new master>'
> start slave;
> show slave status\G;
maxctrl -u user --password='password'
> list monitors
> list servers
> call command mariadbmon switchover <monitor name> <new_master> <old_master>