{"id":271,"date":"2009-12-04T19:26:52","date_gmt":"2009-12-04T19:26:52","guid":{"rendered":"http:\/\/kedar.nitty-witty.com\/?p=271"},"modified":"2014-06-24T18:58:57","modified_gmt":"2014-06-24T18:58:57","slug":"mysql-master-master-replication-monitor-with-php-code","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/mysql-master-master-replication-monitor-with-php-code","title":{"rendered":"MySQL master master replication monitor with php code"},"content":{"rendered":"<p>For monitoring replication we know a lot of tools and codes &#8211; but this one is different because I wrote it \ud83d\ude09<br \/>\nWell this is fairly simple php code for monitoring a master master replication setup.<\/p>\n<p>It requires a single shared login id available on both MySQL servers.<\/p>\n<p>It will display in tabular format following details:<\/p>\n<ul>\n<li>File: Present binary log<\/li>\n<li>Position: Binary log position<\/li>\n<li>Io run: Slave IO Thread Running status<\/li>\n<li>Sql run: SQL Thread Running status<\/li>\n<li>ErrorNum: Error number<\/li>\n<li>ErrorMeg: Error message<\/li>\n<\/ul>\n<p>You can easily stop \/ start each server&#8217;s slave (STOP SLAVE \/ START SLAVE) with a single click.<br \/>\nIt also does provide detailed information of global status variables on same page.<br \/>\nIt is auto refreshes by default every 2 seconds to provide updated status of both MySQL Servers in Replication.<\/p>\n<p>In code you just need to adjust following parameters as per requirement:<\/p>\n<p><em>#host-name &amp; ports for replication servers<\/em><br \/>\n<em>$slave = &#8220;localhost&#8221;;<\/em><br \/>\n<em>$master = &#8220;localhost&#8221;;<\/em><br \/>\n<em>$slaveport=3306;<\/em><br \/>\n<em>$masterport=3307;<\/em><\/p>\n<p><em><\/em><br \/>\n<em>#Refresh rate<\/em><br \/>\n<em>$refreshRate=2;<\/em><\/p>\n<p><em><\/em><br \/>\n<em>#considered a common username password for accessing both servers#<\/em><br \/>\n<em>$username=&#8221;root&#8221;;<\/em><br \/>\n<span style=\"font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;\">$password=&#8221;kedar&#8221;;<\/span><\/p>\n<p>You can download code here: <a href=\"http:\/\/kedar.nitty-witty.com\/wp-content\/uploads\/2009\/12\/replication.zip\">mysql-replication-monitor.php<\/a><\/p>\n<p>MySQL Replication Monitor Using PHP:<\/p>\n<p style=\"text-align: center;\"><a title=\"mysql-replication-monitor-php\" href=\"http:\/\/kedar.nitty-witty.com\/wp-content\/uploads\/2009\/12\/mysql-replication-monitor-php.jpg\" target=\"_blank\"><img decoding=\"async\" class=\"size-medium wp-image-274 aligncenter\" title=\"mysql-replication-monitor-php\" src=\"http:\/\/kedar.nitty-witty.com\/wp-content\/uploads\/2009\/12\/mysql-replication-monitor-php-300x144.jpg\" alt=\"mysql-replication-monitor-php\" width=\"400\" height=\"250\" \/><\/a><\/p>\n<p><script charset=\"utf-8\" type=\"text\/javascript\" src=\"http:\/\/ws.amazon.com\/widgets\/q?ServiceVersion=20070822&#038;MarketPlace=US&#038;ID=V20070822\/US\/httpkedarnitt-20\/8001\/29266fe4-10b4-4f4a-bf7f-c5dc0ffee5a2\"> <\/script> <noscript><a HREF=\"http:\/\/ws.amazon.com\/widgets\/q?ServiceVersion=20070822&#038;MarketPlace=US&#038;ID=V20070822%2FUS%2Fhttpkedarnitt-20%2F8001%2F29266fe4-10b4-4f4a-bf7f-c5dc0ffee5a2&#038;Operation=NoScript\">Amazon.com Widgets<\/a><\/noscript><\/p>\n","protected":false},"excerpt":{"rendered":"For monitoring replication we know a lot of tools and codes &#8211; but this one is different because I wrote it \ud83d\ude09 Well this is fairly simple php code for&hellip;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","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,378],"tags":[24,427,208,85,209,100,426,119],"class_list":{"0":"post-271","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-mysql","7":"category-mysql-scripts-mysql","8":"tag-code","9":"tag-mysql","10":"tag-mysql-replication-monitoring","11":"tag-php","12":"tag-php-script","13":"tag-replication","14":"tag-technical","15":"tag-tool"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/271","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=271"}],"version-history":[{"count":3,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/271\/revisions"}],"predecessor-version":[{"id":1602,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/271\/revisions\/1602"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}