{"id":41682,"date":"2024-10-02T04:17:56","date_gmt":"2024-10-01T20:17:56","guid":{"rendered":"https:\/\/server.hk\/cnblog\/41682\/"},"modified":"2024-10-02T04:17:56","modified_gmt":"2024-10-01T20:17:56","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_hcheck%e8%a8%ad%e5%ae%9aapache","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/41682\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_proxy_hcheck\u8a2d\u5b9aApache"},"content":{"rendered":"<h1 id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_hcheck%e8%a8%ad%e5%ae%9aapache-hvwInCZROV\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_proxy_hcheck\u8a2d\u5b9aApache<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cApache\u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u7db2\u7ad9\u548c\u61c9\u7528\u7a0b\u5f0f\u4e2d\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u53ef\u7528\u6027\u548c\u8ca0\u8f09\u5e73\u8861\u7684\u7cfb\u7d71\uff0c\u4f7f\u7528mod_proxy_hcheck\u6a21\u7d44\u4f86\u76e3\u63a7\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u5065\u5eb7\u72c0\u614b\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728Apache\u4e2d\u4f7f\u7528mod_proxy_hcheck\u9032\u884c\u8a2d\u5b9a\uff0c\u5e6b\u52a9\u65b0\u624b\u7528\u6236\u66f4\u597d\u5730\u7ba1\u7406\u5176\u4f3a\u670d\u5668\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afmod_proxy_hcheck%ef%bc%9f-hvwInCZROV\">\u4ec0\u9ebc\u662fmod_proxy_hcheck\uff1f<\/h2>\n<p>mod_proxy_hcheck\u662f\u4e00\u500bApache\u6a21\u7d44\uff0c\u4e3b\u8981\u7528\u65bc\u6aa2\u67e5\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u5065\u5eb7\u72c0\u614b\u3002\u7576\u5f8c\u7aef\u4f3a\u670d\u5668\u51fa\u73fe\u6545\u969c\u6642\uff0cmod_proxy_hcheck\u53ef\u4ee5\u81ea\u52d5\u5c07\u6d41\u91cf\u91cd\u5b9a\u5411\u5230\u5176\u4ed6\u5065\u5eb7\u7684\u4f3a\u670d\u5668\uff0c\u5f9e\u800c\u63d0\u9ad8\u7cfb\u7d71\u7684\u53ef\u7528\u6027\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dmod_proxy_hcheck-hvwInCZROV\">\u5b89\u88ddmod_proxy_hcheck<\/h2>\n<p>\u5728\u4f7f\u7528mod_proxy_hcheck\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u78ba\u4fddApache\u5df2\u7d93\u5b89\u88dd\u4e26\u555f\u7528\u8a72\u6a21\u7d44\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u7684\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo a2enmod proxy\nsudo a2enmod proxy_http\nsudo a2enmod proxy_hcheck\nsudo systemctl restart apache2\n<\/code><\/pre>\n<p>\u9019\u4e9b\u547d\u4ee4\u5c07\u555f\u7528proxy\u3001proxy_http\u548cproxy_hcheck\u6a21\u7d44\uff0c\u4e26\u91cd\u555fApache\u4f3a\u670d\u5668\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%aemod_proxy_hcheck-hvwInCZROV\">\u914d\u7f6emod_proxy_hcheck<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u914d\u7f6emod_proxy_hcheck\u4ee5\u76e3\u63a7\u5f8c\u7aef\u4f3a\u670d\u5668\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u57fa\u672c\u7684\u914d\u7f6e\u7bc4\u4f8b\uff1a<\/p>\n<pre><code>&lt;Proxy balancer:\/\/mycluster&gt;\n    BalancerMember http:\/\/192.168.1.1:80\n    BalancerMember http:\/\/192.168.1.2:80\n    ProxySet lbmethod=byrequests\n    ProxySet status=On\n    ProxySet timeout=5\n    ProxySet hcheck=On\n    ProxySet hcheckinterval=5\n    ProxySet hchecktimeout=2\n&lt;\/Proxy&gt;\n\nProxyPass \/ balancer:\/\/mycluster\/\nProxyPassReverse \/ balancer:\/\/mycluster\/\n<\/code><\/pre>\n<p>\u5728\u9019\u6bb5\u914d\u7f6e\u4e2d\uff0c\u6211\u5011\u5275\u5efa\u4e86\u4e00\u500b\u540d\u70ba\u201cmycluster\u201d\u7684\u8ca0\u8f09\u5e73\u8861\u5668\uff0c\u4e26\u6dfb\u52a0\u4e86\u5169\u500b\u5f8c\u7aef\u4f3a\u670d\u5668\u3002\u4ee5\u4e0b\u662f\u5404\u500b\u53c3\u6578\u7684\u89e3\u91cb\uff1a<\/p>\n<ul>\n<li><strong>BalancerMember<\/strong>: \u5b9a\u7fa9\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u5730\u5740\u3002<\/li>\n<li><strong>ProxySet lbmethod<\/strong>: \u8a2d\u5b9a\u8ca0\u8f09\u5e73\u8861\u7684\u65b9\u6cd5\uff0c\u9019\u88e1\u4f7f\u7528\u7684\u662f\u6309\u8acb\u6c42\u6578\u91cf\u9032\u884c\u5e73\u8861\u3002<\/li>\n<li><strong>ProxySet status<\/strong>: \u555f\u7528\u72c0\u614b\u6aa2\u67e5\u3002<\/li>\n<li><strong>ProxySet timeout<\/strong>: \u8a2d\u5b9a\u8acb\u6c42\u7684\u8d85\u6642\u6642\u9593\u3002<\/li>\n<li><strong>ProxySet hcheck<\/strong>: \u555f\u7528\u5065\u5eb7\u6aa2\u67e5\u3002<\/li>\n<li><strong>ProxySet hcheckinterval<\/strong>: \u8a2d\u5b9a\u5065\u5eb7\u6aa2\u67e5\u7684\u9593\u9694\u6642\u9593\u3002<\/li>\n<li><strong>ProxySet hchecktimeout<\/strong>: \u8a2d\u5b9a\u5065\u5eb7\u6aa2\u67e5\u7684\u8d85\u6642\u6642\u9593\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e9%85%8d%e7%bd%ae-hvwInCZROV\">\u6e2c\u8a66\u914d\u7f6e<\/h2>\n<p>\u5b8c\u6210\u914d\u7f6e\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5Apache\u7684\u914d\u7f6e\u662f\u5426\u6b63\u78ba\uff1a<\/p>\n<pre><code>sudo apachectl configtest\n<\/code><\/pre>\n<p>\u5982\u679c\u6c92\u6709\u932f\u8aa4\uff0c\u5247\u53ef\u4ee5\u91cd\u555fApache\u4f3a\u670d\u5668\u4ee5\u4f7f\u914d\u7f6e\u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2\n<\/code><\/pre>\n<h2 id=\"%e7%9b%a3%e6%8e%a7%e5%92%8c%e6%97%a5%e8%aa%8c-hvwInCZROV\">\u76e3\u63a7\u548c\u65e5\u8a8c<\/h2>\n<p>\u70ba\u4e86\u78ba\u4fddmod_proxy_hcheck\u6b63\u5e38\u904b\u884c\uff0c\u5efa\u8b70\u5b9a\u671f\u6aa2\u67e5Apache\u7684\u65e5\u8a8c\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u65e5\u8a8c\uff1a<\/p>\n<pre><code>tail -f \/var\/log\/apache2\/error.log\n<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u53ca\u6642\u767c\u73fe\u4efb\u4f55\u6f5b\u5728\u7684\u554f\u984c\uff0c\u4e26\u9032\u884c\u76f8\u61c9\u7684\u8abf\u6574\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-hvwInCZROV\">\u7e3d\u7d50<\/h2>\n<p>\u4f7f\u7528mod_proxy_hcheck\u53ef\u4ee5\u6709\u6548\u63d0\u9ad8Apache\u4f3a\u670d\u5668\u7684\u53ef\u7528\u6027\u548c\u7a69\u5b9a\u6027\u3002\u901a\u904e\u6b63\u78ba\u7684\u914d\u7f6e\u548c\u76e3\u63a7\uff0c\u60a8\u53ef\u4ee5\u78ba\u4fdd\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u5065\u5eb7\u72c0\u614b\uff0c\u5f9e\u800c\u70ba\u7528\u6236\u63d0\u4f9b\u66f4\u597d\u7684\u670d\u52d9\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u7ba1\u7406\u60a8\u7684\u4f3a\u670d\u5668\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\u4f86\u652f\u6301\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528mod_proxy_hcheck\u5728Apache\u4e2d\u8a2d\u7f6e\u5065\u5eb7\u6aa2\u67e5\uff0c\u78ba\u4fdd\u4f3a\u670d\u5668\u7a69\u5b9a\u6027\u8207\u6027\u80fd\u3002\u9069\u5408\u65b0\u624b\u7684\u8a73\u7d30\u6559\u7a0b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-41682","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=41682"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41682\/revisions"}],"predecessor-version":[{"id":41683,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41682\/revisions\/41683"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=41682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=41682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=41682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}