{"id":2091,"date":"2011-09-26T22:19:54","date_gmt":"2011-09-26T22:19:54","guid":{"rendered":"https:\/\/supportex.net\/?p=2091"},"modified":"2019-05-10T18:12:47","modified_gmt":"2019-05-10T16:12:47","slug":"mysql-checking-replication-consistency-mk-table-checksum","status":"publish","type":"post","link":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/","title":{"rendered":"MySQL: checking replication with mk-table-checksum"},"content":{"rendered":"<p>Here is a simple way to check if your database on master and slave server have the same data. We will use <em>mk-table-checksum<\/em> from <a href=\"http:\/\/www.maatkit.org\/\">maatkit<\/a> tools for this purpose.<\/p>\n<p><strong>Note! Never do it on the production server! Or use it on your own risk! <a href=\"http:\/\/www.maatkit.org\/doc\/mk-table-checksum.html\">As stated<\/a>:<\/strong><\/p>\n<blockquote><p>mk-table-checksum executes queries that cause the MySQL server to checksum its data. This can cause significant server load. It is read-only unless you use the &#8211;replicate option, in which case it inserts a small amount of data into the specified table.<\/p><\/blockquote>\n<p>This trick works only for statement-based replication and with big databases can lead to significant overhead. To install <em>mk-table-checksum <\/em>run:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">wget http:\/\/www.maatkit.org\/trunk\/mk-table-checksum\nchmod u+x .\/mk-table-checksum<\/pre>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">.\/mk-table-checksum -uroot -pstong_password --create-replicate --replicate YOUR_DB.checksums --ignore-databases information_schema,mysql --replicate-database=YOUR_DB --empty-replicate-table --chunk-size=1M nocheck-replication-filters master.example.com<\/code><\/p>\n<p>This commands will execute <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/checksum-table.html\">CHECKSUM TABLE<\/a> statement on all tables and will create table YOUR_DB.checksums to store sums. Due to the replication the same statements will be processed on the slave and it will calculate its own versions of checksums. After that <em>mk-table-checksum<\/em> can perform some query which will be used to define if databases are the same. More information on that can be found at <a href=\"http:\/\/www.maatkit.org\/doc\/mk-table-checksum.html#consistent_checksums\">maatkit documentation<\/a>.<\/p>\n<p>Now we are ready to do last check (at this time\u00a0&#8216;&#8211;replicate-check 1&#8217; are being used) :<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">.\/mk-table-checksum -uroot -pstrong_password --create-replicate --replicate YOUR_DB.checksums --ignore-databases information_schema,mysql --replicate-database=YOUR_DB --empty-replicate-table --chunk-size=1M --nocheck-replication-filters --replicate-check 1 \u00a0master.example.com<\/code><\/p>\n<p>If there&#8217;s no output it means there&#8217;s no differences between the master and slave.<\/p>\n<p>One more thing. If master performs write operations during checksumming, you can get incorrect result so you might need to consider -lock option. And once again, you really don&#8217;t want to do all of these actions on live server.<\/p>\n<p><strong>Didn&#8217;t find the answer to your question? <a href=\"\/contacts\/\">Ask it<\/a> our administrators to reply we will publish on website.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a simple way to check if your database on master and slave server have the same data. We will use mk-table-checksum from maatkit tools for this purpose. Note! Never do it on the production server! Or use it on your own risk! As stated: mk-table-checksum executes queries that cause the MySQL server to&hellip; <\/p>\n<div class=\"readmore-wrapper\"><a href=\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\" class=\"more-link\">Read <\/a><\/div>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[278],"tags":[199,196],"class_list":["post-2091","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql-en","tag-percona"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL: checking replication with mk-table-checksum &#8211; Supportex.NET blog<\/title>\n<meta name=\"description\" content=\"How to check replication with mk-table-checksum Percona tool\" \/>\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\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL: checking replication with mk-table-checksum &#8211; Supportex.NET blog\" \/>\n<meta property=\"og:description\" content=\"How to check replication with mk-table-checksum Percona tool\" \/>\n<meta property=\"og:url\" content=\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\" \/>\n<meta property=\"og:site_name\" content=\"Supportex.NET blog\" \/>\n<meta property=\"article:published_time\" content=\"2011-09-26T22:19:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-10T16:12:47+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\"},\"author\":{\"name\":\"Oleksii Tykhonov\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"headline\":\"MySQL: checking replication with mk-table-checksum\",\"datePublished\":\"2011-09-26T22:19:54+00:00\",\"dateModified\":\"2019-05-10T16:12:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\"},\"wordCount\":272,\"commentCount\":0,\"keywords\":[\"mysql\",\"percona\"],\"articleSection\":[\"mysql\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\",\"url\":\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\",\"name\":\"MySQL: checking replication with mk-table-checksum &#8211; Supportex.NET blog\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\"},\"datePublished\":\"2011-09-26T22:19:54+00:00\",\"dateModified\":\"2019-05-10T16:12:47+00:00\",\"author\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"description\":\"How to check replication with mk-table-checksum Percona tool\",\"breadcrumb\":{\"@id\":\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/supportex.net\/blog\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL: checking replication with mk-table-checksum\"}]},{\"@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":"MySQL: checking replication with mk-table-checksum &#8211; Supportex.NET blog","description":"How to check replication with mk-table-checksum Percona tool","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\/09\/mysql-checking-replication-consistency-mk-table-checksum\/","og_locale":"en_US","og_type":"article","og_title":"MySQL: checking replication with mk-table-checksum &#8211; Supportex.NET blog","og_description":"How to check replication with mk-table-checksum Percona tool","og_url":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/","og_site_name":"Supportex.NET blog","article_published_time":"2011-09-26T22:19:54+00:00","article_modified_time":"2019-05-10T16:12:47+00:00","author":"Oleksii Tykhonov","twitter_misc":{"Written by":"Oleksii Tykhonov","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#article","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/"},"author":{"name":"Oleksii Tykhonov","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"headline":"MySQL: checking replication with mk-table-checksum","datePublished":"2011-09-26T22:19:54+00:00","dateModified":"2019-05-10T16:12:47+00:00","mainEntityOfPage":{"@id":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/"},"wordCount":272,"commentCount":0,"keywords":["mysql","percona"],"articleSection":["mysql"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/","url":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/","name":"MySQL: checking replication with mk-table-checksum &#8211; Supportex.NET blog","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/en\/#website"},"datePublished":"2011-09-26T22:19:54+00:00","dateModified":"2019-05-10T16:12:47+00:00","author":{"@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"description":"How to check replication with mk-table-checksum Percona tool","breadcrumb":{"@id":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/supportex.net\/blog\/2011\/09\/mysql-checking-replication-consistency-mk-table-checksum\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/supportex.net\/blog\/en\/"},{"@type":"ListItem","position":2,"name":"MySQL: checking replication with mk-table-checksum"}]},{"@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\/2091","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=2091"}],"version-history":[{"count":3,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2091\/revisions"}],"predecessor-version":[{"id":3182,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2091\/revisions\/3182"}],"wp:attachment":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/media?parent=2091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/categories?post=2091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/tags?post=2091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}