{"id":73,"date":"2025-01-22T20:16:08","date_gmt":"2025-01-22T12:16:08","guid":{"rendered":"https:\/\/www.handytoo.com\/?p=73"},"modified":"2025-01-22T20:16:30","modified_gmt":"2025-01-22T12:16:30","slug":"linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%80%a7%e8%83%bd%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"http:\/\/www.handytoo.com\/?p=73","title":{"rendered":"Linux\u670d\u52a1\u5668\u6027\u80fd\u5206\u6790"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u5f71\u54cdLinux\u670d\u52a1\u5668\u6027\u80fd\u7684\u56e0\u7d20<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u64cd\u4f5c\u7cfb\u7edf\u7ea7<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>CPU<\/li>\n\n\n\n<li>\u5185\u5b58<\/li>\n\n\n\n<li>\u78c1\u76d8I\/O\u5e26\u5bbd<\/li>\n\n\n\n<li>\u7f51\u7edcI\/O\u5e26\u5bbd<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a0b\u5e8f\u5e94\u7528\u7ea7<\/h3>\n\n\n\n<h2 class=\"wp-block-heading\">\u7cfb\u7edf\u6027\u80fd\u8bc4\u4f30\u6807\u51c6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f71\u54cd\u6027\u80fd\u56e0\u7d20<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u8bc4\u5224\u6807\u51c6<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\u597d \n\u574f\n\u7cdf\u7cd5\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">CPU<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>user% + sys%&lt; 70%\nuser% + sys%= 85%\nuser% + sys% >=90% \n%user\uff1a\u8868\u793aCPU\u5904\u5728\u7528\u6237\u6a21\u5f0f\u4e0b\u7684\u65f6\u95f4\u767e\u5206\u6bd4\u3002\n%sys\uff1a\u8868\u793aCPU\u5904\u5728\u7cfb\u7edf\u6a21\u5f0f\u4e0b\u7684\u65f6\u95f4\u767e\u5206\u6bd4\u3002<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u5185\u5b58<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>Swap In\uff08si\uff09\uff1d0\nSwap Out\uff08so\uff09\uff1d0\nPer CPU with 10 page\/s\nMore Swap In &amp; Swap Out\nswap in\uff1a\u5373si\uff0c\u8868\u793a\u865a\u62df\u5185\u5b58\u7684\u9875\u5bfc\u5165\uff0c\u5373\u4eceSWAP DISK\u4ea4\u6362\u5230RAM\nswap out\uff1a\u5373so\uff0c\u8868\u793a\u865a\u62df\u5185\u5b58\u7684\u9875\u5bfc\u51fa\uff0c\u5373\u4eceRAM\u4ea4\u6362\u5230SWAP DISK\u3002<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u78c1\u76d8<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>iowait&nbsp;% &lt; 20%\niowait&nbsp;% =35%\niowait&nbsp;% &gt;= 50%\n<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">%iowait\uff1a\u8868\u793aCPU\u7b49\u5f85\u8f93\u5165\u8f93\u51fa\u5b8c\u6210\u65f6\u95f4\u7684\u767e\u5206\u6bd4\u3002<br><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7cfb\u7edf\u6027\u80fd\u5206\u6790\u5de5\u5177<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u7528\u7cfb\u7edf\u547d\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">Vmstat\u3001sar\u3001iostat\u3001netstat\u3001free\u3001ps\u3001top\u7b49\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u7528\u7ec4\u5408\u65b9\u5f0f<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u7528vmstat\u3001sar\u3001iostat\u68c0\u6d4b\u662f\u5426\u662fCPU\u74f6\u9888<\/li>\n\n\n\n<li>\u7528free\u3001vmstat\u68c0\u6d4b\u662f\u5426\u662f\u5185\u5b58\u74f6\u9888<\/li>\n\n\n\n<li>\u7528iostat\u68c0\u6d4b\u662f\u5426\u662f\u78c1\u76d8I\/O\u74f6\u9888<\/li>\n\n\n\n<li>\u7528netstat\u68c0\u6d4b\u662f\u5426\u662f\u7f51\u7edc\u5e26\u5bbd\u74f6\u9888<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Linux\u6027\u80fd\u8bc4\u4f30\u4e0e\u4f18\u5316<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u7cfb\u7edf\u6574\u4f53\u6027\u80fd\u8bc4\u4f30\uff08uptime\u547d\u4ee4\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web1 ~]# uptime \n16:38:00 up 118 days,  3:01,  5 users,  load average: 1.22, 1.02, 0.91 \n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1aload average\u8fd9\u4e2a\u8f93\u51fa\u503c\uff0c\u8fd9\u4e09\u4e2a\u503c\u7684\u5927\u5c0f\u4e00\u822c\u4e0d\u80fd\u5927\u4e8e\u7cfb\u7edfCPU\u7684\u4e2a\u6570\uff0c\u4f8b\u5982\uff0c\u672c\u8f93\u51fa\u4e2d\u7cfb\u7edf\u67098\u4e2aCPU,\u5982\u679cload average\u7684\u4e09\u4e2a\u503c\u957f\u671f\u5927\u4e8e8\u65f6\uff0c\u8bf4\u660eCPU\u5f88\u7e41\u5fd9\uff0c\u8d1f\u8f7d\u5f88\u9ad8\uff0c\u53ef\u80fd\u4f1a\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\uff0c\u4f46\u662f\u5076\u5c14\u5927\u4e8e8\u65f6\uff0c\u5012\u4e0d\u7528\u62c5\u5fc3\uff0c\u4e00\u822c\u4e0d\u4f1a\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\u3002\u76f8\u53cd\uff0c\u5982\u679cload average\u7684\u8f93\u51fa\u503c\u5c0f\u4e8eCPU\u7684\u4e2a\u6570\uff0c\u5219\u8868\u793aCPU\u8fd8\u6709\u7a7a\u95f2\u7684\u65f6\u95f4\u7247\uff0c\u6bd4\u5982\u672c\u4f8b\u4e2d\u7684\u8f93\u51fa\uff0cCPU\u662f\u975e\u5e38\u7a7a\u95f2\u7684\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CPU\u6027\u80fd\u8bc4\u4f30<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5229\u7528vmstat\u547d\u4ee4\u76d1\u63a7\u7cfb\u7edfCPU<\/h4>\n\n\n\n<p>\u8be5\u547d\u4ee4\u53ef\u4ee5\u663e\u793a\u5173\u4e8e\u7cfb\u7edf\u5404\u79cd\u8d44\u6e90\u4e4b\u95f4\u76f8\u5173\u6027\u80fd\u7684\u7b80\u8981\u4fe1\u606f\uff0c\u8fd9\u91cc\u6211\u4eec\u4e3b\u8981\u7528\u5b83\u6765\u770bCPU\u4e00\u4e2a\u8d1f\u8f7d\u60c5\u51b5\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662fvmstat\u547d\u4ee4\u5728\u67d0\u4e2a\u7cfb\u7edf\u7684\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@node1 ~]# vmstat 2 3 \nprocs -----------memory----------  ---swap--  -----io---- --system--  -----cpu------ \nr  b   swpd   free      buff  cache   si   so    bi    bo       in     cs     us sy  id   wa st \n0  0    0    162240   8304  67032   0    0    13    21   1007   23     0  1   98   0   0 \n0  0    0    162240   8304  67032   0    0     1     0     1010   20     0  1   100 0   0 \n0  0    0    162240   8304  67032   0    0     1     1     1009   18     0  1    99  0   0 \nl        Procs \n<\/code><\/pre>\n\n\n\n<p>r\u5217\u8868\u793a\u8fd0\u884c\u548c\u7b49\u5f85cpu\u65f6\u95f4\u7247\u7684\u8fdb\u7a0b\u6570\uff0c\u8fd9\u4e2a\u503c\u5982\u679c\u957f\u671f\u5927\u4e8e\u7cfb\u7edfCPU\u7684\u4e2a\u6570\uff0c\u8bf4\u660eCPU\u4e0d\u8db3\uff0c\u9700\u8981\u589e\u52a0CPU\u3002<\/p>\n\n\n\n<p>b\u5217\u8868\u793a\u5728\u7b49\u5f85\u8d44\u6e90\u7684\u8fdb\u7a0b\u6570\uff0c\u6bd4\u5982\u6b63\u5728\u7b49\u5f85I\/O\u3001\u6216\u8005\u5185\u5b58\u4ea4\u6362\u7b49\u3002<\/p>\n\n\n\n<p>Cpu<\/p>\n\n\n\n<p>us\u5217\u663e\u793a\u4e86\u7528\u6237\u8fdb\u7a0b\u6d88\u8017\u7684CPU \u65f6\u95f4\u767e\u5206\u6bd4\u3002us\u7684\u503c\u6bd4\u8f83\u9ad8\u65f6\uff0c\u8bf4\u660e\u7528\u6237\u8fdb\u7a0b\u6d88\u8017\u7684cpu\u65f6\u95f4\u591a\uff0c\u4f46\u662f\u5982\u679c\u957f\u671f\u5927\u4e8e50%\uff0c\u5c31\u9700\u8981\u8003\u8651\u4f18\u5316\u7a0b\u5e8f\u6216\u7b97\u6cd5\u3002<\/p>\n\n\n\n<p>sy\u5217\u663e\u793a\u4e86\u5185\u6838\u8fdb\u7a0b\u6d88\u8017\u7684CPU\u65f6\u95f4\u767e\u5206\u6bd4\u3002Sy\u7684\u503c\u8f83\u9ad8\u65f6\uff0c\u8bf4\u660e\u5185\u6838\u6d88\u8017\u7684CPU\u8d44\u6e90\u5f88\u591a\u3002<\/p>\n\n\n\n<p>\u6839\u636e\u7ecf\u9a8c\uff0cus+sy\u7684\u53c2\u8003\u503c\u4e3a80%\uff0c\u5982\u679cus+sy\u5927\u4e8e 80%\u8bf4\u660e\u53ef\u80fd\u5b58\u5728CPU\u8d44\u6e90\u4e0d\u8db3\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5229\u7528sar\u547d\u4ee4\u76d1\u63a7\u7cfb\u7edfCPU<\/h4>\n\n\n\n<p>sar\u529f\u80fd\u5f88\u5f3a\u5927\uff0c\u53ef\u4ee5\u5bf9\u7cfb\u7edf\u7684\u6bcf\u4e2a\u65b9\u9762\u8fdb\u884c\u5355\u72ec\u7684\u7edf\u8ba1\uff0c\u4f46\u662f\u4f7f\u7528sar\u547d\u4ee4\u4f1a\u589e\u52a0\u7cfb\u7edf\u5f00\u9500\uff0c\u4e0d\u8fc7\u8fd9\u4e9b\u5f00\u9500\u662f\u53ef\u4ee5\u8bc4\u4f30\u7684\uff0c\u5bf9\u7cfb\u7edf\u7684\u7edf\u8ba1\u7ed3\u679c\u4e0d\u4f1a\u6709\u5f88\u5927\u5f71\u54cd\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662fsar\u547d\u4ee4\u5bf9\u67d0\u4e2a\u7cfb\u7edf\u7684CPU\u7edf\u8ba1\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@webserver ~]# sar -u 3 5\nLinux 2.6.9-42.ELsmp (webserver)        11\/28\/2008      _i686_  (8 CPU)\n11:41:24 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle\n11:41:27 AM     all      0.88      0.00      0.29      0.00      0.00     98.83\n11:41:30 AM     all      0.13      0.00      0.17      0.21      0.00     99.50\n11:41:33 AM     all      0.04      0.00      0.04      0.00      0.00     99.92\n11:41:36 AM     all      90.08     0.00      0.13      0.16      0.00     9.63\n11:41:39 AM     all      0.38      0.00      0.17      0.04      0.00     99.41\nAverage:        all      0.34      0.00      0.16      0.05      0.00     99.45\n      \n<\/code><\/pre>\n\n\n\n<p>\u5bf9\u4e0a\u9762\u6bcf\u9879\u7684\u8f93\u51fa\u89e3\u91ca\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">%user\u5217\u663e\u793a\u4e86\u7528\u6237\u8fdb\u7a0b\u6d88\u8017\u7684CPU \u65f6\u95f4\u767e\u5206\u6bd4\u3002<br>%nice\u5217\u663e\u793a\u4e86\u8fd0\u884c\u6b63\u5e38\u8fdb\u7a0b\u6240\u6d88\u8017\u7684CPU \u65f6\u95f4\u767e\u5206\u6bd4\u3002<br>%system\u5217\u663e\u793a\u4e86\u7cfb\u7edf\u8fdb\u7a0b\u6d88\u8017\u7684CPU\u65f6\u95f4\u767e\u5206\u6bd4\u3002<br>%iowait\u5217\u663e\u793a\u4e86IO\u7b49\u5f85\u6240\u5360\u7528\u7684CPU\u65f6\u95f4\u767e\u5206\u6bd4<br>%steal\u5217\u663e\u793a\u4e86\u5728\u5185\u5b58\u76f8\u5bf9\u7d27\u5f20\u7684\u73af\u5883\u4e0bpagein\u5f3a\u5236\u5bf9\u4e0d\u540c\u7684\u9875\u9762\u8fdb\u884c\u7684steal\u64cd\u4f5c \u3002<br>%idle\u5217\u663e\u793a\u4e86CPU\u5904\u5728\u7a7a\u95f2\u72b6\u6001\u7684\u65f6\u95f4\u767e\u5206\u6bd4\u3002<br><\/pre>\n\n\n\n<p>\u5728\u4e00\u4e2a\u591aCPU\u7684\u7cfb\u7edf\u4e2d\uff0c\u5982\u679c\u7a0b\u5e8f\u4f7f\u7528\u4e86\u5355\u7ebf\u7a0b\uff0c\u4f1a\u51fa\u73b0\u8fd9\u4e48\u4e00\u4e2a\u73b0\u8c61\uff0cCPU\u7684\u6574\u4f53\u4f7f\u7528\u7387\u4e0d\u9ad8\uff0c\u4f46\u662f\u7cfb\u7edf\u5e94\u7528\u5374\u54cd\u5e94\u7f13\u6162\uff0c\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u7a0b\u5e8f\u4f7f\u7528\u5355\u7ebf\u7a0b\u7684\u539f\u56e0\uff0c\u5355\u7ebf\u7a0b\u53ea\u4f7f\u7528\u4e00\u4e2aCPU\uff0c\u5bfc\u81f4\u8fd9\u4e2aCPU\u5360\u7528\u7387\u4e3a100%\uff0c\u65e0\u6cd5\u5904\u7406\u5176\u5b83\u8bf7\u6c42\uff0c\u800c\u5176\u5b83\u7684CPU\u5374\u95f2\u7f6e\uff0c\u8fd9\u5c31\u5bfc\u81f4\u4e86\u6574\u4f53CPU\u4f7f\u7528\u7387\u4e0d\u9ad8\uff0c\u800c\u5e94\u7528\u7f13\u6162\u73b0\u8c61\u7684\u53d1\u751f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5185\u5b58\u6027\u80fd\u8bc4\u4f30<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5229\u7528free\u6307\u4ee4\u76d1\u63a7\u5185\u5b58<\/h4>\n\n\n\n<p>free\u662f\u76d1\u63a7linux\u5185\u5b58\u4f7f\u7528\u72b6\u51b5\u6700\u5e38\u7528\u7684\u6307\u4ee4\uff0c\u770b\u4e0b\u9762\u7684\u4e00\u4e2a\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@webserver ~]# free  -m \n         total         used       free     shared    buffers     cached \nMem:       8111       7185        926          0        243           6299 \n-\/+ buffers\/cache:     643       7468 \nSwap:       8189          0         8189 \n<\/code><\/pre>\n\n\n\n<p>\u4e00\u822c\u6709\u8fd9\u6837\u4e00\u4e2a\u7ecf\u9a8c\u516c\u5f0f\uff1a\u5e94\u7528\u7a0b\u5e8f\u53ef\u7528\u5185\u5b58\/\u7cfb\u7edf\u7269\u7406\u5185\u5b58&gt;70%\u65f6\uff0c\u8868\u793a\u7cfb\u7edf\u5185\u5b58\u8d44\u6e90\u975e\u5e38\u5145\u8db3\uff0c\u4e0d\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\uff0c\u5e94\u7528\u7a0b\u5e8f\u53ef\u7528\u5185\u5b58\/\u7cfb\u7edf\u7269\u7406\u5185\u5b58&lt;20%\u65f6\uff0c\u8868\u793a\u7cfb\u7edf\u5185\u5b58\u8d44\u6e90\u7d27\u7f3a\uff0c\u9700\u8981\u589e\u52a0\u7cfb\u7edf\u5185\u5b58\uff0c20%&lt;\u5e94\u7528\u7a0b\u5e8f\u53ef\u7528\u5185\u5b58\/\u7cfb\u7edf\u7269\u7406\u5185\u5b58&lt;70%\u65f6\uff0c\u8868\u793a\u7cfb\u7edf\u5185\u5b58\u8d44\u6e90\u57fa\u672c\u80fd\u6ee1\u8db3\u5e94\u7528\u9700\u6c42\uff0c\u6682\u65f6\u4e0d\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5229\u7528vmstat\u547d\u4ee4\u76d1\u63a7\u5185\u5b58<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@node1 ~]# vmstat 2 3 \nprocs -----------memory----------  ---swap--  -----io---- --system--  -----cpu------ \nr  b   swpd   free      buff  cache   si   so    bi    bo       in     cs     us sy  id  wa st \n0  0    0    162240   8304  67032   0    0    13    21   1007   23     0  1  98   0  0 \n0  0    0    162240   8304  67032   0    0     1     0     1010   20     0  1  100 0  0 \n0  0    0    162240   8304  67032   0    0     1     1     1009   18     0  1  99   0  0 \nl        memory \n<\/code><\/pre>\n\n\n\n<p>swpd\u5217\u8868\u793a\u5207\u6362\u5230\u5185\u5b58\u4ea4\u6362\u533a\u7684\u5185\u5b58\u6570\u91cf\uff08\u4ee5k\u4e3a\u5355\u4f4d\uff09\u3002\u5982\u679cswpd\u7684\u503c\u4e0d\u4e3a0\uff0c\u6216\u8005\u6bd4\u8f83\u5927\uff0c\u53ea\u8981si\u3001so\u7684\u503c\u957f\u671f\u4e3a0\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e00\u822c\u4e0d\u7528\u62c5\u5fc3\uff0c\u4e0d\u4f1a\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n\n\n\n<p>free\u5217\u8868\u793a\u5f53\u524d\u7a7a\u95f2\u7684\u7269\u7406\u5185\u5b58\u6570\u91cf\uff08\u4ee5k\u4e3a\u5355\u4f4d\uff09<\/p>\n\n\n\n<p>buff\u5217\u8868\u793abuffers cache\u7684\u5185\u5b58\u6570\u91cf\uff0c\u4e00\u822c\u5bf9\u5757\u8bbe\u5907\u7684\u8bfb\u5199\u624d\u9700\u8981\u7f13\u51b2\u3002<\/p>\n\n\n\n<p>cache\u5217\u8868\u793apage cached\u7684\u5185\u5b58\u6570\u91cf\uff0c\u4e00\u822c\u4f5c\u4e3a\u6587\u4ef6\u7cfb\u7edfcached\uff0c\u9891\u7e41\u8bbf\u95ee\u7684\u6587\u4ef6\u90fd\u4f1a\u88abcached\uff0c\u5982\u679ccache\u503c\u8f83\u5927\uff0c\u8bf4\u660ecached\u7684\u6587\u4ef6\u6570\u8f83\u591a\uff0c\u5982\u679c\u6b64\u65f6IO\u4e2dbi\u6bd4\u8f83\u5c0f\uff0c\u8bf4\u660e\u6587\u4ef6\u7cfb\u7edf\u6548\u7387\u6bd4\u8f83\u597d\u3002<\/p>\n\n\n\n<p>swap<\/p>\n\n\n\n<p>si\u5217\u8868\u793a\u7531\u78c1\u76d8\u8c03\u5165\u5185\u5b58\uff0c\u4e5f\u5c31\u662f\u5185\u5b58\u8fdb\u5165\u5185\u5b58\u4ea4\u6362\u533a\u7684\u6570\u91cf\u3002<\/p>\n\n\n\n<p>so\u5217\u8868\u793a\u7531\u5185\u5b58\u8c03\u5165\u78c1\u76d8\uff0c\u4e5f\u5c31\u662f\u5185\u5b58\u4ea4\u6362\u533a\u8fdb\u5165\u5185\u5b58\u7684\u6570\u91cf\u3002<\/p>\n\n\n\n<p>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0csi\u3001so\u7684\u503c\u90fd\u4e3a0\uff0c\u5982\u679csi\u3001so\u7684\u503c\u957f\u671f\u4e0d\u4e3a0\uff0c\u5219\u8868\u793a\u7cfb\u7edf\u5185\u5b58\u4e0d\u8db3\u3002\u9700\u8981\u589e\u52a0\u7cfb\u7edf\u5185\u5b58\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u78c1\u76d8I\/O\u6027\u80fd\u8bc4\u4f30<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u78c1\u76d8\u5b58\u50a8\u57fa\u7840<\/h3>\n\n\n\n<p>\u719f\u6089RAID\u5b58\u50a8\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u5e94\u7528\u7684\u4e0d\u540c\uff0c\u9009\u62e9\u4e0d\u540c\u7684RAID\u65b9\u5f0f\u3002\u5c3d\u53ef\u80fd\u7528\u5185\u5b58\u7684\u8bfb\u5199\u4ee3\u66ff\u76f4\u63a5\u78c1\u76d8I\/O\uff0c\u4f7f\u9891\u7e41\u8bbf\u95ee\u7684\u6587\u4ef6\u6216\u6570\u636e\u653e\u5165\u5185\u5b58\u4e2d\u8fdb\u884c\u64cd\u4f5c\u5904\u7406\uff0c\u56e0\u4e3a\u5185\u5b58\u8bfb\u5199\u64cd\u4f5c\u6bd4\u76f4\u63a5\u78c1\u76d8\u8bfb\u5199\u7684\u6548\u7387\u8981\u9ad8\u5343\u500d\u3002\u5c06\u7ecf\u5e38\u8fdb\u884c\u8bfb\u5199\u7684\u6587\u4ef6\u4e0e\u957f\u671f\u4e0d\u53d8\u7684\u6587\u4ef6\u72ec\u7acb\u51fa\u6765\uff0c\u5206\u522b\u653e\u7f6e\u5230\u4e0d\u540c\u7684\u78c1\u76d8\u8bbe\u5907\u4e0a\u3002\u5bf9\u4e8e\u5199\u64cd\u4f5c\u9891\u7e41\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u88f8\u8bbe\u5907\u4ee3\u66ff\u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528\u88f8\u8bbe\u5907\u7684\u4f18\u70b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6570\u636e\u53ef\u4ee5\u76f4\u63a5\u8bfb\u5199\uff0c\u4e0d\u9700\u8981\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7ea7\u7684\u7f13\u5b58\uff0c\u8282\u7701\u4e86\u5185\u5b58\u8d44\u6e90\uff0c\u907f\u514d\u4e86\u5185\u5b58\u8d44\u6e90\u4e89\u7528\u3002<\/li>\n\n\n\n<li>\u907f\u514d\u4e86\u6587\u4ef6\u7cfb\u7edf\u7ea7\u7684\u7ef4\u62a4\u5f00\u9500\uff0c\u6bd4\u5982\u6587\u4ef6\u7cfb\u7edf\u9700\u8981\u7ef4\u62a4\u8d85\u7ea7\u5757\u3001I-node\u7b49\u3002<\/li>\n\n\n\n<li>\u907f\u514d\u4e86\u64cd\u4f5c\u7cfb\u7edf\u7684cache\u9884\u8bfb\u529f\u80fd\uff0c\u51cf\u5c11\u4e86I\/O\u8bf7\u6c42\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528\u88f8\u8bbe\u5907\u7684\u7f3a\u70b9<\/h4>\n\n\n\n<p>\u6570\u636e\u7ba1\u7406\u3001\u7a7a\u95f4\u7ba1\u7406\u4e0d\u7075\u6d3b\uff0c\u9700\u8981\u5f88\u4e13\u4e1a\u7684\u4eba\u6765\u64cd\u4f5c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5229\u7528iostat\u8bc4\u4f30\u78c1\u76d8\u6027\u80fd<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@webserver ~]#   iostat -d 2 3\nLinux 2.6.9-42.ELsmp (webserver)        12\/01\/2008      _i686_  (8 CPU) \nDevice:         tps   Blk_read\/s   Blk_wrtn\/s   Blk_read      Blk_wrtn \nsda               1.87         2.58       114.12        6479462     286537372 \nDevice:         tps   Blk_read\/s   Blk_wrtn\/s   Blk_read   Blk_wrtn \nsda               0.00         0.00         0.00              0                0 \nDevice:         tps   Blk_read\/s   Blk_wrtn\/s   Blk_read    Blk_wrtn \nsda               1.00         0.00        12.00             0                24 \n<\/code><\/pre>\n\n\n\n<p>\u5bf9\u4e0a\u9762\u6bcf\u9879\u7684\u8f93\u51fa\u89e3\u91ca\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>Blk_read\/s\u8868\u793a\u6bcf\u79d2\u8bfb\u53d6\u7684\u6570\u636e\u5757\u6570\u3002<\/p>\n\n\n\n<p>Blk_wrtn\/s\u8868\u793a\u6bcf\u79d2\u5199\u5165\u7684\u6570\u636e\u5757\u6570\u3002<\/p>\n\n\n\n<p>Blk_read\u8868\u793a\u8bfb\u53d6\u7684\u6240\u6709\u5757\u6570\u3002<\/p>\n\n\n\n<p>Blk_wrtn\u8868\u793a\u5199\u5165\u7684\u6240\u6709\u5757\u6570\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u901a\u8fc7Blk_read\/s\u548cBlk_wrtn\/s\u7684\u503c\u5bf9\u78c1\u76d8\u7684\u8bfb\u5199\u6027\u80fd\u6709\u4e00\u4e2a\u57fa\u672c\u7684\u4e86\u89e3\uff0c\u5982\u679cBlk_wrtn\/s\u503c\u5f88\u5927\uff0c\u8868\u793a\u78c1\u76d8\u7684\u5199\u64cd\u4f5c\u5f88\u9891\u7e41\uff0c\u53ef\u4ee5\u8003\u8651\u4f18\u5316\u78c1\u76d8\u6216\u8005\u4f18\u5316\u7a0b\u5e8f\uff0c\u5982\u679cBlk_read\/s\u503c\u5f88\u5927\uff0c\u8868\u793a\u78c1\u76d8\u76f4\u63a5\u8bfb\u53d6\u64cd\u4f5c\u5f88\u591a\uff0c\u53ef\u4ee5\u5c06\u8bfb\u53d6\u7684\u6570\u636e\u653e\u5165\u5185\u5b58\u4e2d\u8fdb\u884c\u64cd\u4f5c\u3002\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u9009\u9879\u7684\u503c\u6ca1\u6709\u4e00\u4e2a\u56fa\u5b9a\u7684\u5927\u5c0f\uff0c\u6839\u636e\u7cfb\u7edf\u5e94\u7528\u7684\u4e0d\u540c\uff0c\u4f1a\u6709\u4e0d\u540c\u7684\u503c\uff0c\u4f46\u662f\u6709\u4e00\u4e2a\u89c4\u5219\u8fd8\u662f\u53ef\u4ee5\u9075\u5faa\u7684\uff1a\u957f\u671f\u7684\u3001\u8d85\u5927\u7684\u6570\u636e\u8bfb\u5199\uff0c\u80af\u5b9a\u662f\u4e0d\u6b63\u5e38\u7684\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e00\u5b9a\u4f1a\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5229\u7528sar\u8bc4\u4f30\u78c1\u76d8\u6027\u80fd<\/h3>\n\n\n\n<p>\u901a\u8fc7\u201csar \u2013d\u201d\u7ec4\u5408\uff0c\u53ef\u4ee5\u5bf9\u7cfb\u7edf\u7684\u78c1\u76d8IO\u505a\u4e00\u4e2a\u57fa\u672c\u7684\u7edf\u8ba1\uff0c\u8bf7\u770b\u4e0b\u9762\u7684\u4e00\u4e2a\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@webserver ~]# sar -d 2 3 \nLinux 2.6.9-42.ELsmp (webserver)        11\/30\/2008      _i686_  (8 CPU) \n11:09:33 PM  DEV     tps   rd_sec\/s   wr_sec\/s  avgrq-sz  avgqu-sz   await  svctm   %util \n11:09:35 PM dev8-0  0.00  0.00            0.00        0.00          0.00         0.00   0.00     0.00 \n11:09:35 PM  DEV     tps  rd_sec\/s    wr_sec\/s  avgrq-sz  avgqu-sz  await   svctm   %util \n11:09:37 PM dev8-0  1.00  0.00         12.00        12.00         0.00        0.00    0.00     0.00 \n11:09:37 PM   DEV    tps    rd_sec\/s  wr_sec\/s   avgrq-sz  avgqu-sz  await  svctm   %util \n11:09:39 PM dev8-0  1.99   0.00         47.76         24.00       0.00        0.50    0.25     0.05 \nAverage:  DEV          tps    rd_sec\/s   wr_sec\/s  avgrq-sz  avgqu-sz    await  svctm   %util \nAverage:  dev8-0      1.00   0.00          19.97         20.00       0.00         0.33    0.17     0.02 \n<\/code><\/pre>\n\n\n\n<p>\u9700\u8981\u5173\u6ce8\u7684\u51e0\u4e2a\u53c2\u6570\u542b\u4e49\uff1a<\/p>\n\n\n\n<p>await\u8868\u793a\u5e73\u5747\u6bcf\u6b21\u8bbe\u5907I\/O\u64cd\u4f5c\u7684\u7b49\u5f85\u65f6\u95f4\uff08\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\uff09\u3002<\/p>\n\n\n\n<p>svctm\u8868\u793a\u5e73\u5747\u6bcf\u6b21\u8bbe\u5907I\/O\u64cd\u4f5c\u7684\u670d\u52a1\u65f6\u95f4\uff08\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\uff09\u3002<\/p>\n\n\n\n<p>%util\u8868\u793a\u4e00\u79d2\u4e2d\u6709\u767e\u5206\u4e4b\u51e0\u7684\u65f6\u95f4\u7528\u4e8eI\/O\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u5bf9\u4ee5\u78c1\u76d8IO\u6027\u80fd\uff0c\u4e00\u822c\u6709\u5982\u4e0b\u8bc4\u5224\u6807\u51c6\uff1a<\/p>\n\n\n\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0bsvctm\u5e94\u8be5\u662f\u5c0f\u4e8eawait\u503c\u7684\uff0c\u800csvctm\u7684\u5927\u5c0f\u548c\u78c1\u76d8\u6027\u80fd\u6709\u5173\uff0cCPU\u3001\u5185\u5b58\u7684\u8d1f\u8377\u4e5f\u4f1a\u5bf9svctm\u503c\u9020\u6210\u5f71\u54cd\uff0c\u8fc7\u591a\u7684\u8bf7\u6c42\u4e5f\u4f1a\u95f4\u63a5\u7684\u5bfc\u81f4svctm\u503c\u7684\u589e\u52a0\u3002<\/p>\n\n\n\n<p>await\u503c\u7684\u5927\u5c0f\u4e00\u822c\u53d6\u51b3\u4e0esvctm\u7684\u503c\u548cI\/O\u961f\u5217\u957f\u5ea6\u4ee5\u53caI\/O\u8bf7\u6c42\u6a21\u5f0f\uff0c\u5982\u679csvctm\u7684\u503c\u4e0eawait\u5f88\u63a5\u8fd1\uff0c\u8868\u793a\u51e0\u4e4e\u6ca1\u6709I\/O\u7b49\u5f85\uff0c\u78c1\u76d8\u6027\u80fd\u5f88\u597d\uff0c\u5982\u679cawait\u7684\u503c\u8fdc\u9ad8\u4e8esvctm\u7684\u503c\uff0c\u5219\u8868\u793aI\/O\u961f\u5217\u7b49\u5f85\u592a\u957f\uff0c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\u5c06\u53d8\u6162\uff0c\u6b64\u65f6\u53ef\u4ee5\u901a\u8fc7\u66f4\u6362\u66f4\u5feb\u7684\u786c\u76d8\u6765\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n\n\n\n<p>%util\u9879\u7684\u503c\u4e5f\u662f\u8861\u91cf\u78c1\u76d8I\/O\u7684\u4e00\u4e2a\u91cd\u8981\u6307\u6807\uff0c\u5982\u679c%util\u63a5\u8fd1100%\uff0c\u8868\u793a\u78c1\u76d8\u4ea7\u751f\u7684I\/O\u8bf7\u6c42\u592a\u591a\uff0cI\/O\u7cfb\u7edf\u5df2\u7ecf\u6ee1\u8d1f\u8377\u7684\u5728\u5de5\u4f5c\uff0c\u8be5\u78c1\u76d8\u53ef\u80fd\u5b58\u5728\u74f6\u9888\u3002\u957f\u671f\u4e0b\u53bb\uff0c\u52bf\u5fc5\u5f71\u54cd\u7cfb\u7edf\u7684\u6027\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f18\u5316\u7a0b\u5e8f\u6216\u8005\u901a\u8fc7\u66f4\u6362\u66f4\u9ad8\u3001\u66f4\u5feb\u7684\u78c1\u76d8\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f51\u7edc\u6027\u80fd\u8bc4\u4f30<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u901a\u8fc7ping\u547d\u4ee4\u68c0\u6d4b\u7f51\u7edc\u7684\u8fde\u901a\u6027<\/li>\n\n\n\n<li>\u901a\u8fc7netstat \u2013i\u7ec4\u5408\u68c0\u6d4b\u7f51\u7edc\u63a5\u53e3\u72b6\u51b5<\/li>\n\n\n\n<li>\u901a\u8fc7netstat \u2013r\u7ec4\u5408\u68c0\u6d4b\u7cfb\u7edf\u7684\u8def\u7531\u8868\u4fe1\u606f<\/li>\n\n\n\n<li>\u901a\u8fc7sar \u2013n\u7ec4\u5408\u663e\u793a\u7cfb\u7edf\u7684\u7f51\u7edc\u8fd0\u884c\u72b6\u6001<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u5f71\u54cdLinux\u670d\u52a1\u5668\u6027\u80fd\u7684\u56e0\u7d20 \u64cd\u4f5c\u7cfb\u7edf\u7ea7 \u7a0b\u5e8f\u5e94\u7528\u7ea7 \u7cfb\u7edf\u6027\u80fd\u8bc4\u4f30\u6807\u51c6 \u5f71\u54cd\u6027\u80fd\u56e0\u7d20 \u8bc4\u5224\u6807\u51c6 CPU \u5185\u5b58 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[23],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":1,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":74,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions\/74"}],"wp:attachment":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}