{"id":4795,"date":"2014-03-13T10:56:51","date_gmt":"2014-03-13T02:56:51","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=4795"},"modified":"2023-11-24T16:37:21","modified_gmt":"2023-11-24T08:37:21","slug":"some-tricky-about-mysqladmin-extended-status","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2014\/03\/some-tricky-about-mysqladmin-extended-status\/","title":{"rendered":"\u4f7f\u7528mysqladmin ext\u4e86\u89e3MySQL\u8fd0\u884c\u72b6\u6001"},"content":{"rendered":"\n<p><a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/mysqladmin.html\" target=\"_blank\" rel=\"noopener\">mysqladmin<\/a>\u662fMySQL\u4e00\u4e2a\u91cd\u8981\u7684\u5ba2\u6237\u7aef\uff0c\u6700\u5e38\u89c1\u7684\u662f\u4f7f\u7528\u5b83\u6765\u5173\u95ed\u6570\u636e\u5e93\uff0c\u9664\u6b64\uff0c\u8be5\u547d\u4ee4\u8fd8\u53ef\u4ee5\u4e86\u89e3MySQL\u8fd0\u884c\u72b6\u6001\u3001\u8fdb\u7a0b\u4fe1\u606f\u3001\u8fdb\u7a0b\u6740\u6b7b\u7b49\u3002\u672c\u6587\u4ecb\u7ecd\u4e00\u4e0b\u5982\u4f55\u4f7f\u7528mysqladmin extended-status(\u56e0\u4e3a\u6ca1\u6709&#8221;\u6b67\u4e49&#8221;\uff0c\u6240\u4ee5\u53ef\u4ee5\u4f7f\u7528ext\u4ee3\u66ff)\u4e86\u89e3MySQL\u7684\u8fd0\u884c\u72b6\u6001\u3002<\/p>\n\n\n\n\n\n\n<h3 class=\"wp-block-heading\">1. \u4f7f\u7528-r\/-i\u53c2\u6570<\/h3>\n\n\n\n<p>\u4f7f\u7528mysqladmin extended-status\u547d\u4ee4\u53ef\u4ee5\u83b7\u5f97\u6240\u6709MySQL\u6027\u80fd\u6307\u6807\uff0c\u5373show global status\u7684\u8f93\u51fa\uff0c\u4e0d\u8fc7\uff0c\u56e0\u4e3a\u591a\u6570\u8fd9\u4e9b\u6307\u6807\u90fd\u662f\u7d2f\u8ba1\u503c\uff0c\u5982\u679c\u60f3\u4e86\u89e3\u5f53\u524d\u7684\u72b6\u6001\uff0c\u5219\u9700\u8981\u8fdb\u884c\u4e00\u6b21\u5dee\u503c\u8ba1\u7b97\uff0c\u8fd9\u5c31\u662fmysqladmin extended-status\u7684\u4e00\u4e2a\u989d\u5916\u529f\u80fd\uff0c\u975e\u5e38\u5b9e\u7528\u3002\u9ed8\u8ba4\u7684\uff0c\u4f7f\u7528extended-status\uff0c\u770b\u5230\u4e5f\u662f\u7d2f\u8ba1\u503c\uff0c\u4f46\u662f\uff0c\u52a0\u4e0a\u53c2\u6570-r(&#8211;relative)\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u5404\u4e2a\u6307\u6807\u7684\u5dee\u503c\uff0c\u914d\u5408\u53c2\u6570-i(&#8211;sleep)\u5c31\u53ef\u4ee5\u6307\u5b9a\u5237\u65b0\u7684\u9891\u7387\uff0c\u90a3\u4e48\u5c31\u6709\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">mysqladmin -uroot -r -i 1 -pxxx extended-status\n+------------------------------------------+----------------------+\n| Variable_name                            | Value                |\n+------------------------------------------+----------------------+\n| Aborted_clients                          | 0                    |\n| Com_select                               | 336                  |\n| Com_insert                               | 243                  |\n......\n| Threads_created                          | 0                    |\n+------------------------------------------+----------------------+<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u914d\u5408grep\u4f7f\u7528<\/h3>\n\n\n\n<p>\u914d\u5408grep\u4f7f\u7528\uff0c\u6211\u4eec\u5c31\u6709\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">mysqladmin -uroot -r -i 1 -pxxx extended-status \\\n|grep \"Questions\\|Queries\\|Innodb_rows\\|Com_select \\|Com_insert \\|Com_update \\|Com_delete \"\n| Com_delete                               | 1                    |\n| Com_delete_multi                         | 0                    |\n| Com_insert                               | 321                  |\n| Com_select                               | 286                  |\n| Com_update                               | 63                   |\n| Innodb_rows_deleted                      | 1                    |\n| Innodb_rows_inserted                     | 207                  |\n| Innodb_rows_read                         | 5211                 |\n| Innodb_rows_updated                      | 65                   |\n| Queries                                  | 2721                 |\n| Questions                                | 2721                 |<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u914d\u5408\u7b80\u5355\u7684awk\u4f7f\u7528<\/h3>\n\n\n\n<p>\u4f7f\u7528awk\uff0c\u540c\u65f6\u8f93\u51fa\u65f6\u95f4\u4fe1\u606f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">mysqladmin -uroot -p -h127.0.0.1 -P3306 -r -i 1 ext |\\\nawk -F\"|\" '{\\\n  if($2 ~ \/Variable_name\/){\\\n    print \" &lt;-------------    \"  strftime(\"%H:%M:%S\") \"    ------------->\";\\\n  }\\\n  if($2 ~ \/Questions|Queries|Innodb_rows|Com_select |Com_insert |Com_update |Com_delete |Innodb_buffer_pool_read_requests\/)\\\n    print $2 $3;\\\n}'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u914d\u5408\u590d\u6742\u4e00\u70b9\u7684awk<\/h3>\n\n\n\n<p>\u53cd\u6b63\u4e5f\u4e0d\u7b80\u5355\u4e86\uff0c\u90a3\u5c31\u66f4\u590d\u6742\u4e00\u70b9\uff0c\u8fd9\u6837\u8ba9\u8f93\u51fa\u7ed3\u679c<strong>\u66f4\u53cb\u597d<\/strong>\u70b9\uff0c\u56e0\u4e3aawk\u4e0d\u652f\u6301\u52a8\u6001\u53d8\u91cf\uff0c\u6240\u4ee5\u4ee3\u7801\u770b\u8d77\u6765\u6bd4\u8f83\u590d\u6742\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">mysqladmin -P3306 -uroot -p -h127.0.0.1 -r -i 1 ext |\\\nawk -F\"|\" \\\n\"BEGIN{ count=0; }\"\\\n'{ if($2 ~ \/Variable_name\/ &amp;&amp; ((++count)%20 == 1)){\\\n    print \"----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --\";\\\n    print \"---Time---|---QPS---|select insert update delete|  read inserted updated deleted|   logical    physical\";\\\n}\\\nelse if ($2 ~ \/Queries\/){queries=$3;}\\\nelse if ($2 ~ \/Com_select \/){com_select=$3;}\\\nelse if ($2 ~ \/Com_insert \/){com_insert=$3;}\\\nelse if ($2 ~ \/Com_update \/){com_update=$3;}\\\nelse if ($2 ~ \/Com_delete \/){com_delete=$3;}\\\nelse if ($2 ~ \/Innodb_rows_read\/){innodb_rows_read=$3;}\\\nelse if ($2 ~ \/Innodb_rows_deleted\/){innodb_rows_deleted=$3;}\\\nelse if ($2 ~ \/Innodb_rows_inserted\/){innodb_rows_inserted=$3;}\\\nelse if ($2 ~ \/Innodb_rows_updated\/){innodb_rows_updated=$3;}\\\nelse if ($2 ~ \/Innodb_buffer_pool_read_requests\/){innodb_lor=$3;}\\\nelse if ($2 ~ \/Innodb_buffer_pool_reads\/){innodb_phr=$3;}\\\nelse if ($2 ~ \/Uptime \/ &amp;&amp; count >= 2){\\\n  printf(\" %s |%9d\",strftime(\"%H:%M:%S\"),queries);\\\n  printf(\"|%6d %6d %6d %6d\",com_select,com_insert,com_update,com_delete);\\\n  printf(\"|%6d %8d %7d %7d\",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted);\\\n  printf(\"|%10d %11d\\n\",innodb_lor,innodb_phr);\\\n}}'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --\n---Time---|---QPS---|select insert update delete|  read inserted updated deleted|   logical    physical\n 10:37:13 |     2231|   274    214     70      0|  4811      160      71       0|      4146           0\n 10:37:14 |     2972|   403    256     84     23|  2509      173      85      23|      4545           0\n 10:37:15 |     2334|   282    232     66      1|  1266      154      67       1|      3543           0\n 10:37:15 |     2241|   271    217     66      0|  1160      129      66       0|      2935           0\n 10:37:17 |     2497|   299    224     97      0|  1141      149      95       0|      3831           0\n 10:37:18 |     2871|   352    304     74     23|  8202      226      73      23|      6167           0\n 10:37:19 |     2441|   284    233     82      0|  1099      121      78       0|      3292           0\n 10:37:20 |     2342|   279    242     61      0|  1083      224      61       0|      3366           0<\/code><\/pre>\n\n\n\n<p>\u5c31\u8fd9\u6837\u4e86\uff0c\u8fd9\u51e0\u4e2a\u547d\u4ee4\u81ea\u5df1\u7528\u7684\u6bd4\u8f83\u591a\uff0c\u968f\u624b\u5206\u4eab\u51fa\u6765\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysqladmin\u662fMySQL\u4e00\u4e2a\u91cd\u8981\u7684\u5ba2\u6237\u7aef\uff0c\u6700\u5e38\u89c1\u7684\u662f\u4f7f\u7528\u5b83\u6765\u5173\u95ed\u6570\u636e\u5e93\uff0c\u9664\u6b64\uff0c\u8be5\u547d\u4ee4\u8fd8\u53ef\u4ee5\u4e86\u89e3MySQL\u8fd0\u884c\u72b6\u6001\u3001\u8fdb\u7a0b\u4fe1\u606f\u3001\u8fdb\u7a0b\u6740\u6b7b\u7b49\u3002\u672c\u6587\u4ecb\u7ecd\u4e00\u4e0b\u5982\u4f55\u4f7f\u7528mysqladmin extended-status(\u56e0\u4e3a\u6ca1\u6709&#8221;\u6b67\u4e49&#8221;\uff0c\u6240\u4ee5\u53ef\u4ee5\u4f7f\u7528ext\u4ee3\u66ff)\u4e86\u89e3MySQL\u7684\u8fd0\u884c\u72b6\u6001\u3002 1. \u4f7f\u7528-r\/-i\u53c2\u6570 \u4f7f\u7528mysqladmin extended-status\u547d\u4ee4\u53ef\u4ee5\u83b7\u5f97\u6240\u6709MySQL\u6027\u80fd\u6307\u6807\uff0c\u5373show global status\u7684\u8f93\u51fa\uff0c\u4e0d\u8fc7\uff0c\u56e0\u4e3a\u591a\u6570\u8fd9\u4e9b\u6307\u6807\u90fd\u662f\u7d2f\u8ba1\u503c\uff0c\u5982\u679c\u60f3\u4e86\u89e3\u5f53\u524d\u7684\u72b6\u6001\uff0c\u5219\u9700\u8981\u8fdb\u884c\u4e00\u6b21\u5dee\u503c\u8ba1\u7b97\uff0c\u8fd9\u5c31\u662fmysqladmin extended-status\u7684\u4e00\u4e2a\u989d\u5916\u529f\u80fd\uff0c\u975e\u5e38\u5b9e\u7528\u3002\u9ed8\u8ba4\u7684\uff0c\u4f7f\u7528extended-status\uff0c\u770b\u5230\u4e5f\u662f\u7d2f\u8ba1\u503c\uff0c\u4f46\u662f\uff0c\u52a0\u4e0a\u53c2\u6570-r(&#8211;relative)\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u5404\u4e2a\u6307\u6807\u7684\u5dee\u503c\uff0c\u914d\u5408\u53c2\u6570-i(&#8211;sleep)\u5c31\u53ef\u4ee5\u6307\u5b9a\u5237\u65b0\u7684\u9891\u7387\uff0c\u90a3\u4e48\u5c31\u6709\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[6],"tags":[],"class_list":["post-4795","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/4795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=4795"}],"version-history":[{"count":15,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/4795\/revisions"}],"predecessor-version":[{"id":9939,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/4795\/revisions\/9939"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=4795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=4795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=4795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}