Sample Header Ad - 728x90

Switch to master auto position from master_log_file and master_log_pos MySQL 5.7.44

0 votes
1 answer
202 views
MySQL Server - 5.7.44 I have a master and three slaves running on MySQL 5.7.44. The GTID is enabled and I am using gtid_enforce_consistency. I took a backup from a slave and built a fourth slave using xtrabackup. Following is the command I used to backup the data. xtrabackup --defaults-file=/etc/my.cnf --user="bkp_user" --password="password" --port=3306 --socket=/var/lib/mysql/mysql.sock --backup --use-memory=2048MB --tmpdir=/tmp/ after copying the backup to the data directory, I applied the logs xtrabackup --apply-log --use-memory=10G . and then once the logs are applied, after changing the ownership of the files, I started the new slave. I added skip-slave-start in the config file before starting the new slave. I, then, used the following command to connect the slave to the server from where I had taken backup. change master to master_host='IP', MASTER_USER='replica', MASTER_PASSWORD='password', MASTER_AUTO_POSITION=1; I kept receiving the Duplicate entry errors 1062. I skipped one GTID and started the replication, but it kept happening and I kept receiving 1062 error. LAST_ERROR_MESSAGE: Worker 1 failed executing transaction '8e36a7e9-4bb6-11ea-9989-0aab56f5ae8e:4967477654' at master log binlog.000454, end_log_pos 638; Could not execute Write_rows event on table db.table; Duplicate entry '97193728' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log FIRST, end_log_pos 638 LAST_ERROR_TIMESTAMP: 2024-11-22 22:38:18 I had to switch back to BINLOG POSITION based replication. STOP SLAVE; RESET SLAVE ALL; change master to master_host='IP', MASTER_USER='replica', MASTER_PASSWORD='password', MASTER_LOG_FILE='binlog.000454', MASTER_LOG_POS=772253840; And replication is working fine. I am out of thought, what did I miss? Also how do I safely switch back to MASTER_AUTO_POSITION? This link gives a simple procedure to do so, but really not sure and haven't tried it yet https://thedataguy.in/mysql-convert-binlog-based-replication-to-gtid-replication-without-downtime/ This percona blog talks about doing that on MariaDB, reading, searching further https://www.percona.com/blog/convert-mariadb-binary-log-file-and-position-based-replication-to-gtid-replication/
Asked by Avinash Pawar (216 rep)
Dec 1, 2024, 12:03 AM
Last activity: Jul 13, 2025, 01:04 AM