This is the cluster setup:
------ ------ | m1 | --- | m2 | ------ ------ || || ------ ------ | s1 | | s2 | ------ ------
m2 are in a Galera Cluster, and replication between these nodes works fine. There is also an arbitrator node running on a separate server.
s1 is a slave node to
s2 is a slave node to
m2. The replication to slave nodes is using classic MySQL replication.
Now, the issue here is that the slave nodes needed to be started from fresh state. This was the process to start the replication:
service mysql stopon slave node.
/var/lib/mysqlon slave node.
innobackupex -u user -p passwordon master node.
innobackupex -u user -p password --apply-log /path/to/backupon the master node.
- Copy database backup files to slave server.
innobackupex --copy-back /path/to/backupon slave server.
chown -r mysql.mysql /var/lib/mysql/*on slave server to fix permissions.
service mysql starton slave server.
After this, I started
mysql -u root -p password, and issued this command:
STOP SLAVE; CHANGE MASTER TO MASTER_HOST='m1', MASTER_USER='repl', MASTER_PASSWORD='password', MASTER_LOG_FILE='mariadb-bin.NNNNNN', MASTER_LOG_POS=nnn; START SLAVE;
nnn were retrieved from
xtrabackup_binlog_info file from the backup files.
Now, this process worked perfectly between
s1. However, with
s2, it generates an error message (I split the error message to multiple lines for better readability):
Could not execute Write_rows_v1 event on table db.table; Cannot add or update a child row: a foreign key constraint fails (`db`.`table`, CONSTRAINT `FK3EBA76781F6AACF1` FOREIGN KEY (`job`) REFERENCES `table2` (`id`)), Error_code: 1452; handler error HA_ERR_NO_REFERENCED_ROW; the event's master log mariadb-bin.000710, end_log_pos 1523526
I have tried to repeat the process again a couple of times without any success.
I have also issued
RESET MASTER on
m2 to reset the replication log file in case it had some corruption.
I am running out of ideas what is happening here and how I can restart replication correctly. Any ideas?