{"id":393,"date":"2013-04-16T18:24:03","date_gmt":"2013-04-16T18:24:03","guid":{"rendered":"http:\/\/vickistan.com\/?p=393"},"modified":"2015-12-03T15:25:06","modified_gmt":"2015-12-03T15:25:06","slug":"resync-mysql-master-slave","status":"publish","type":"post","link":"https:\/\/vickistan.com\/?p=393","title":{"rendered":"ReSync MySQL Master Slave"},"content":{"rendered":"<p>At the master:<\/p>\n<p>RESET MASTER;<br \/>\nFLUSH TABLES WITH READ LOCK;<br \/>\nSHOW MASTER STATUS;<\/p>\n<p>And copy the values of the result of the last command somewhere.<\/p>\n<p>Wihtout closing the connection to the client (because it would release the read lock) issue the command to get a dump of the master:<\/p>\n<p>mysqldump -uroot -p &#8211;all-database &gt; \/a\/path\/mysqldump.sql<\/p>\n<p>Now you can release the lock, even if the dump hasn&#8217;t end. To do it perform the following command in the mysql client:<\/p>\n<p>UNLOCK TABLES;<\/p>\n<p>Now copy the dump file to the slave using scp or your preferred tool.<\/p>\n<p>At the slave:<\/p>\n<p>Open a connection to mysql and type:<\/p>\n<p>STOP SLAVE;<\/p>\n<p>Load master&#8217;s data dump with this console command:<\/p>\n<p>mysql -uroot -p &lt; mysqldump.sql<\/p>\n<p>Sync slave and master logs:<\/p>\n<p>RESET SLAVE;<br \/>\nCHANGE MASTER TO MASTER_LOG_FILE=&#8217;mysql-bin.000001&#8242;, MASTER_LOG_POS=98;<\/p>\n<p>Where the values of the above fields are the ones you got from the folllowing:<\/p>\n<p>zcat dumpfile.sql.gz | head \u221230 | grep -i change<\/p>\n<p>Finally type<\/p>\n<p>START SLAVE;<\/p>\n<p>And to check that everything is working again, if you type<\/p>\n<p>SHOW SLAVE STATUS;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the master: RESET MASTER; FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS; And copy the values of the result of the last command somewhere. Wihtout closing the connection to the client (because it would release the read lock) issue &hellip; <a href=\"https:\/\/vickistan.com\/?p=393\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,8],"tags":[],"class_list":["post-393","post","type-post","status-publish","format-standard","hentry","category-linux","category-mysql"],"_links":{"self":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=393"}],"version-history":[{"count":3,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/393\/revisions"}],"predecessor-version":[{"id":536,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/393\/revisions\/536"}],"wp:attachment":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}