{"id":1145,"date":"2011-12-14T17:16:00","date_gmt":"2011-12-14T09:16:00","guid":{"rendered":"\/?p=1145"},"modified":"2011-12-14T17:16:00","modified_gmt":"2011-12-14T17:16:00","slug":"1145","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/architecture\/1145.html","title":{"rendered":"\u8f6f\u4ef6\u7ea7\u8d1f\u8f7d\u5747\u8861\u5668(LVS\/HAProxy\/Nginx)\u7684\u7279\u70b9\u548c\u5bf9\u6bd4"},"content":{"rendered":"
\u73b0\u5728\u7f51\u7ad9\u53d1\u5c55\u7684\u8d8b\u52bf\u5bf9\u7f51\u7edc\u8d1f\u8f7d\u5747\u8861<\/span>\u7684\u4f7f\u7528\u662f\u968f\u7740\u7f51\u7ad9\u89c4\u6a21\u7684\u63d0\u5347\u6839\u636e\u4e0d\u540c\u7684\u9636\u6bb5\u6765\u4f7f\u7528\u4e0d\u540c\u7684\u6280\u672f\uff1a<\/p>\n \u4e00\u79cd\u662f\u901a\u8fc7\u786c\u4ef6\u6765\u8fdb\u884c\u8fdb\u884c\uff0c\u5e38\u89c1\u7684\u786c\u4ef6\u6709\u6bd4\u8f83\u6602\u8d35\u7684NetScaler\u3001F5\u3001Radware\u548cArray\u7b49\u5546\u7528\u7684\u8d1f\u8f7d\u5747\u8861\u5668\uff0c\u5b83\u7684\u4f18\u70b9\u5c31\u662f\u6709\u4e13\u4e1a\u7684\u7ef4\u62a4\u56e2\u961f\u6765\u5bf9\u8fd9\u4e9b\u670d\u52a1\u8fdb\u884c\u7ef4\u62a4\u3001\u7f3a\u70b9\u5c31\u662f\u82b1\u9500\u592a\u5927\uff0c\u6240\u4ee5\u5bf9\u4e8e\u89c4\u6a21\u8f83\u5c0f\u7684\u7f51\u7edc\u670d\u52a1\u6765\u8bf4\u6682\u65f6\u8fd8\u6ca1\u6709\u9700\u8981\u4f7f\u7528\uff1b\u53e6\u5916\u4e00\u79cd\u5c31\u662f\u7c7b\u4f3c\u4e8eLVS<\/span>\/HAProxy\u3001Nginx<\/span>\u7684\u57fa\u4e8eLinux<\/span>\u7684\u5f00\u6e90<\/span>\u514d\u8d39\u7684\u8d1f\u8f7d\u5747\u8861\u8f6f\u4ef6\u7b56\u7565,\u8fd9\u4e9b\u90fd\u662f\u901a\u8fc7\u8f6f\u4ef6\u7ea7\u522b\u6765\u5b9e\u73b0\uff0c\u6240\u4ee5\u8d39\u7528\u975e\u5e38\u4f4e\u5ec9\uff0c\u6240\u4ee5\u6211\u4e2a\u4e5f\u6bd4\u8f83\u63a8\u8350\u5927\u5bb6\u91c7\u7528\u7b2c\u4e8c\u79cd\u65b9\u6848\u6765\u5b9e\u65bd\u81ea\u5df1\u7f51\u7ad9\u7684\u8d1f\u8f7d\u5747\u8861\u9700\u6c42\u3002<\/p>\n \u8fd1\u671f\u670b\u53cb\u7684\u9879\u76ee\u6210\u529f\u4e0a\u7ebf\u4e86\uff0cPV\u8fbe\u5230\u4e86\u4ebf\u7ea7\/\u65e5\u7684\u8bbf\u95ee\u91cf\uff0c\u6700\u524d\u7aef\u7528\u7684\u662fHAProxy+Keepalived\u53cc\u673a\u4f5c\u7684\u8d1f\u8f7d\u5747\u8861\u5668\/\u53cd\u5411\u4ee3\u7406\uff0c\u6574\u4e2a\u7f51\u7ad9\u975e\u5e38\u7a33\u5b9a\uff1b\u8fd9\u8ba9\u6211\u66f4\u575a\u5b9a\u4e86\u4ee5\u524d\u8ddf\u8001\u7537\u5b69\u524d\u8f88\u804a\u7684\u5173\u4e8e\u7f51\u7ad9\u67b6\u6784\u6bd4\u8f83\u5408\u7406\u8bbe\u8ba1\u7684\u67b6\u6784\u65b9\u6848\uff1a\u5373Nginx\/HAProxy+Keepalived\u4f5cWeb<\/span>\u6700\u524d\u7aef\u7684\u8d1f\u8f7d\u5747\u8861\u5668\uff0c\u540e\u7aef\u7684MySQL<\/span>\u6570\u636e\u5e93<\/span>\u67b6\u6784\u91c7\u7528\u4e00\u4e3b\u591a\u4ece\uff0c\u8bfb\u5199\u5206\u79bb\u7684\u65b9\u5f0f\uff0c\u91c7\u7528LVS+Keepalived\u7684\u65b9\u5f0f\u3002<\/p>\n \u5728\u8fd9\u91cc\u6211\u4e5f\u6709\u4e00\u70b9\u8981\u8ddf\u5927\u5bb6\u7533\u660e\u4e0b\uff1a\u5f88\u591a\u670b\u53cb\u62c5\u5fc3\u8f6f\u4ef6\u7ea7\u522b\u7684\u8d1f\u8f7d\u5747\u8861\u5728\u9ad8\u5e76\u53d1\u6d41\u91cf\u51b2\u51fb\u4e0b\u7684\u7a33\u5b9a\u60c5\u51b5\uff0c\u4e8b\u5b9e\u662f\u6211\u4eec\u901a\u8fc7\u6210\u529f\u4e0a\u7ebf\u7684\u8bb8\u591a\u7f51\u7ad9\u53d1\u73b0\uff0c\u5b83\u4eec\u7684\u7a33\u5b9a\u6027\u4e5f\u662f\u975e\u5e38\u597d\u7684\uff0c\u5b95\u673a<\/span>\u7684\u53ef\u80fd\u6027\u5fae\u4e4e\u5176\u5fae\uff0c\u6240\u4ee5\u6211\u73b0\u5728\u505a\u7684\u9879\u76ee\uff0c\u57fa\u672c\u4e0a\u6ca1\u8003\u8651\u670d\u52a1\u7ea7\u522b\u7684\u9ad8\u53ef\u7528\u4e86\u3002\u76f8\u4fe1\u5927\u5bb6\u5bf9\u8fd9\u4e9b\u8f6f\u4ef6\u7ea7\u522b\u7684\u8d1f\u8f7d\u5747\u8861\u8f6f\u4ef6\u90fd\u5df2\u7ecf\u6709\u4e86\u5f88\u6df1\u7684\u7684\u8ba4\u8bc6\uff0c\u4e0b\u9762\u6211\u5c31\u5b83\u4eec\u7684\u7279\u70b9\u548c\u9002\u7528\u573a\u5408\u5206\u522b\u8bf4\u660e\u4e0b\u3002<\/p>\n LVS\uff1a\u4f7f\u7528\u96c6\u7fa4\u6280\u672f\u548cLinux\u64cd\u4f5c\u7cfb\u7edf<\/span>\u5b9e\u73b0\u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u9ad8\u53ef\u7528\u7684\u670d\u52a1\u5668<\/span>\uff0c\u5b83\u5177\u6709\u5f88\u597d\u7684\u53ef\u4f38\u7f29\u6027\uff08Scalability)\u3001\u53ef\u9760\u6027\uff08Reliability)\u548c\u53ef\u7ba1\u7406\u6027\uff08Manageability)\uff0c\u611f\u8c22\u7ae0\u6587\u5d69\u535a\u58eb\u4e3a\u6211\u4eec\u63d0\u4f9b\u5982\u6b64\u5f3a\u5927\u5b9e\u7528\u7684\u5f00\u6e90\u8f6f\u4ef6\u3002<\/p>\n LVS\u7684\u7279\u70b9\u662f\uff1a Nginx\u7684\u7279\u70b9\u662f\uff1a HAProxy\u7684\u7279\u70b9\u662f\uff1a \u73b0\u5728\u7f51\u7ad9\u53d1\u5c55\u7684\u8d8b\u52bf\u5bf9\u7f51\u7edc\u8d1f\u8f7d\u5747\u8861<\/span>\u7684\u4f7f\u7528\u662f\u968f\u7740\u7f51\u7ad9\u89c4\u6a21\u7684\u63d0\u5347\u6839\u636e\u4e0d\u540c\u7684\u9636\u6bb5\u6765\u4f7f\u7528\u4e0d\u540c\u7684\u6280\u672f\uff1a<\/p>\n \u4e00\u79cd\u662f\u901a\u8fc7\u786c\u4ef6\u6765\u8fdb\u884c\u8fdb\u884c\uff0c\u5e38\u89c1\u7684\u786c\u4ef6\u6709\u6bd4\u8f83\u6602\u8d35\u7684NetScaler\u3001F5\u3001Radware\u548cArray\u7b49\u5546\u7528\u7684\u8d1f\u8f7d\u5747\u8861\u5668\uff0c\u5b83\u7684\u4f18\u70b9\u5c31\u662f\u6709\u4e13\u4e1a\u7684\u7ef4\u62a4\u56e2\u961f\u6765\u5bf9\u8fd9\u4e9b\u670d\u52a1\u8fdb\u884c\u7ef4\u62a4\u3001\u7f3a\u70b9\u5c31\u662f\u82b1\u9500\u592a\u5927\uff0c\u6240\u4ee5\u5bf9\u4e8e\u89c4\u6a21\u8f83\u5c0f\u7684\u7f51\u7edc\u670d\u52a1\u6765\u8bf4\u6682\u65f6\u8fd8\u6ca1\u6709\u9700\u8981\u4f7f\u7528\uff1b\u53e6\u5916\u4e00\u79cd\u5c31\u662f\u7c7b\u4f3c\u4e8eLVS<\/span>\/HAProxy\u3001Nginx<\/span>\u7684\u57fa\u4e8eLinux<\/span>\u7684\u5f00\u6e90<\/span>\u514d\u8d39\u7684\u8d1f\u8f7d\u5747\u8861\u8f6f<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1145"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1145"}],"version-history":[{"count":0,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1145\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
<\/strong><\/p>\n\n
<\/strong><\/p>\n\n
<\/strong><\/p>\n\n
\u2460 roundrobin\uff0c\u8868\u793a\u7b80\u5355\u7684\u8f6e\u8be2\uff0c\u8fd9\u4e2a\u4e0d\u591a\u8bf4\uff0c\u8fd9\u4e2a\u662f\u8d1f\u8f7d\u5747\u8861\u57fa\u672c\u90fd\u5177\u5907\u7684\uff1b
\u2461 static-rr\uff0c\u8868\u793a\u6839\u636e\u6743\u91cd\uff0c\u5efa\u8bae\u5173\u6ce8\uff1b
\u2462 leastconn\uff0c\u8868\u793a\u6700\u5c11\u8fde\u63a5\u8005\u5148\u5904\u7406\uff0c\u5efa\u8bae\u5173\u6ce8\uff1b
\u2463 source\uff0c\u8868\u793a\u6839\u636e\u8bf7\u6c42\u6e90IP\uff0c\u8fd9\u4e2a\u8ddfNginx\u7684IP_hash\u673a\u5236\u7c7b\u4f3c\uff0c\u6211\u4eec\u7528\u5176\u4f5c\u4e3a\u89e3\u51b3session\u95ee\u9898\u7684\u4e00\u79cd\u65b9\u6cd5\uff0c\u5efa\u8bae\u5173\u6ce8\uff1b
\u2464 ri\uff0c\u8868\u793a\u6839\u636e\u8bf7\u6c42\u7684URI\uff1b
\u2465 rl_param\uff0c\u8868\u793a\u6839\u636e\u8bf7\u6c42\u7684URl\u53c2\u6570’balance url_param’ requires an URL parameter name\uff1b
\u2466 hdr(name)\uff0c\u8868\u793a\u6839\u636eHTTP\u8bf7\u6c42\u5934\u6765\u9501\u5b9a\u6bcf\u4e00\u6b21HTTP\u8bf7\u6c42\uff1b
\u2467 rdp-cookie(name)\uff0c\u8868\u793a\u6839\u636e\u636ecookie(name)\u6765\u9501\u5b9a\u5e76\u54c8\u5e0c\u6bcf\u4e00\u6b21TCP\u8bf7\u6c42\u3002 <\/li>\n<\/ol>\n