{"id":2182,"date":"2011-10-18T21:53:35","date_gmt":"2011-10-18T20:53:35","guid":{"rendered":"https:\/\/supportex.net\/?p=2182"},"modified":"2019-05-10T17:59:08","modified_gmt":"2019-05-10T15:59:08","slug":"dumping-mysql-database-slave-replication-set","status":"publish","type":"post","link":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/","title":{"rendered":"Dumping MySQL database from slave for replication set up"},"content":{"rendered":"<p>Usually to set up MySQL replication it&#8217;s convenient to dump database from current master with <em>&#8211;master-data<\/em> parameter. With this option <em>mysqldump<\/em> includes commented SQL operator which needs to be issued on slave to set up replication:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">CHANGE MASTER TO MASTER_LOG_FILE='mysqld-bin.000008', MASTER_LOG_POS=687808977;<\/code><\/p>\n<p>But sometime it&#8217;s not very good idea to dump database from master server. For instance, you use MyISAM tables and you don&#8217;t want to lock them while dumping. In this case you can dump database from on e of the slaves (of course, if you already have them). That is what you need to do. Stop SQL_THREAD:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">STOP SLAVE SQL_THREAD;<\/code><\/p>\n<p>Check slave status:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">SHOW SLAVE STATUSG;<\/code><\/p>\n<p>Get master binary log coordinates:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">mysql&gt; pager egrep '(Relay_Master_Log_File|Exec_Master_Log_Pos)' ; show slave statusG;\nPAGER set to 'egrep '(Relay_Master_Log_File|Exec_Master_Log_Pos)''\nRelay_Master_Log_File: mysql-bin.000225\nExec_Master_Log_Pos: 632106728\n1 row in set (0.00 sec)\nERROR: No query specified\nmysql&gt;<\/pre>\n<p>Save last output to use it later.<br \/>\nAt thus point we can start slave:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">START SLAVE SQL_THREAD;<\/code><\/p>\n<p>Make sure it&#8217;s working:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">SHOW SLAVE STATUSG;<\/code><\/p>\n<p>After restoring database on new slave change its master to your current one using values above:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000225',MASTER_LOG_POS=632106728;<\/code><\/p>\n<p>First value is Relay_Master_Log_File, and the second one is Exec_Master_Log_Pos.<\/p>\n<p>More information you can get in <em>man mysqldump<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Usually to set up MySQL replication it&#8217;s convenient to dump database from current master with &#8211;master-data parameter. With this option mysqldump includes commented SQL operator which needs to be issued on slave to set up replication: CHANGE MASTER TO MASTER_LOG_FILE=&#8217;mysqld-bin.000008&#8242;, MASTER_LOG_POS=687808977; But sometime it&#8217;s not very good idea to dump database from master server. For&hellip; <\/p>\n<div class=\"readmore-wrapper\"><a href=\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\" class=\"more-link\">Read <\/a><\/div>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[278],"tags":[275,199],"class_list":["post-2182","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-linux","tag-mysql-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Dumping MySQL database from slave for replication set up &#8211; Supportex.NET blog<\/title>\n<meta name=\"description\" content=\"How to dump MySQL database from slave for replication set up\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dumping MySQL database from slave for replication set up &#8211; Supportex.NET blog\" \/>\n<meta property=\"og:description\" content=\"How to dump MySQL database from slave for replication set up\" \/>\n<meta property=\"og:url\" content=\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\" \/>\n<meta property=\"og:site_name\" content=\"Supportex.NET blog\" \/>\n<meta property=\"article:published_time\" content=\"2011-10-18T20:53:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-10T15:59:08+00:00\" \/>\n<meta name=\"author\" content=\"Oleksii Tykhonov\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oleksii Tykhonov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\"},\"author\":{\"name\":\"Oleksii Tykhonov\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"headline\":\"Dumping MySQL database from slave for replication set up\",\"datePublished\":\"2011-10-18T20:53:35+00:00\",\"dateModified\":\"2019-05-10T15:59:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\"},\"wordCount\":173,\"keywords\":[\"linux\",\"mysql\"],\"articleSection\":[\"mysql\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\",\"url\":\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\",\"name\":\"Dumping MySQL database from slave for replication set up &#8211; Supportex.NET blog\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\"},\"datePublished\":\"2011-10-18T20:53:35+00:00\",\"dateModified\":\"2019-05-10T15:59:08+00:00\",\"author\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"description\":\"How to dump MySQL database from slave for replication set up\",\"breadcrumb\":{\"@id\":\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/supportex.net\/blog\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dumping MySQL database from slave for replication set up\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\",\"url\":\"https:\/\/supportex.net\/blog\/en\/\",\"name\":\"Supportex.NET blog\",\"description\":\"Server and network management company\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\",\"name\":\"Oleksii Tykhonov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"caption\":\"Oleksii Tykhonov\"},\"url\":\"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dumping MySQL database from slave for replication set up &#8211; Supportex.NET blog","description":"How to dump MySQL database from slave for replication set up","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/","og_locale":"en_US","og_type":"article","og_title":"Dumping MySQL database from slave for replication set up &#8211; Supportex.NET blog","og_description":"How to dump MySQL database from slave for replication set up","og_url":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/","og_site_name":"Supportex.NET blog","article_published_time":"2011-10-18T20:53:35+00:00","article_modified_time":"2019-05-10T15:59:08+00:00","author":"Oleksii Tykhonov","twitter_misc":{"Written by":"Oleksii Tykhonov","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/#article","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/"},"author":{"name":"Oleksii Tykhonov","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"headline":"Dumping MySQL database from slave for replication set up","datePublished":"2011-10-18T20:53:35+00:00","dateModified":"2019-05-10T15:59:08+00:00","mainEntityOfPage":{"@id":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/"},"wordCount":173,"keywords":["linux","mysql"],"articleSection":["mysql"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/","url":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/","name":"Dumping MySQL database from slave for replication set up &#8211; Supportex.NET blog","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/en\/#website"},"datePublished":"2011-10-18T20:53:35+00:00","dateModified":"2019-05-10T15:59:08+00:00","author":{"@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"description":"How to dump MySQL database from slave for replication set up","breadcrumb":{"@id":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/supportex.net\/blog\/2011\/10\/dumping-mysql-database-slave-replication-set\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/supportex.net\/blog\/en\/"},{"@type":"ListItem","position":2,"name":"Dumping MySQL database from slave for replication set up"}]},{"@type":"WebSite","@id":"https:\/\/supportex.net\/blog\/en\/#website","url":"https:\/\/supportex.net\/blog\/en\/","name":"Supportex.NET blog","description":"Server and network management company","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251","name":"Oleksii Tykhonov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","caption":"Oleksii Tykhonov"},"url":"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/"}]}},"_links":{"self":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/comments?post=2182"}],"version-history":[{"count":2,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2182\/revisions"}],"predecessor-version":[{"id":3174,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2182\/revisions\/3174"}],"wp:attachment":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/media?parent=2182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/categories?post=2182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/tags?post=2182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}