{"id":2298,"date":"2012-02-05T10:58:15","date_gmt":"2012-02-05T15:58:15","guid":{"rendered":"http:\/\/www.bytebot.net\/blog\/?p=2298"},"modified":"2012-02-05T11:00:53","modified_gmt":"2012-02-05T16:00:53","slug":"managing-mysql-with-percona-toolkit-by-frederic-descamps","status":"publish","type":"post","link":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps","title":{"rendered":"Managing MySQL with Percona Toolkit by Fr\u00c3\u00a9d\u00c3\u00a9ric Descamps"},"content":{"rendered":"<p>Fr\u00e9d\u00e9ric Descamps of <a href=\"http:\/\/www.percona.com\/\">Percona<\/a>.<\/p>\n<p>Percona Toolkit is Maatkit &amp; Aspersa combined. Opensource and the tools are very useful for a DBA.<\/p>\n<p>You need Perl, DBI, DBD::mysql, Term::ReadKey. Most tools are written in Perl, and whatever is in Bash is being re-written in Perl. There is also a tarball or RPM or DEB packages.<\/p>\n<p>Know your environment. The hardware &amp; OS are crucial for you to know. How much memory\/CPU do you use? Do you use swap? Is this a physical\/virtual machine? Do you have free space? What kind of RAID controller? Volumes? Disk? What about the network interfaces? What IO schedulers are used? Which filesystem is the data stored on?\u00a0To answer all that, just use <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-summary.html\">pt-summary<\/a><\/tt>.<\/p>\n<p>Know your MySQL environment. Version? Build? How many databases? Where is the data directory? What about replication? What are key InnoDB settings? Storage engine in use? Index type? Foreign keys? Full text indexes? To answer all this and more use <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-mysql-summary.html\"><tt>pt-mysql-summary<\/tt><\/a>.<\/p>\n<p>pt-slave-find shows you the topology and replication hierarchy of your MySQL replication instances. An inventory of replicas!<\/p>\n<p>Where is my disk I\/O going? Use <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-diskstats.html\">pt-diskstats<\/a><\/tt> which is an improved iostat. There is <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-ioprofile.html\">pt-ioprofile<\/a><\/tt> but it can be dangerous in production.<\/p>\n<p>Now its time to get more intimate with your database. Let&#8217;s try to find the answer to these questions: how are the indexes used? Are there duplicate keys? Which queries are eating most of the resources? You can use <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-duplicate-key-checker.html\"><tt>pt-duplicate-key-checker<\/tt><\/a> to check for duplicate\/redundant indexes or foreign keys. <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-index-usage.html\"><tt>pt-index-usage<\/tt><\/a> can tell you which indexes are unused. If you think you have bad SQL, check out <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-query-advisor.html\"><tt>pt-query-advisor<\/tt><\/a>.<\/p>\n<p>You can use <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-query-digest.html\"><tt>pt-query-digest<\/tt><\/a> to analyze the slow query log and show a profile of the workload. You mostly use this with slow query logs &amp; tcpdump&#8217;s. Be careful when you have dropped packets &#8212; results may tend to be fake then!<\/p>\n<p>After all this, its time to maintain your environment.<\/p>\n<p><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-deadlock-logger.html\"><tt>pt-deadlock-logger<\/tt><\/a> checks InnoDB status to log MySQL deadlock information. It needs to run continually to capture things.<\/p>\n<p><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-fk-error-logger.html\"><tt>pt-fk-error-logger<\/tt><\/a> extracts and logs MySQL foreign key errors.<\/p>\n<p><tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-online-schema-change.html\">pt-online-schema-change<\/a><\/tt> to alter tables. It makes a &#8220;shadow copy&#8221; and swaps them. Extremely useful for large, long-running ALTER. Facebook uses the same technique.<\/p>\n<p>Validate your upgrades as upgrades are the leading cause of downtime. Are queries using different indexes? Is query execution plan different? New errors? See <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-upgrade.html\">pt-upgrade<\/a><\/tt> for this. Best to run this on a third machine (i.e. the old machine and a new machine to see how it goes).<\/p>\n<p>Verify replication integrity &#8211; <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-table-checksum.html\">pt-table-checksum<\/a><\/tt>. Perform an online replication consistency check or checksum MySQL tables efficiently on one or many servers. Use it routinely (mandatory for 95% of MySQL users). Put it in a weekly crontab. Repair differences with <tt>pt-table-sync<\/tt>.<\/p>\n<p>Repair out-of-sync replicas &#8211; <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-table-sync.html\">pt-table-sync<\/a><\/tt><\/p>\n<p>Measure delay acfurately &#8211; <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-heartbeat.html\">pt-heartbeat<\/a><\/tt><\/p>\n<p>Deliberately delay replication &#8211; <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-slave-delay.html\">pt-slave-delay<\/a><\/tt><\/p>\n<p>Watch &amp; restart MySQL replication after errors &#8211; <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-slave-restart.html\"><tt>pt-slave-restart<\/tt><\/a><\/p>\n<p>When there are problems, get the symptoms when it hurts. Look at <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-stalk.html\">pt-stalk<\/a><\/tt> (wait for a condition to occur them begin collecting data &#8211; eg. everytime the threads go over 2,000 you have a problem, so it collects stuff &#8211; it calls <tt>pt-collect<\/tt>), <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-collect.html\">pt-collect<\/a><\/tt> (collect information from a server for some period of time), and <tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-sift.html\">pt-sift<\/a><\/tt>.<\/p>\n<p><tt><a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-mext.html\">pt-mext<\/a><\/tt> looks at many samples of MySQL <tt>SHOW GLOBAL STATUS<\/tt> side-by-side. Default STATUS shows counter since the MySQL instances started. It is very helpful to see a delta of recent activity.<\/p>\n<p>The future: <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.0\/pt-query-digest.html\"><tt>pt-query-digest<\/tt><\/a> will do query reviews; <tt>pt-stalk<\/tt> will do &#8220;magical fault detection algorithm&#8221;. Its all opensource and its all on Launchpad at <a href=\"https:\/\/launchpad.net\/percona-toolkit\">lp:percona-toolkit<\/a>.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Managing%20MySQL%20with%20Percona%20Toolkit%20by%20Fr%C3%83%C2%A9d%C3%83%C2%A9ric%20Descamps&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2012%2F02%2F05%2Fmanaging-mysql-with-percona-toolkit-by-frederic-descamps&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"0ac0aa09fe\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-2298\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-2298\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-2298\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Fr\u00e9d\u00e9ric Descamps of Percona. Percona Toolkit is Maatkit &amp; Aspersa combined. Opensource and the tools are very useful for a DBA. You need Perl, DBI, DBD::mysql, Term::ReadKey. Most tools are written in Perl, and whatever is in Bash is being re-written in Perl. There is also a tarball or RPM or DEB packages. Know your [&hellip;]<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Managing%20MySQL%20with%20Percona%20Toolkit%20by%20Fr%C3%83%C2%A9d%C3%83%C2%A9ric%20Descamps&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2012%2F02%2F05%2Fmanaging-mysql-with-percona-toolkit-by-frederic-descamps&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"0ac0aa09fe\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-2298\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-2298\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-2298\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[23],"tags":[1332,1349,1350],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4vJD-B4","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3158,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2016\/01\/12\/fosdem-2016-see-you-in-brussels","url_meta":{"origin":2298,"position":0},"title":"FOSDEM 2016 &#8211; See you in Brussels","date":"12\/1\/2016","format":false,"excerpt":"Over the weekend I read in the FT (paywall): Is Brussels safe? Ring a local resident to find out. I\u2019m sure it will be fine, and you will want to be there for FOSDEM, happening 30-31 January 2016.\u00a0 There is the excellent one day track, that is the MySQL &\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2452,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/08\/31\/mysql-across-two-coasts","url_meta":{"origin":2298,"position":1},"title":"MySQL across two coasts","date":"31\/8\/2012","format":false,"excerpt":"The end of September\/beginning of October is a most exciting time if you dig MySQL & its diaspora. September 29-30 is MySQL Connect\u00a0(register - early bird ends September 7) in San Francisco and October 1-2 is Percona Live NYC\u00a0(register\u00a0- early bird ends September 1) in New York City. I'm just\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3280,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2016\/09\/08\/speaking-at-percona-live-europe-amsterdam","url_meta":{"origin":2298,"position":2},"title":"Speaking at Percona Live Europe Amsterdam","date":"8\/9\/2016","format":false,"excerpt":"I'm happy to speak at Percona Live Europe Amsterdam 2016 again this year (just look at the awesome schedule). On my agenda: Monday Oct 3 Tutorial: Best Practices of MySQL High Availability Monday Oct 3 Tutorial: The Complete MariaDB Tutorial Wednesday Oct 5 Talk: Securing your MySQL\/MariaDB data with my\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3134,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2015\/11\/29\/voting-for-the-percona-live-data-performance-conference-2016","url_meta":{"origin":2298,"position":3},"title":"Voting for talks at the Percona Live Data Performance Conference 2016","date":"29\/11\/2015","format":false,"excerpt":"So this year the Percona Live conference has a new name \u2013 it is the \u201cData Performance Conference\u201d (presumably for a much broader appeal and the fact that Percona is now in the MongoDB world as well). And the next new thing to note? You have to go through a\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3199,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2016\/04\/08\/tweet-summary-of-percona-live-2015","url_meta":{"origin":2298,"position":4},"title":"(tweet) Summary of Percona Live 2015","date":"8\/4\/2016","format":false,"excerpt":"The problem with Twitter is that we talk about something and before you know it, people forget. (e.g. does WebScaleSQL have an async client library?) How many blog posts are there about Percona Live Santa Clara 2015? This time (2016), I'm going to endeavour to write more than to just\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2695,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2013\/04\/16\/julian-cash-at-the-percona-live-mysql-conference","url_meta":{"origin":2298,"position":5},"title":"Julian Cash at the Percona Live MySQL Conference","date":"16\/4\/2013","format":false,"excerpt":"I just got invited to this: MySQL Studio Photos @ Percona Live MySQL. I immediately signed up on the Indiegogo page for MySQL Portrait Photographs. I'm going and I'm happy to see the photographer again. Julian Cash is an incredibly talented photographer (check out his portfolio) who for some years\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/farm1.staticflickr.com\/47\/138173597_b1f359cf5a_n.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/2298"}],"collection":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/comments?post=2298"}],"version-history":[{"count":5,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/2298\/revisions"}],"predecessor-version":[{"id":2303,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/2298\/revisions\/2303"}],"wp:attachment":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/media?parent=2298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/categories?post=2298"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/tags?post=2298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}