{"id":870,"date":"2014-08-05T12:49:45","date_gmt":"2014-08-05T12:49:45","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=870"},"modified":"2014-08-05T12:49:45","modified_gmt":"2014-08-05T12:49:45","slug":"linux%e7%b3%bb%e7%bb%9f%e7%9a%84%e6%80%a7%e8%83%bd%e6%8c%87%e6%a0%87","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/870.html","title":{"rendered":"Linux\u7cfb\u7edf\u7684\u6027\u80fd\u6307\u6807"},"content":{"rendered":"<p>\u4e4b\u524d\u88ab\u95ee\u5230\u8fc7\u7684\u4e00\u4e2a\u95ee\u9898\uff0c\u4e5f\u80fd\u591f\u7b54\u4e0a\u6765\u4e00\u4e9b\uff0c\u4f46\u53ef\u80fd\u56e0\u4e3a\u6ca1\u6709\u63a5\u89e6\u8fc7\u771f\u5b9e\u7684\u7ebf\u4e0a\u751f\u4ea7\u73af\u5883\uff0c\u53ea\u662f\u81ea\u5df1\u5728\u81ea\u5df1\u7684\u865a\u62df\u673a\/VPS\u4e0a\u8fd0\u884c\u7684\u65f6\u5019\u67e5\u770b\u7740\u73a9\u4e00\u73a9\uff0c\u5bf9\u6027\u80fd\u6307\u6807\u3001\u7cfb\u7edf\u6027\u80fd\u76d1\u63a7\u6ca1\u6709\u4ec0\u4e48\u7279\u522b\u6df1\u523b\u3001\u76f4\u89c2\u7684\u8ba4\u8bc6\uff0c\u95f2\u7740\u7684\u65f6\u5019\u60f3\u60f3\u8fd9\u4e2a\u95ee\u9898\uff08\u5bf9\u4e8e\u4e00\u53f0Linux\u673a\u5668\u6765\u8bf4\uff0c\u5982\u4f55\u76d1\u63a7\u5b83\u7684CPU\uff0c\u5185\u5b58\uff0c\u78c1\u76d8\uff0c\u7f51\u7edc\u7b49\u7684\u4f7f\u7528\u60c5\u51b5\uff1b\u600e\u6837\u7b97\u9ad8\u8d1f\u8f7d\uff0c\u5177\u4f53\u7684\u4f9d\u636e\u662f\u4ec0\u4e48\uff1f\uff09\u53ef\u80fd\u8fd8\u662f\u5f97\u603b\u7ed3\u4e00\u4e0b\uff0c\u8bf4\u4e0d\u5b9a\u4ec0\u4e48\u65f6\u5019\u5c31\u518d\u7528\u5f97\u4e0a\u5462\uff1f<\/p>\n<h5>\u4e00\u3001CPU\u7684\u4f7f\u7528\u60c5\u51b5<\/h5>\n<p>CPU\u4f7f\u7528\u7387\u53cd\u6620\u7684\u662f\u5f53\u524dCPU\u7684\u7e41\u5fd9\u7a0b\u5ea6\uff0c\u5ffd\u9ad8\u5ffd\u4f4e\u7684\u539f\u56e0\u5728\u4e8e\u5360\u7528CPU\u5904\u7406\u65f6\u95f4\u7684\u8fdb\u7a0b\u53ef\u80fd\u5904\u4e8eI\/O\u7b49\u5f85\u72b6\u6001\u4f46\u5374\u8fd8\u672a\u91ca\u653e\u8fdb\u5165wait\u3002<\/p>\n<p>\u5e73\u5747\u8d1f\u8f7d\uff08load average\uff09\u662f\u6307\u67d0\u6bb5\u65f6\u95f4\u5185\u5360\u7528CPU\u65f6\u95f4\u7684\u8fdb\u7a0b\u548c\u7b49\u5f85CPU\u65f6\u95f4\u7684\u8fdb\u7a0b\u6570\uff0c\u8fd9\u91cc\u7b49\u5f85CPU\u65f6\u95f4\u7684\u8fdb\u7a0b\u662f\u6307\u7b49\u5f85\u88ab\u5524\u9192\u7684\u8fdb\u7a0b\uff0c\u4e0d\u5305\u62ec\u5904\u4e8ewait\u72b6\u6001\u8fdb\u7a0b\u3002<\/p>\n<h6>CPU\u826f\u597d\u72b6\u6001\u7684\u6307\u6807<\/h6>\n<ul>\n<li>CPU\u5229\u7528\u7387\uff1aUser Time &lt;= 70%\uff0cSystem Time &lt;= 35%\uff0cUser Time + System Time &lt;= 70%\u3002<\/li>\n<li>\u4e0a\u4e0b\u6587\u5207\u6362\uff1a\u4e0eCPU\u5229\u7528\u7387\u76f8\u5173\u8054\uff0c\u5982\u679cCPU\u5229\u7528\u7387\u72b6\u6001\u826f\u597d\uff0c\u5927\u91cf\u7684\u4e0a\u4e0b\u6587\u5207\u6362\u4e5f\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\u3002<\/li>\n<li>\u53ef\u8fd0\u884c\u961f\u5217\uff1a\u6bcf\u4e2a\u5904\u7406\u5668\u7684\u53ef\u8fd0\u884c\u961f\u5217&lt;=3\u4e2a\u7ebf\u7a0b\u3002<\/li>\n<\/ul>\n<h6>\u5e38\u7528\u76d1\u63a7\u5de5\u5177\/\u547d\u4ee4\u6709\uff1a<\/h6>\n<ul>\n<li>mpstat\uff1a mpstat \u4e0d\u4f46\u80fd\u67e5\u770b\u6240\u6709CPU\u7684\u5e73\u5747\u4fe1\u606f\uff0c\u8fd8\u80fd\u67e5\u770b\u6307\u5b9aCPU\u7684\u4fe1\u606f\u3002<\/li>\n<li>vmstat\uff1a\u67e5\u770b\u6240\u6709CPU\u7684\u5e73\u5747\u4fe1\u606f\u3002<\/li>\n<li>iostat: \u53ea\u80fd\u67e5\u770b\u6240\u6709CPU\u7684\u5e73\u5747\u4fe1\u606f\u3002<\/li>\n<li>sar\uff1a \u4e0e mpstat \u4e00\u6837\uff0c\u4e0d\u4f46\u80fd\u67e5\u770bCPU\u7684\u5e73\u5747\u4fe1\u606f\uff0c\u8fd8\u80fd\u67e5\u770b\u6307\u5b9aCPU\u7684\u4fe1\u606f\u3002<\/li>\n<li>top\uff1a \u663e\u793a\u7684\u4fe1\u606f\u540cps\u63a5\u8fd1\uff0c\u4f46\u662ftop\u53ef\u4ee5\u4e86\u89e3\u5230CPU\u6d88\u8017\uff0c\u53ef\u4ee5\u6839\u636e\u7528\u6237\u6307\u5b9a\u7684\u65f6\u95f4\u6765\u66f4\u65b0\u663e\u793a\u3002<\/li>\n<\/ul>\n<h5>\u4e8c\u3001Memory\u7684\u4f7f\u7528\u60c5\u51b5<\/h5>\n<h6>Memory\u7684\u826f\u597d\u72b6\u6001\u6307\u6807<\/h6>\n<p>swap in \uff08si\uff09 == 0\uff0cswap out \uff08so\uff09 == 0<br \/>\n\u5e94\u7528\u7a0b\u5e8f\u53ef\u7528\u5185\u5b58\/\u7cfb\u7edf\u7269\u7406\u5185\u5b58 &lt;= 70%<\/p>\n<h6>\u5e38\u7528\u76d1\u63a7\u5de5\u5177\/\u547d\u4ee4\uff1a<\/h6>\n<ul>\n<li>vmstat<\/li>\n<li>free<\/li>\n<\/ul>\n<h5>\u4e09\u3001\u78c1\u76d8\u7684\u4f7f\u7528\u60c5\u51b5\uff08\u78c1\u76d8I\/O\uff09<\/h5>\n<h6>\u78c1\u76d8\u4f7f\u7528\u7387\u7684\u826f\u597d\u72b6\u6001\u6307\u6807<\/h6>\n<ul>\n<li>iowait % &lt; 20%<\/li>\n<li>\u63d0\u9ad8\u547d\u4e2d\u7387\u7684\u4e00\u4e2a\u7b80\u5355\u65b9\u5f0f\u5c31\u662f\u589e\u5927\u6587\u4ef6\u7f13\u5b58\u533a\u9762\u79ef\uff0c\u7f13\u5b58\u533a\u8d8a\u5927\u9884\u5b58\u7684\u9875\u9762\u5c31\u8d8a\u591a\uff0c\u547d\u4e2d\u7387\u4e5f\u8d8a\u9ad8\u3002<\/li>\n<li>Linux \u5185\u6838\u5e0c\u671b\u80fd\u5c3d\u53ef\u80fd\u4ea7\u751f\u6b21\u7f3a\u9875\u4e2d\u65ad\uff08\u4ece\u6587\u4ef6\u7f13\u5b58\u533a\u8bfb\uff09\uff0c\u5e76\u4e14\u80fd\u5c3d\u53ef\u80fd\u907f\u514d\u4e3b\u7f3a\u9875\u4e2d\u65ad\uff08\u4ece\u786c\u76d8\u8bfb\uff09\uff0c\u8fd9\u6837\u968f\u7740\u6b21\u7f3a\u9875\u4e2d\u65ad\u7684\u589e\u591a\uff0c\u6587\u4ef6\u7f13\u5b58\u533a\u4e5f\u9010\u6b65\u589e\u5927\uff0c\u76f4\u5230\u7cfb\u7edf\u53ea\u6709\u5c11\u91cf\u53ef\u7528\u7269\u7406\u5185\u5b58\u7684\u65f6\u5019 Linux \u624d\u5f00\u59cb\u91ca\u653e\u4e00\u4e9b\u4e0d\u7528\u7684\u9875\u3002<\/li>\n<\/ul>\n<p><span style=\"font-weight: bold;\">\u5e38\u7528\u76d1\u63a7\u5de5\u5177\/\u547d\u4ee4\uff1a<\/span><\/p>\n<ul>\n<li>iostat<\/li>\n<li>sar<\/li>\n<li>df<\/li>\n<li>iotop<\/li>\n<\/ul>\n<h5>\u56db\u3001\u7f51\u7edc\u72b6\u51b5\uff08\u7f51\u7edcI\/O\uff09<\/h5>\n<p>\u5982\u4f55\u5224\u65ad\u7f51\u7edc\u72b6\u6001\u662f\u5426\u826f\u597d\u8fd9\u4e2a\u6682\u65f6\u8fd8\u771f\u4e0d\u6e05\u695ao(\u256f\u25a1\u2570)o<\/p>\n<h6>\u5e38\u7528\u76d1\u63a7\u5de5\u5177\/\u547d\u4ee4\uff1a<\/h6>\n<ul>\n<li>iftop<\/li>\n<li>nload<\/li>\n<li>iptraf<\/li>\n<li>nethogs<\/li>\n<li>netstat<\/li>\n<li>sar<\/li>\n<li>dstat<\/li>\n<li>tcpdump<\/li>\n<li>mtr<\/li>\n<\/ul>\n<h5>\u4e94\u3001\u5176\u5b83<\/h5>\n<p>\u6587\u4ef6\u3001\u8fdb\u7a0b\u3001\u7aef\u53e3\u7b49\u7684\u4f7f\u7528\u60c5\u51b5\uff08\u7b2c5\u90e8\u5206\u7684\u5185\u5bb9\u5176\u5b9e\u548c\u4e0a\u9762\u76844\u4e2a\u5206\u7c7b\u6709\u91cd\u53e0\uff0c\u4e5f\u53ef\u4ee5\u7b97\u662f\u4e0a\u97624\u4e2a\u5206\u7c7b\u7684\u4e00\u79cd\u5fae\u89c2\u8868\u73b0\u5427\uff09<\/p>\n<ul>\n<li>lsof<\/li>\n<li>htop<\/li>\n<li>w<\/li>\n<li>vnstat<\/li>\n<li>ps<\/li>\n<li>pgrep<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h6>\u53c2\u8003\/\u6269\u5c55\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.geek521.com\/?p=5754\" target=\"_blank\">linux \u7cfb\u7edf\u6027\u80fd\u6307\u6807<\/a><\/li>\n<li><a href=\"http:\/\/www.binarytides.com\/linux-commands-monitor-network\/\" target=\"_blank\">18 commands to monitor network bandwidth on Linux server<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/tang08\/article\/details\/1775717\" target=\"_blank\">Linux\u7cfb\u7edf\u6027\u80fd\u76d1\u63a7\u8be6\u89e3<\/a><\/li>\n<li><a href=\"http:\/\/www.cyberciti.biz\/tips\/top-linux-monitoring-tools.html\" target=\"_blank\">20 Linux System Monitoring Tools Every SysAdmin Should Know<\/a><\/li>\n<li><a href=\"http:\/\/www.tecmint.com\/command-line-tools-to-monitor-linux-performance\/\" target=\"_blank\">20 Command Line Tools to Monitor Linux Performance<\/a><\/li>\n<li><a href=\"http:\/\/coolshell.cn\/articles\/7490.html\" target=\"_blank\">\u6027\u80fd\u8c03\u4f18\u653b\u7565<\/a><\/li>\n<li><a href=\"http:\/\/coolshell.cn\/articles\/7829.html\" target=\"_blank\">28\u4e2aUnix\/Linux\u7684\u547d\u4ee4\u884c\u795e\u5668<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/rsun1\/article\/details\/8918475\" target=\"_blank\">Linux\u7cfb\u7edf\u76d1\u63a7<\/a><\/li>\n<li><a href=\"http:\/\/blog.fulin.org\/2011\/07\/linux_server_performace_estimate.html\" target=\"_blank\">Linux\u670d\u52a1\u5668\u6027\u80fd\u8bc4\u4f30<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u88ab\u95ee\u5230\u8fc7\u7684\u4e00\u4e2a\u95ee\u9898\uff0c\u4e5f\u80fd\u591f\u7b54\u4e0a\u6765\u4e00\u4e9b\uff0c\u4f46\u53ef\u80fd\u56e0\u4e3a\u6ca1\u6709\u63a5\u89e6\u8fc7\u771f\u5b9e\u7684\u7ebf\u4e0a\u751f\u4ea7\u73af\u5883\uff0c\u53ea\u662f\u81ea\u5df1\u5728\u81ea\u5df1\u7684\u865a\u62df\u673a\/VP [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11],"tags":[226,295,227,296,297,229],"class_list":["post-870","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","tag-dstat","tag-free","tag-iostat","tag-ps","tag-top","tag-vmstat"],"views":6455,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=870"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/870\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}