{"id":1379,"date":"2008-09-08T23:50:12","date_gmt":"2008-09-08T23:50:12","guid":{"rendered":"http:\/\/www.icocean.com\/blog\/?p=1379"},"modified":"2008-09-08T23:50:58","modified_gmt":"2008-09-08T23:50:58","slug":"%E8%A7%A3%E5%86%B3apache%E5%87%BA%E7%8E%B0%E7%9A%84cpu%E9%AB%98%E5%8D%A0%E7%94%A8%E7%8E%87%E7%9A%84%E9%97%AE%E9%A2%98","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=1379","title":{"rendered":"\u89e3\u51b3Apache\u51fa\u73b0\u7684CPU\u9ad8\u5360\u7528\u7387\u7684\u95ee\u9898"},"content":{"rendered":"<p>\u4f5c\u8005: <a href=\"http:\/\/www.javatang.com\/index.php?s=MaxRequestsPerChild\" target=\"_blank\">Jet Mah from Java\u5802<\/a><\/p>\n<p>\u6240\u8c13Apache\u51fa\u73b0CPU\u9ad8\u5360\u7528\u7387\u5c31\u662f\u6307Apache\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u6301\u7eed\u5360\u7528\u5f88\u9ad8\u7684CPU\u4f7f\u7528\u7387\uff0c\u751a\u81f3\u8fbe\u5230CPU100\uff05\uff0c\u8fd9\u4e2a\u65f6\u5019\u9020\u6210\u7f51\u7ad9\u65e0\u6cd5\u8bbf\u95ee\u3002\u89e3\u51b3\u7684\u65b9\u6cd5\u5c31\u662f\u4ed4\u7ec6\u89c2\u5bdfApache\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u67e5\u9605\u9519\u8bef\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u9488\u5bf9\u51e0\u79cd\u9519\u8bef\u4fe1\u606f\u8fdb\u884c\u5206\u6790\u5e76\u7ed9\u51fa\u89e3\u51b3\u7684\u65b9\u6cd5\uff1a<\/p>\n<p>1. Apache\u4e0eWinSock v2\u76f8\u51b2\u7a81<br \/>Apache\u5b98\u65b9\u63d0\u4f9b\u7684\u624b\u518c\u4e2d\u63d0\u5230\uff0c\u5728Windows\u7cfb\u7edf\u4e0bApache2.x\u4e3a\u4e86\u63d0\u9ad8\u6027\u80fd\u800c\u4f7f\u7528\u4e86Microsoft WinSock v2 API\uff0c\u4f46\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u9632\u706b\u5899\u8f6f\u4ef6\u4f1a\u7834\u574f\u4ed6\u7684\u6b63\u786e\u6027\uff0c\u4ece\u800c\u4f7f\u5f97Apache\u51fa\u73b0\u6b7b\u5faa\u73af\u64cd\u4f5c\u9020\u6210CPU100\uff05\u3002<\/p>\n<p>\u5176\u9519\u8bef\u63d0\u793a\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;[error] (730038)An operation was attempted on something that is not a socket.: winnt_accept: AcceptEx failed. Attempting to recover. <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;[error] (OS 10038) : Child 3356: Encountered too many errors accepting client connections. Possible causes: dynamic address renewal, or incompatible VPN or firewall software. Try using the Win32DisableAcceptEx directive. <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;[warn] (OS 121)\u4fe1\u53f7\u706f\u8d85\u65f6\u65f6\u95f4\u5df2\u5230\u3002 : winnt_accept: Asynchronous AcceptEx failed.<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;[warn] (OS 64)\u6307\u5b9a\u7684\u7f51\u7edc\u540d\u4e0d\u518d\u53ef\u7528\u3002 : winnt_accept: Asynchronous AcceptEx failed.<\/p>\n<p>\u53ef\u4ee5\u4f9d\u6b21\u91c7\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u6765\u89e3\u51b3\u4e0a\u9762\u7684\u95ee\u9898\uff0c\u5982\u679c\u8fdb\u884c\u4e86\u4e00\u6b65\u8fd8\u6709\u95ee\u9898\u5c31\u7ee7\u7eed\u4e0b\u4e00\u6b65\uff1a<\/p>\n<p>1) \u5728httpd.conf\u6587\u4ef6\u4e2d\u4f7f\u7528 Win32DisableAcceptEx \u7981\u6b62Apache\u4f7f\u7528 Microsoft WinSock v2 API \uff1a<!--more--><\/p>\n<p>&nbsp;&nbsp; 1. <IfModule mpm_winnt.c><br \/>&nbsp;&nbsp; 2. Win32DisableAcceptEx # \u7981\u6b62\u4f7f\u7528AcceptEx()<br \/>&nbsp;&nbsp; 3. <\/IfModule><\/p>\n<p>2) \u4f7f\u7528System Repair Engineer(SREng)\u67e5\u770bWinSocket\u4f9b\u5e94\u8005\uff0c\u5982\u679c\u51fa\u73b0\u975eMS\u7684\u964c\u751f\u9879\u5219\u5c06\u5176\u5220\u9664\uff0c\u5e76\u4f7f\u7528\u8f6f\u4ef6\u7684\u201c\u91cd\u7f6eWinSocket\u201d\u6309\u94ae\u8fdb\u884c\u91cd\u7f6e\u3002<\/p>\n<p>3) \u5378\u8f7d\u4e0eApache\u76f8\u51b2\u7a81\u7684\u6740\u6bd2\u8f6f\u4ef6\u6216\u9632\u706b\u5899\u8f6f\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u8fdb\u884c\u4e0a\u9762\u7684\u4e09\u4e2a\u6b65\u9aa4\u4e4b\u540e\u8fd8\u6709\u95ee\u9898\uff0c\u90a3\u5e94\u8be5\u770b\u770b\u662f\u4e0d\u662f\u8fd8\u6709\u4e0b\u9762\u7684\u9519\u8bef\u3002<\/p>\n<p>2. \u201cTerminating 1 threads that failed to exit\u201d\u9519\u8bef<br \/>\u4e0a\u9762\u9519\u8bef\u4e2d\u7684\u6570\u5b571\u6709\u53ef\u80fd\u662f\u5176\u4ed6\u6570\u5b57\uff0c\u9020\u6210\u8fd9\u4e2a\u9519\u8bef\u7684\u539f\u56e0\u662fApache\u5728\u9000\u51fa\u5e76\u53d1\u7ebf\u7a0b\u7684\u65f6\u5019\u51fa\u73b0\u7ebf\u7a0b\u6ea2\u51fa\uff0c\u4ece\u800c\u9020\u6210\u5185\u5b58\u6cc4\u9732\uff0c\u8868\u73b0\u51fa\u6765\u7684\u5c31\u662fApache\u6240\u5360\u7528\u7684\u7cfb\u7edf\u8d44\u6e90\u6301\u7eed\u589e\u957f\u3002<\/p>\n<p>\u89e3\u51b3\u7684\u65b9\u6cd5\u4e5f\u5f88\u7b80\u5355\uff0c\u5c06\u6700\u5927\u8bf7\u6c42\u7ebf\u7a0b\u7684\u503c\u964d\u4f4e\u4e00\u4e9b\uff0c\u4f46\u662f\u4e5f\u4e0d\u80fd\u592a\u4f4e\uff0c\u592a\u4f4e\u7684\u8bdd\u4f1a\u4ea7\u751f\u5927\u91cf\u7684\u8bf7\u6c42\u961f\u5217\u4ece\u800c\u9020\u6210\u7ad9\u70b9\u8bbf\u95ee\u7f13\u6162\u3002\u5982\u679c\u4e4b\u524d\u4e3a0\u5219\u5c06\u5176\u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u6700\u5927\u503c\u3002<\/p>\n<p>&nbsp;&nbsp; 1. MaxRequestsPerChild 10000<\/p>\n<p>3. \u201cfile .&#92;&#92;server&#92;&#92;mpm&#92;&#92;winnt&#92;&#92;child.c, line 1078, assertion \u201c(rv >= 0) &#038;&#038; (rv < threads_created)\u201d failed\u201d \u9519\u8bef\n\n\u8fd9\u4e2a\u9519\u8bef\u662fApache\u7684\u4e00\u4e2abug(#11997)\uff0c\u53ef\u4ee5\u901a\u8fc7 Win32DisableAcceptEx \u7981\u6b62Apache\u4f7f\u7528WinSocket v2\u6765\u907f\u514d\u6b64bug\uff0c\u5177\u4f53\u8bbe\u7f6e\u89c1\u524d\u8ff0\u3002\n\n4. PHP5.2.1\u4ee5\u4e0a\u7248\u672c\u7684libmysql.dll\u4e0eMySQL5\u4e0d\u517c\u5bb9<br \/>PHP5.2.1\u4ee5\u540e\u7684\u65b0\u7248\u672c(\u622a\u6b62\u76ee\u524d\u6700\u65b0\u7248\u672c\u4e3a5.2.5)\u4e2d\u7528\u4e8e\u8fde\u63a5MySQL\u7684libmysql.dll\u7ec4\u4ef6\u4e0eMySQL5\u4e0d\u517c\u5bb9\uff0c\u5728Apache\u4e2d\u8fd0\u884cPHP\u7684\u65f6\u5019\u4f1a\u9020\u6210Apache\u4ea7\u751fCPU100%\u7684\u95ee\u9898\u3002<\/p>\n<p>\u89e3\u51b3\u7684\u65b9\u6cd5\u5c31\u662f\u4ecehttp:\/\/www.php.net\/releases\/\u4e0b\u8f7d5.2.1\u7248\u672c\uff0c\u5c06\u538b\u7f29\u5305\u4e2d\u7684libmysql.dll\u6587\u4ef6\u8986\u76d6\u73b0\u5728\u7684\u6587\u4ef6\uff0c\u7136\u540e\u91cd\u542fApache\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>5. \u75c5\u6bd2\u6216\u6728\u9a6c\u7a0b\u5e8f\u547d\u540d\u4e3aApache.exe<br \/>\u6709\u7684\u65f6\u5019\u75c5\u6bd2\u6216\u6728\u9a6c\u7a0b\u5e8f\u4f1a\u5c06\u5176\u540d\u79f0\u547d\u540d\u4e3aApache.exe\u6587\u4ef6\u8fbe\u5230\u4e00\u79cd\u63a9\u9970\u7684\u76ee\u7684\uff0c\u8fd9\u4e2a\u65f6\u5019\u4f7f\u7528\u7b2c\u4e09\u65b9\u8fdb\u7a0b\u5206\u6790\u5668\u67e5\u770b\u8fdb\u7a0b\u7684\u8def\u5f84\u7136\u540e\u5c06\u5176\u5220\u9664\u6216\u4f7f\u7528\u6740\u6bd2\u8f6f\u4ef6\u6e05\u9664\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>6. \u7a0b\u5e8f\u7f16\u5199\u4e0d\u4e25\u8c28\u9020\u6210\u6b7b\u5faa\u73af\u7b49\u9519\u8bef<br \/>\u5982\u679c\u4e0a\u9762\u7684\u95ee\u9898\u90fd\u4e0d\u5b58\u5728Apache\u4f9d\u7136\u4ea7\u751fCPU100%\u7684\u95ee\u9898\u7684\u8bdd\uff0c\u901a\u5e38\u6765\u8bf4\u5c31\u5e94\u8be5\u662fWeb\u7a0b\u5e8f\u81ea\u8eab\u7684\u95ee\u9898\u4e86\uff0c\u4f8b\u5982\u6b7b\u5faa\u73af\u7b49\u7b49\u3002\u8fd9\u4e2a\u65f6\u5019\u9700\u8981\u5728\u65e5\u5fd7\u4e2d\u8bbe\u7f6eHTTP\u8bf7\u6c42\u7684\u6587\u4ef6\u53ca\u6267\u884c\u7684\u65f6\u95f4\uff0c\u7136\u540e\u67e5\u627e\u51fa\u6267\u884c\u65f6\u95f4\u6bd4\u8f83\u957f\u7684\u5730\u5740\u8fdb\u884c\u5206\u6790\u6392\u67e5\u3002<\/p>\n<p>\u65e5\u5fd7\u683c\u5f0f\u8bbe\u7f6e\u5982\u4e0b\uff1a<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;LogFormat \u201c%v %h %l %u %t [%Ts] &#92;\u201d%r&#92;\u201d %>s %b\u201d vhost_common #\u8bbe\u7f6e\u7a0b\u5e8f\u6267\u884c\u65f6\u95f4<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;<VirtualHost xxx.xxx.xx.xx:80><br \/>&nbsp;&nbsp;&nbsp;&nbsp;ServerName xxx.xxx.com<br \/>&nbsp;&nbsp;&nbsp;&nbsp;DirectoryIndex index.php index.html index.htm<br \/>&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot \u201cxxx\u201d<br \/>&nbsp;&nbsp;&nbsp;&nbsp;# cronolog.exe\u662fApache\u81ea\u5e26\u7684\u7528\u4e8e\u5c06\u65e5\u5fd7\u6587\u4ef6\u8fdb\u884c\u5206\u5272\u7684\u5e94\u7528\u7a0b\u5e8f<br \/>&nbsp;&nbsp;&nbsp;&nbsp;CustomLog \u201c&#124;bin\/cronolog.exe e:\/%Y%m%d.log\u201d vhost_common<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/VirtualHost><\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<br \/><a href=\"http:\/\/groups.google.com\/group\/eachgain\/browse_thread\/thread\/203204184f99e544\/339ae75ba239e064%23339ae75ba239e064\" target=\"_blank\">apache \u9047\u5230[error] (OS 10038) \u9519\u8bef<\/a><br \/><a href=\"https:\/\/support.kayako.com\/index.php?_m=knowledgebase&#038;_a=viewarticle&#038;kbarticleid=236\" target=\"_blank\">Error in my_thread_global_end(): 1 threads didn\u2019t exit<\/a><br \/><a href=\"http:\/\/blog.s135.com\/read.php\/269.htm?page=1\" target=\"_blank\">\u67e5\u770bApache\u5e76\u53d1\u8bf7\u6c42\u6570\u53ca\u5176TCP\u8fde\u63a5\u72b6\u6001<\/a><br \/><a href=\"http:\/\/issues.apache.org\/bugzilla\/show_bug.cgi?id=11997\" target=\"_blank\">Apache Bug 11997<\/a><br \/><a href=\"http:\/\/zhumeng99.cn\/read.php?48\" target=\"_blank\">\u5173\u4e8eapache.exe\u5f00\u673a\u5360\u7528cpu100%\u7684\u7ec8\u6781\u89e3\u51b3\u65b9\u6cd5<\/a><br \/><a href=\"http:\/\/riddle.bokee.com\/6200980.html\" target=\"_blank\">apache cpu\u5360\u7528100%\u7684\u95ee\u9898<\/a><br \/><a href=\"http:\/\/x.discuz.net\/viewthread-609579.html\" target=\"_blank\">\u7a7a\u95f4\u6301\u7eedCPU100%\u65f6\u95f4\u8fc7\u957f\uff0c\u5982\u4f55\u4f18\u5316\u7a0b\u5e8f<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005: Jet Mah from Java\u5802 \u6240\u8c13Apache\u51fa\u73b0CPU\u9ad8\u5360\u7528\u7387\u5c31\u662f\u6307Apache\u5728\u4e00\u6bb5\u65f6\u95f4\u5185 <a href='https:\/\/www.icocean.com\/blog\/?p=1379' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[638,346,1520,1882,425],"class_list":["post-1379","post","type-post","status-publish","format-standard","hentry","category-lamp","tag-apache","tag-cpu","tag-1520","tag-1882","tag-425","category-24-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1379"}],"version-history":[{"count":0,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1379\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}