{"id":1988,"date":"2014-12-31T12:06:09","date_gmt":"2014-12-31T12:06:09","guid":{"rendered":"http:\/\/kedar.nitty-witty.com\/?p=1988"},"modified":"2015-02-26T13:57:06","modified_gmt":"2015-02-26T13:57:06","slug":"mariadb-slave-restore-using-gtid-xtrabackup-bug","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/mariadb-slave-restore-using-gtid-xtrabackup-bug","title":{"rendered":"MariaDB slave restore using GTID &#038; xtrabackup bug"},"content":{"rendered":"<p>Recently I happen to work for a MySQL database restore, a pretty exciting task for DBA \ud83d\ude1b<\/p>\n<p>Well, backup server was already configured with Holland (backup framework) &amp; Xtrabackup (Percona&#8217;s backup tool) which made our lives easier with steps to restore.<\/p>\n<p>Extracted backup command from backup server&#8217;s holland.log:<\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">\/usr\/bin\/innobackupex-1.5.1 --defaults-file=\/mysql_backups\/xtrabackup\/20141219_013002\/my.cnf --stream=tar --tmpdir=\/mysql_backups\/xtrabackup\/20141219_013002 --slave-info --no-timestamp \/mysql_backups\/xtrabackup\/20141219_013002 &gt; \/mysql_backups\/xtrabackup\/20141219_013002\/backup.tar.gz 2 &gt; \/mysql_backups\/xtrabackup\/20141219_013002\/xtrabackup.log<\/pre>\n<\/blockquote>\n<p><!--more Continue Reading...--><br \/>\nThe task here is as simple as:<br \/>\n&#8211; Ship &amp; extract the backup to destination,<br \/>\n&#8211; Apply-logs (innobackupex &#8211;defaults-file=\/path\/my.cnf &#8211;apply-log \/path\/datadir\/)<br \/>\n&#8211; Start database (\/etc\/init.d\/mysqld start),<br \/>\n&#8211; Setup replication (CHANGE MASTER TO) .<\/p>\n<p>MySQL cameup clean after following all the steps and now it&#8217;s time to setup replication.<\/p>\n<p>The option &#8211;slave-info to innobackupex script stores master&#8217;s binlog coordinates in a file, xtrabackup_slave_info, which can be used to setup the new server as slave.<\/p>\n<p>The co-ordinates can also be found in the xtrabackup log shown as follows:<\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\"><em>innobackupex-1.5.1: Backup created in directory '\/mysql_backups\/xtrabackup\/20141219_013002'\r\ninnobackupex-1.5.1: MySQL binlog position: filename 'mysql-bin.002573', position 53014559, GTID of the last change '0-10110111-42499073'\r\ninnobackupex-1.5.1: MySQL slave binlog position: master host '10.1.101.11', gtid_slave_pos 0-10110111-42499073\r\n141219 04:55:16\u00a0 innobackupex-1.5.1: Connection to database server closed\r\ninnobackupex-1.5.1: You must use -i (--ignore-zeros) option for extraction of the tar stream.\r\n141219 04:55:16\u00a0 innobackupex-1.5.1: completed OK!<\/em><\/pre>\n<\/blockquote>\n<p>I noted that the backup xtrabackup_slave_info file binlog co-ordinate did not match that of master!! And we found that the binlog co-ordinates we had were of slave itself (show master status) and not of master (relay_Master_Log_File &amp; exec_master_pos). This appears a <a href=\"https:\/\/bugs.launchpad.net\/bugs\/1404484\" target=\"_blank\" rel=\"nofollow\">bug in xtrabackup<\/a>.<\/p>\n<p>Luckily the xtrabackup log did note the GTID positions and that helped to restore the slave as follows.<\/p>\n<p>Verified the present gtid_slave_pos matches that of log and started slave. (Check the References for MariaDB documentation page about restoring slave)<\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">MariaDB [(none)]&gt; show global variables like 'gtid_slave_pos';\r\n+----------------+---------------------+\r\n| Variable_name| Value |\r\n+----------------+---------------------+\r\n| gtid_slave_pos | 0-10110111-42499073 |\r\n+----------------+---------------------+\r\n1 row in set (0.00 sec)\r\n\r\nMariaDB [(none)]&gt; show global variables like 'gtid_current_pos';\r\n+------------------+---------------------+\r\n| Variable_name| Value |\r\n+------------------+---------------------+\r\n| gtid_current_pos | 0-10110111-42499073 |\r\n+------------------+---------------------+\r\n\r\nMariaDB [(none)]&gt;CHANGE MASTER TO master_use_gtid=current_pos; START SLAVE;<\/pre>\n<\/blockquote>\n<p>We&#8217;ll look forward to the bug fix to that reports correct (master&#8217;s) binary log positions in xtrabackup_slave_info file.<\/p>\n<p><b>References:<\/b><\/p>\n<ul>\n<li>https:\/\/bugs.launchpad.net\/bugs\/1404484<\/li>\n<li>https:\/\/mariadb.com\/kb\/en\/mariadb\/documentation\/replication\/standard-replication\/global-transaction-id\/#setting-up-from-backup<\/li>\n<li>http:\/\/www.percona.com\/doc\/percona-xtrabackup\/2.2\/innobackupex\/innobackupex_option_reference.html#cmdoption-innobackupex&#8211;slave-info<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"Restoring MariaDB (MySQL) slave using Xtrabackup &#038; GTID.\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8,377],"tags":[370,380,379,427,369],"class_list":{"0":"post-1988","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-mysql","7":"category-mysql-articles","8":"tag-bug","9":"tag-gtid-replication","10":"tag-mariadb","11":"tag-mysql","12":"tag-xtrabackup"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/1988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/comments?post=1988"}],"version-history":[{"count":5,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/1988\/revisions"}],"predecessor-version":[{"id":2045,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/1988\/revisions\/2045"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=1988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=1988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=1988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}