{"id":2961,"date":"2014-03-01T15:50:39","date_gmt":"2014-03-01T15:50:39","guid":{"rendered":"http:\/\/blog.hmouse.tk\/?p=2961"},"modified":"2014-03-10T09:25:53","modified_gmt":"2014-03-10T01:25:53","slug":"mysqlmtop-%e5%ae%89%e8%a3%85%e6%89%8b%e5%86%8c","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=2961","title":{"rendered":"mysqlMTop \u5b89\u88c5\u624b\u518c"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><basefont size=\"2\" face=\"Tahoma\" \/><br \/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html;charset=utf-8\" \/><br \/>\n<meta name=\"exporter-version\" content=\"Evernote Windows\/270387 (zh-CN); Windows\/6.1.7601 Service Pack 1;\" \/><\/p>\n<style><!--\n    body, td {\n      font-family: Tahoma;\n      font-size: 10pt;\n    }\n\n--><\/style>\n<p><a name=\"216\"><\/a><\/p>\n<h1>mysqlMTop \u5b89\u88c5\u624b\u518c<\/h1>\n<div>\n<div style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">\u4e0b\u8f7d<\/p>\n<div>\u00a0cd \/root\/install<\/div>\n<div>wget <a href=\"http:\/\/mtop.cc\/system\/files\/mysqlmtop_v1.0_beta_sp1.zip\">http:\/\/mtop.cc\/system\/files\/mysqlmtop_v1.0_beta_sp1.zip<\/a><\/div>\n<div>\u5b89\u88c5<\/div>\n<div>\u524d\u671f\u51c6\u5907<\/div>\n<div>unzip -o\u00a0mysqlmtop_v1.0_beta_sp1.zip<\/div>\n<div>\u00a0yum -y install \u00a0vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel\u00a0 pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel\u00a0 libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel<\/div>\n<div>yum -y install php\u00a0php-devel \u00a0php-mysql\u00a0httpd<\/div>\n<div>yum -y install MySQL-python\u00a0php-gd<\/div>\n<div>\u5b89\u88c5sql<\/div>\n<div>\n<p>mysql&gt; create database mtop default character set utf8;<\/p>\n<p>mysql&gt; grant select,insert,update,delete,create,drop,alter,index on mtop.* to &#8216;mtop&#8217;@&#8217;localhost&#8217; identified by &#8216;mtop321&#8217;;<\/p>\n<p>mysql&gt; flush privileges;<\/p>\n<p>\u5bfc\u5165SQL\u6587\u4ef6\u5939\u91cc\u7684SQL\u6587\u4ef6<\/p>\n<p>#mysql -uroot -p mtop &lt; mtop.sql<\/p>\n<div>#mysql -uroot -p mtop &lt; mtop_data.sql<\/div>\n<\/div>\n<div><\/div>\n<div>cp -rf mysqlmtop\/ \/usr\/local\/<\/div>\n<div><\/div>\n<div>vi\u00a0 etc\/config.ini<\/div>\n<div><\/div>\n<div>[monitor_server]<br \/>\nhost=&#8221;localhost&#8221;<br \/>\nport=3306<br \/>\nuser=&#8221;mtop&#8221;<br \/>\npasswd=&#8221;mtop321&#8243;<br \/>\ndbname=&#8221;mtop&#8221;<br \/>\n#\u672c\u5730\u6570\u636e\u5e93#<br \/>\n###MySQL\u6570\u636e\u5e93\u7528\u6237\u5bc6\u7801###<br \/>\n[mysql_db]<br \/>\nusername=&#8221;mtop&#8221;<br \/>\npassword=&#8221;mtop321&#8243;<br \/>\n#\u76d1\u63a7\u8d26\u53f7\u548c\u5bc6\u7801#<br \/>\n###\u90ae\u4ef6\u62a5\u8b66\u670d\u52a1\u5668\u5730\u5740###<br \/>\n[mail_server]<br \/>\nmail_host=&#8221;&#8221;<br \/>\nmail_user=&#8221;&#8221;<br \/>\nmail_pass=&#8221;&#8221;<br \/>\nmail_postfix=&#8221;<\/div>\n<div><\/div>\n<div>\n<p>2.3\u6388\u4e88\u53ef\u6267\u884c\u6587\u4ef6\u6267\u884c\u6743\u9650\u5e76\u542f\u52a8\u8fdb\u7a0b<\/p>\n<p># chmod a+x \u00a0*.py<\/p>\n<p># ln -s \/usr\/local\/mysqlmtop\/mtopctl \/usr\/local\/bin\/ \u00a0\uff08\u8fd9\u90e8\u53ef\u4ee5\u7701\u7565\uff09<\/p>\n<p>#\u00a0 \/usr\/local\/mysqlmtop\/mtopctl start<\/p>\n<\/div>\n<div>mv frontweb \/var\/www\/html\/sqljk<\/div>\n<div><\/div>\n<div>chown -Rf apache:apache \/var\/www\/html\/sqljk\/<\/div>\n<div>vi application\/config\/database.php<\/div>\n<div>\u4fee\u6539\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6<\/div>\n<div>vi application\/controllers\/grapha.php<\/div>\n<div>ini_set(&#8220;include_path&#8221;, &#8220;D:\/wwwroot\/mysqlmtop\/frontweb\/public&#8221;);<\/div>\n<div>\u4fee\u6539\u6210\u6b63\u786e\u7684\u8def\u5f84<\/div>\n<div><\/div>\n<div>\u6388\u6743<\/div>\n<div>grant select,REPLICATION client,process on *.* to &#8216;mtop&#8217;@&#8217;172.21.27.76&#8217; identified by &#8216;mtop321!@#&#8217;;<br \/>\nflush privileges;<\/div>\n<div><\/div>\n<div>\u95ee\u9898<\/div>\n<div>vi \/var\/www\/html\/sqljk\/application\/views\/widget\/bigtable.php<\/div>\n<div>\u4fee\u6539\u5927\u8868\u7684\u5355\u4f4d<\/div>\n<div>\u00a0&lt;td&gt;&lt;?php echo $item[&#8216;table_size&#8217;] ?&gt;M&lt;\/td&gt;<\/div>\n<div><\/div>\n<div>vi\u00a0.\/check_mysql_widget_bigtable.py<\/div>\n<div>\u4fee\u6539<\/div>\n<div>bigtable=cur.execute(&#8220;SELECT table_schema as &#8216;DB&#8217;,table_name as &#8216;TABLE&#8217;,CONCAT(ROUND(( data_length + index_length ) \/ ( <span style=\"color: #ff0000;\">1024 * 1024<\/span>\u00a0 ), 2), &#8221;) &#8216;TOTAL&#8217; , table_comment as COMMENT FROM information_schema.TABLES ORDER BY data_length + index_length DESC LIMIT <span style=\"color: #ff0000;\">1<\/span>; ;&#8221;);<\/div>\n<div>\u53d6\u6700\u5927\u7684\u503c\uff0c\u4e4b\u524d\u8bbe\u7f6e\u7684\u662fG\uff0c\u73b0\u5728\u6539\u6210\u4e86M<\/div>\n<div><span style=\"color: #ff0000;\">if table_size &gt; 0:<\/span><\/div>\n<div>\u5982\u679c\u8868\u8d85\u8fc7\u591a\u5c11\u7684\u65f6\u5019\uff0c\u624d\u63d2\u5165\u3002<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;<\/p>\n<p><basefont size=\"2\" face=\"Tahoma\" \/><br \/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html;charset=utf-8\" \/><br \/>\n<meta name=\"exporter-version\" content=\"Evernote Windows\/270387 (zh-CN); Windows\/6.1.7601 Service Pack 1;\" \/><\/p>\n<style><!--\n    body, td {\n      font-family: Tahoma;\n      font-size: 10pt;\n    }\n\n--><\/style>\n<p><a name=\"216\"><\/a><\/p>\n<h1>mysqlMTop \u5b89\u88c5\u624b\u518c<\/h1>\n<div>\n<div style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">\u4e0b\u8f7d<\/p>\n<div>\u00a0cd \/root\/install<\/div>\n<div>wget <a href=\"http:\/\/mtop.cc\/system\/files\/mysqlmtop_v1.0_beta_sp1.zip\">http:\/\/mtop.cc\/system\/files\/mysqlmtop_v1.0_beta_sp1.zip<\/a><\/div>\n<div>\u5b89\u88c5<\/div>\n<div>\u524d\u671f\u51c6\u5907<\/div>\n<div>unzip -o\u00a0mysqlmtop_v1.0_beta_sp1.zip<\/div>\n<div>\u00a0yum -y install \u00a0vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel\u00a0 pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel\u00a0 libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel<\/div>\n<div>yum -y install php\u00a0php-devel \u00a0php-mysql\u00a0httpd<\/div>\n<div>yum -y install MySQL-python\u00a0php-gd<\/div>\n<div>\u5b89\u88c5sql<\/div>\n<div>\n<p>mysql&gt; create database mtop default character set utf8;<\/p>\n<p>mysql&gt; grant select,insert,update,delete,create,drop,alter,index on mtop.* to &#8216;mtop&#8217;@&#8217;localhost&#8217; identified by &#8216;mtop321&#8217;;<\/p>\n<p>mysql&gt; flush privileges;<\/p>\n<p>\u5bfc\u5165SQL\u6587\u4ef6\u5939\u91cc\u7684SQL\u6587\u4ef6<\/p>\n<p>#mysql -uroot -p mtop &lt; mtop.sql<\/p>\n<div>#mysql -uroot -p mtop &lt; mtop_data.sql<\/div>\n<\/div>\n<div><\/div>\n<div>cp -rf mysqlmtop\/ \/usr\/local\/<\/div>\n<div><\/div>\n<div>vi\u00a0 etc\/config.ini<\/div>\n<div><\/div>\n<div>[monitor_server]<br \/>\nhost=&#8221;localhost&#8221;<br \/>\nport=3306<br \/>\nuser=&#8221;mtop&#8221;<br \/>\npasswd=&#8221;mtop321&#8243;<br \/>\ndbname=&#8221;mtop&#8221;<br \/>\n#\u672c\u5730\u6570\u636e\u5e93#<br \/>\n###MySQL\u6570\u636e\u5e93\u7528\u6237\u5bc6\u7801###<br \/>\n[mysql_db]<br \/>\nusername=&#8221;mtop&#8221;<br \/>\npassword=&#8221;mtop321&#8243;<br \/>\n#\u76d1\u63a7\u8d26\u53f7\u548c\u5bc6\u7801#<br \/>\n###\u90ae\u4ef6\u62a5\u8b66\u670d\u52a1\u5668\u5730\u5740###<br \/>\n[mail_server]<br \/>\nmail_host=&#8221;&#8221;<br \/>\nmail_user=&#8221;&#8221;<br \/>\nmail_pass=&#8221;&#8221;<br \/>\nmail_postfix=&#8221;<\/div>\n<div><\/div>\n<div>\n<p>2.3\u6388\u4e88\u53ef\u6267\u884c\u6587\u4ef6\u6267\u884c\u6743\u9650\u5e76\u542f\u52a8\u8fdb\u7a0b<\/p>\n<p># chmod a+x \u00a0*.py<\/p>\n<p># ln -s \/usr\/local\/mysqlmtop\/mtopctl \/usr\/local\/bin\/ \u00a0\uff08\u8fd9\u90e8\u53ef\u4ee5\u7701\u7565\uff09<\/p>\n<p>#\u00a0 \/usr\/local\/mysqlmtop\/mtopctl start<\/p>\n<\/div>\n<div>mv frontweb \/var\/www\/html\/sqljk<\/div>\n<div><\/div>\n<div>chown -Rf apache:apache \/var\/www\/html\/sqljk\/<\/div>\n<div>vi application\/config\/database.php<\/div>\n<div>\u4fee\u6539\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6<\/div>\n<div>vi application\/controllers\/grapha.php<\/div>\n<div>ini_set(&#8220;include_path&#8221;, &#8220;D:\/wwwroot\/mysqlmtop\/frontweb\/public&#8221;);<\/div>\n<div>\u4fee\u6539\u6210\u6b63\u786e\u7684\u8def\u5f84<\/div>\n<div><\/div>\n<div>\u6388\u6743<\/div>\n<div>grant select,REPLICATION client,process on *.* to &#8216;mtop&#8217;@&#8217;172.21.27.76&#8217; identified by &#8216;mtop321!@#&#8217;;<br \/>\nflush privileges;<\/div>\n<div><\/div>\n<div>\u95ee\u9898<\/div>\n<div>vi \/var\/www\/html\/sqljk\/application\/views\/widget\/bigtable.php<\/div>\n<div>\u4fee\u6539\u5927\u8868\u7684\u5355\u4f4d<\/div>\n<div>\u00a0&lt;td&gt;&lt;?php echo $item[&#8216;table_size&#8217;] ?&gt;M&lt;\/td&gt;<\/div>\n<div><\/div>\n<div>vi\u00a0.\/check_mysql_widget_bigtable.py<\/div>\n<div>\u4fee\u6539<\/div>\n<div>bigtable=cur.execute(&#8220;SELECT table_schema as &#8216;DB&#8217;,table_name as &#8216;TABLE&#8217;,CONCAT(ROUND(( data_length + index_length ) \/ ( <span style=\"color: #ff0000;\">1024 * 1024<\/span>\u00a0 ), 2), &#8221;) &#8216;TOTAL&#8217; , table_comment as COMMENT FROM information_schema.TABLES ORDER BY data_length + index_length DESC LIMIT <span style=\"color: #ff0000;\">1<\/span>; ;&#8221;);<\/div>\n<div>\u53d6\u6700\u5927\u7684\u503c\uff0c\u4e4b\u524d\u8bbe\u7f6e\u7684\u662fG\uff0c\u73b0\u5728\u6539\u6210\u4e86M<\/div>\n<div><span style=\"color: #ff0000;\">if table_size &gt; 0:<\/span><\/div>\n<div>\u5982\u679c\u8868\u8d85\u8fc7\u591a\u5c11\u7684\u65f6\u5019\uff0c\u624d\u63d2\u5165\u3002<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2961","post","type-post","status-publish","format-standard","hentry","category-5","category-5-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2961"}],"version-history":[{"count":3,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2961\/revisions"}],"predecessor-version":[{"id":3106,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2961\/revisions\/3106"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}