{"id":1974,"date":"2010-05-18T20:49:19","date_gmt":"2010-05-18T12:49:19","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=1974"},"modified":"2010-05-18T20:49:53","modified_gmt":"2010-05-18T12:49:53","slug":"how-to-kill-an-uninterruptible-sleep-process","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2010\/05\/how-to-kill-an-uninterruptible-sleep-process\/","title":{"rendered":"How to kill an `uninterruptible sleep` process"},"content":{"rendered":"<p>\u5f88\u65e9\u4e4b\u524d\u5c31\u9047\u5230\u4e00\u6b21\u8fd9\u4e2a\u6545\u969c\uff0c\u5f53\u65f6\u662f\u4e00\u53f0\u4e3b\u673a\u6545\u969c\uff0c\u8fd9\u6b21\u662f\u4e0a\u767e\u53f0\u4e3b\u673a\u6545\u969c\u3002\u5f53\u65f6\u662f\u4f7f\u7528mysqldump\u5411NFS\u5907\u4efd\u65f6\uff0c\u5199\u6570\u636e\u65f6\u5927\u6982\u662fNFS\u51fa\u73b0\u6545\u969c\uff0c\u4f7f\u5f97mysqldump\u8fdb\u7a0b\u8fdb\u5165uninterruptible sleep\uff08man ps\uff09\u72b6\u6001\uff1a<\/p>\n<div class=\"mycode\">$ps axu|grep mysqldump<br \/>\nmysql     2718  0.0  0.0 51088  672 pts\/0    S+   13:30   0:00 grep mysqldump<br \/>\nmysql    14916  1.4  0.0     0    0 ?        D    02:03  10:03 [mysqldump]<\/div>\n<p>\u8fdb\u5165\u8be5\u72b6\u6001\u7684\u8fdb\u7a0b\uff0c\u4f1a\u4e00\u76f4\u7b49\u5f85NFS\uff0c\u4e0d\u63a5\u53d7\u4efb\u4f55\u4fe1\u53f7\uff0c\u5f53\u7136\u4e5f\u5c31\u65e0\u6cd5\u88ab\u6740\u6b7b\uff08kill\/fuser -k\uff09\u3002\u56e0\u4e3a\u8fdb\u7a0b\u4e00\u76f4\u5728\u8fd0\u884c\u961f\u5217\uff08running queue\uff09\u4e2d\uff0c\u6240\u4ee5\u8fd8\u4f1a\u5bfc\u81f4\u4e3b\u673a\u7684Load\u4e0a\u5347\uff08\u867d\u7136\u4e3b\u673a\u5e76\u4e0d\u7e41\u5fd9\uff09\u3002\u5982\u679c\u7531\u4e8e\u8fd9\u4e2a\u539f\u56e0\u88ab\u5361\u4f4f\u7684\u8fdb\u7a0b\u5f88\u591a\u7684\u8bdd\uff0c\u4e3b\u673a\u7684Load\u53ef\u80fd\u4f1a<strong>\u770b\u8d77\u6765<\/strong>\u975e\u5e38\u9ad8\u3002<!--more--><\/p>\n<p>\u4e0a\u6b21\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\u65f6\u53ea\u6709\u4e00\u53f0\u4e3b\u673a\u51fa\u4e86\u8fd9\u4e2a\u75c7\u72b6\uff0c\u5f53\u65f6Google\u540e\u4e5f\u6ce8\u610f\u5230\u5f88\u591a\u4eba\u6709\u9047\u5230\u4e86<a href=\"http:\/\/www.google.com\/search?hl=en&#038;q=NFS+uninterruptible&#038;btnG=Search&#038;aq=f&#038;aqi=&#038;aql=&#038;oq=&#038;gs_rfai=\">\u7c7b\u4f3c\u7684\u95ee\u9898<\/a>\uff0c\u5e76\u4e14\u90fd\u675f\u624b\u65e0\u7b56(<a href=\"http:\/\/linuxgazette.net\/issue83\/tag\/6.html\">There are some things even root can&#8217;t do<\/a>)\u3002Google\u540e\uff0c\u518d\u5c1d\u8bd5\u627e\u4e86\u4e00\u4e9bLinux\u539f\u7406\u65b9\u9762\u7684\u4ecb\u7ecd\uff0c\u4f9d\u7136\u65e0\u89e3\u3002<\/p>\n<p>\u89e3\u51b3\u7684\u7ec8\u6781\u529e\u6cd5\u662f\u91cd\u542f\u4e3b\u673a\uff08reboot\uff09\uff0c\u6240\u4ee5\u51b3\u5b9a\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\uff08\u4e4b\u524d\u9047\u5230\u8fc7\u4e00\u4e9b\u50f5\u6b7b\u8fdb\u7a0bZ\uff0c\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u540e\u4e5f\u6d88\u5931\u4e86\uff09\uff0c\u5b9e\u5728\u4e0d\u884c\u5c31\u62e9\u673a\u91cd\u542f\u4e3b\u673a\u3002\u4e0d\u8fc7\u5947\u602a\u7684\u662f\uff0c\u7b49\u4e86\u51e0\u5929\u8fc7\u540e\uff0c\u8fd9\u4e2a\u8fdb\u7a0b\u786e\u5b9e\u6d88\u5931\u4e86\uff08\u6b63\u5e38\u7ed3\u675f\u4e86\uff1f\u5e94\u8be5\u662f\uff09\u3002<\/p>\n<p><font color=\"red\">1. Why is Linux so &#8220;stupid&#8221;?<\/font><\/p>\n<p>\u6709\u4eba\u5c31\u95ee\uff0cLinux\u8bbe\u8ba1\u662f\u4e0d\u662f\u6709\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u4f1a\u6709\u4e00\u4e9b\u8fdb\u7a0broot\u4e5f\u65e0\u6cd5\u6740\u6b7b\u5462\uff1f<\/p>\n<p>jra\u5728<a href=\"http:\/\/linuxgazette.net\/issue83\/tag\/6.html\">How to kill a process in uninterruptible sleep state<\/a>\u4e2d\u7ed9\u4e86\u4e00\u4e2a\u89e3\u91ca\uff1a<\/p>\n<pre><div class=\"mycode\">    There's fairly extensive discussion of this in a couple of the kernel \r\ndesign books, and I think in Nemeth, Snyder and Seebass: the problem stems \r\nfrom the fact that there are two types of device drivers -- those \r\nfor \"fast\" devices and those for \"slow\" devices\uff1a\r\n\r\n    Slow-device drivers -- for things like terminals, and such -- are \r\n                usually split in two pieces, and can therefore be \r\n                interrupted while they're in the middle of something.\r\n\r\n    Fast-device drivers -- which service things like hard drives and (I \r\n                think) ethernet cards -- are designed to expect that\r\n                when they call out to hardware, it will respond  instantly \r\n                (in human terms), and that they won't have to wait \r\n                on anything. Such drivers have, as a rule, proven \r\n                extremely intolerant of hardware trouble -- if your hard\r\n                drive start having to do hardware retries to read a \r\n                sector, your system perfromance is going int he toilet, \r\n                even if you have more than one drive...<\/div><\/pre>\n<p>\u5927\u6982\u610f\u601d\u662f\u8bf4\uff0cLinux\u4e2d\u8bbe\u5907\u9a71\u52a8\u7a0b\u5e8f\u53ef\u4ee5\u5206\u4e3a\u201cslow device\u201d\u548c\u201cfast device\u201d\u4e24\u7c7b\u3002\u78c1\u76d8\u5c5e\u4e8e\u201cfast device\u201d\uff08\u5982\u679c\u5f53\u4f5c\u201cslow device\u201d\u5904\u7406\u6548\u7387\u4f1a\u5f88\u4f4e\uff09\uff0c\u5728\u8fd9\u7c7b\u8bbe\u5907\u4e0a\u64cd\u4f5c\u65f6\u4f1a\u4ee5uninterruptible\u7684\u65b9\u5f0f\u8fdb\u884c\u3002<\/p>\n<p><font color=\"red\">2. \u771f\u7684\u6ca1\u529e\u6cd5\u5417?<\/font><\/p>\n<p>\u7406\u8bba\u4e0a\uff0c\u9664\u4e86\u91cd\u542f\u4e3b\u673a\uff0c\u8c8c\u4f3c\u6ca1\u4ec0\u4e48\u529e\u6cd5\u4e86\u3002\u4e0d\u8fc7\uff0c\u6839\u636e\u5b9e\u9645\u7ecf\u9a8c\u548c\u8fd0\u6c14\uff0c\u4e5f\u8fd8\u662f\u6709\u4e00\u4e9b\u529e\u6cd5\u53ef\u4ee5\u5c1d\u8bd5\u7684\u3002<\/p>\n<p><font color=\"blue\">\u529e\u6cd51\uff1aumount -f<\/font><\/p>\n<p>\u5982\u679c\u662f\u7531\u4e8eNFS\u6545\u969c\u5bfc\u81f4\u7684\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u5148umount\/mount\u91cd\u65b0\u6302\u8f7dNFS\u3002\u5982\u679cNFS\u65e0\u6cd5\u5378\u8f7d\uff08\u5982\u679c\u9047\u5230\u4e0a\u8ff0\u60c5\u51b5\uff0c\u516b\u6210\u662f\u8fd9\u6837\uff09\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 -f \u53c2\u6570\u5378\u8f7d\u3002\u6700\u8fd1\u4e00\u6b21\u9047\u5230\u8fd9\u4e2a\u6545\u969c\uff0c\u6709\u63a5\u8fd1\u4e0a\u767e\u53f0\u4e3b\u673a\u51fa\u73b0\u8fd9\u4e2a\u6545\u969c\uff0c\u5c31\u662f\u4f7f\u7528umount -f\u6210\u529f\u5378\u8f7dNFS\u540e\uff0c\u76f8\u5173uninterruptible\u7684\u8fdb\u7a0b\u4e5f\u90fd\u968f\u4e4b\u6b63\u5e38\u7ed3\u675f\u3002\u5f53\u65f6\u53d1\u73b0\uff0c\u8fde\u7eed\u91cd\u8bd5\u591a\u6b21 umount -f \u624d\u884c\uff1a<\/p>\n<div class=\"mycode\">root>#umount -f \/nfsdir<br \/>\numount2: Device or resource busy<br \/>\numount: \/nfsdir: device is busy<br \/>\nroot>#umount -f \/nfsdir<br \/>\numount2: Device or resource busy<br \/>\numount: \/nfsdir: device is busy<\/div>\n<p><font color=\"blue\">\u529e\u6cd52\uff1a\u7b49<\/font><\/p>\n<p>\u6700\u65e9mysqldump\u9047\u5230\u8fd9\u4e2a\u95ee\u9898\u65f6\uff0c\u675f\u624b\u65e0\u7b56\u540e\uff0c\u5c31\u7b49\u4e86\u51e0\u5929\uff0c\u53d1\u73b0\u8fdb\u7a0b\u786e\u5b9e\u7ed3\u675f\u4e86\u3002\u6240\u4ee5\u5982\u679c\u60c5\u51b5\u4e0d\u662f\u5f88\u7d27\u6025\uff0c\u201c\u7b49\u201d\u4e5f\u662f\u4e00\u4e2a\u529e\u6cd5\u3002<\/p>\n<p>\u9047\u5230\u7684\u50f5\u6b7b\u8fdb\u7a0b\u8fd9\u4e2a\u529e\u6cd5\u4e5f\u53ef\u80fd\u6709\u6548\u3002<\/p>\n<p><font color=\"blue\">\u529e\u6cd53\uff1akillall -KILL rpciod<\/font><\/p>\n<p>\u5728<a href=\"http:\/\/bbs.unixall.com\/thread-441-1-1.html\">\u4e00\u7bc7\u6587\u7ae0<\/a>\u4e2d\uff0c\u8fd8\u63d0\u5230\uff0c\u8fdb\u7a0b\u5904\u4e8euninterruptible sleep(\u5373ps\u7684D\u72b6\u6001)\uff0c\u8fdb\u7a0b\u5904\u4e8erpc_execute\u8c03\u7528\u72b6\u6001\uff0c\u800crpc_execute\u8c03\u7528\u662f\u7531rpciod\u63d0\u4f9b\uff0c\u6240\u4ee5\u53ef\u4ee5\u901a\u8fc7\u6740\u6b7brpciod\u6765\u89e3\u51b3\u95ee\u9898\u3002\uff08rpciod\u88ab\u6740\u6b7b\u540e\u4f1a\u81ea\u52a8\u91cd\u542f\u8fc7\u6765\uff09\u3010\u6ca1\u6709\u5b9e\u9a8c\u8fc7\uff0c\u614e\u7528\uff0c\u5e0c\u671b\u6709\u7ecf\u9a8c\u8005\u5206\u4eab\u4e00\u4e0b\u3011<\/p>\n<p><font color=\"blue\">\u529e\u6cd54\uff1areboot<\/font><\/p>\n<p>\u5b9e\u5728\u4e0d\u884c\uff0c\u5c31\u53ea\u80fdreboot\u4e86\u3002\u8fd9\u662f\u6700\u4e0d\u63a8\u8350\u7684\u505a\u6cd5\uff0c\u6bd5\u7adf\u6bcf\u6b21\u9047\u5230\u90fdreboot\uff0c\u4ee3\u4ef7\u8fd8\u662f\u6bd4\u8f83\u5927\uff0c\u7279\u522b\u662f\u5f53\u4f60\u5728\u8ffd\u6c42HA\u7684\u65f6\u5019\u3002<\/p>\n<p><font color=\"red\">3. \u80fd\u591f\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u5417?<\/font><\/p>\n<p>\u5728RTFM\u4e4b\u540e\uff0c\u53d1\u73b0\u53ef\u4ee5\u901a\u8fc7\u6302\u8f7dNFS\u65f6\u6307\u5b9a\u4e00\u4e9b\u53c2\u6570\uff0c\u5c3d\u53ef\u80fd\u7684\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff1a<\/p>\n<pre><div class=\"mycode\">     soft       If an NFS file operation has a major timeout then report\r\n                 an I\/O error to the calling program.  The default is  to\r\n                 continue retrying NFS file operations indefinitely.\r\n\r\n      hard       If an NFS file operation has a major timeout then report\r\n                 \"server not responding\"  on  the  console  and  continue\r\n                 retrying indefinitely.  This is the default.\r\n\r\n      intr       If  an  NFS file operation has a major timeout and it is\r\n                 hard mounted, then allow signals to  interupt  the  file\r\n                 operation  and  cause  it to return EINTR to the calling\r\n                 program.  The default is to not allow file operations to\r\n                 be interrupted.<\/div><\/pre>\n<p>\u4e0a\u97623\u4e2a\u53c2\u6570\uff0c\u5176\u4e2dhard\u662f\u9ed8\u8ba4\u7684\u3002\u6211\u4eec\u901a\u8fc7\u65ad\u5f00\u7f51\u7edc\u6a21\u62dfNFS\u6545\u969c\uff0c\u6d4b\u8bd5\u4e86 intr \u9009\u9879\uff0c\u53d1\u73b0\u80fd\u591f\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u907f\u514d\u4e0a\u8ff0\u7684\u60c5\u51b5\u3002\u5728\u6d4b\u8bd5 soft \u9009\u9879\u65f6\uff0c\u5e76\u6ca1\u6709\u4e0a\u9762\u63cf\u8ff0\u7684\u90a3\u4e48\u597d\u7528\uff0c\u5728\u5b9e\u9a8c\u4e2d\uff0c\u4f7f\u7528 soft \u6302\u8f7d\u662f\u73b0\u8c61\u548c hard \u7c7b\u4f3c\uff08\u4e0d\u77e5\u9053\u6211\u662f\u4e0d\u662f\u5ffd\u7565\u54ea\u4e9b\u7ec6\u8282\u4e86\uff09\u3002<\/p>\n<p>\u5982\u679c\u4f60\u88ab\u8fd9\u4e2a\u95ee\u9898\u56f0\u6270\uff0c\u53ef\u4ee5\u8bd5\u8bd5\u4f7f\u7528intr\u53c2\u6570\u6302\u8f7dNFS\uff1a<\/p>\n<div class=\"mycode\">mount -o intr 172.23.119.25:\/nfs \/nfsdir<\/div>\n<p><font color=\"red\">\u53c2\u8003\u6587\u732e<\/font><br \/>\n[1]. Linux Man<br \/>\n[2]. <a href=\"http:\/\/linuxgazette.net\/issue83\/tag\/6.html\">How to kill a process in uninterruptible sleep state<\/a><br \/>\n[3]. <a href=\"http:\/\/kerneltrap.org\/Linux\/Killing_Tasks_On_Frozen_NFS_Mounts\">Linux: Killing Tasks On Frozen NFS Mounts<\/a><br \/>\n[4]. <a href=\"http:\/\/hychen.wuweig.org\/?p=30728\">How to kill a process in uninterruptible sleep state<\/a><br \/>\n[5]. <a href=\"http:\/\/bbs.unixall.com\/thread-441-1-1.html\">\u5982\u4f55\u6740\u6389\u7531NFS\u9020\u6210Uninterruptible\u7684\u8fdb\u7a0b<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u65e9\u4e4b\u524d\u5c31\u9047\u5230\u4e00\u6b21\u8fd9\u4e2a\u6545\u969c\uff0c\u5f53\u65f6\u662f\u4e00\u53f0\u4e3b\u673a\u6545\u969c\uff0c\u8fd9\u6b21\u662f\u4e0a\u767e\u53f0\u4e3b\u673a\u6545\u969c\u3002\u5f53\u65f6\u662f\u4f7f\u7528mysqldump\u5411NFS\u5907\u4efd\u65f6\uff0c\u5199\u6570\u636e\u65f6\u5927\u6982\u662fNFS\u51fa\u73b0\u6545\u969c\uff0c\u4f7f\u5f97mysqldump\u8fdb\u7a0b\u8fdb\u5165uninterruptible sleep\uff08man ps\uff09\u72b6\u6001\uff1a $ps axu|grep mysqldump mysql 2718 0.0 0.0 51088 672 pts\/0 S+ 13:30 0:00 grep mysqldump mysql 14916 1.4 0.0 0 0 ? D 02:03 10:03 [mysqldump] \u8fdb\u5165\u8be5\u72b6\u6001\u7684\u8fdb\u7a0b\uff0c\u4f1a\u4e00\u76f4\u7b49\u5f85NFS\uff0c\u4e0d\u63a5\u53d7\u4efb\u4f55\u4fe1\u53f7\uff0c\u5f53\u7136\u4e5f\u5c31\u65e0\u6cd5\u88ab\u6740\u6b7b\uff08kill\/fuser -k\uff09\u3002\u56e0\u4e3a\u8fdb\u7a0b\u4e00\u76f4\u5728\u8fd0\u884c\u961f\u5217\uff08running queue\uff09\u4e2d\uff0c\u6240\u4ee5\u8fd8\u4f1a\u5bfc\u81f4\u4e3b\u673a\u7684Load\u4e0a\u5347\uff08\u867d\u7136\u4e3b\u673a\u5e76\u4e0d\u7e41\u5fd9\uff09\u3002\u5982\u679c\u7531\u4e8e\u8fd9\u4e2a\u539f\u56e0\u88ab\u5361\u4f4f\u7684\u8fdb\u7a0b\u5f88\u591a\u7684\u8bdd\uff0c\u4e3b\u673a\u7684Load\u53ef\u80fd\u4f1a\u770b\u8d77\u6765\u975e\u5e38\u9ad8\u3002<\/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":[27],"tags":[121],"class_list":["post-1974","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1974","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=1974"}],"version-history":[{"count":26,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1974\/revisions"}],"predecessor-version":[{"id":2041,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1974\/revisions\/2041"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=1974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=1974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=1974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}