{"id":80,"date":"2022-05-02T15:26:09","date_gmt":"2022-05-02T07:26:09","guid":{"rendered":"https:\/\/frogvps.com\/?p=80"},"modified":"2022-05-18T12:37:26","modified_gmt":"2022-05-18T04:37:26","slug":"keepalived%e9%ab%98%e5%8f%af%e7%94%a8%e9%9b%86%e7%be%a4vrrp%e5%8d%8f%e8%ae%ae%e7%9a%84%e5%b7%a5%e4%bd%9c%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"https:\/\/frogvps.com\/?p=80","title":{"rendered":"KeepAlived\u9ad8\u53ef\u7528\u96c6\u7fa4VRRP\u534f\u8bae\u7684\u5de5\u4f5c\u539f\u7406"},"content":{"rendered":"\n<p>KeepAlived\u53ef\u4ee5\u89e3\u51b3nginx\u3001LVS\u7b49\u5404\u79cd\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u96c6\u7fa4\u53ef\u4ee5\u5206\u4e3a\u4e09\u7c7b\uff1a<\/strong><\/h2>\n\n\n\n<p><strong>1.LB\uff1aLoad Balance \u8d1f\u8f7d\u5747\u8861<\/strong><\/p>\n\n\n\n<p>LVS\/HAProxy\/nginx\uff08http\/upstream, stream\/upstream\uff09<\/p>\n\n\n\n<p><strong>2.HA\uff1aHigh Availability \u9ad8\u53ef\u7528\u96c6\u7fa4<\/strong><\/p>\n\n\n\n<p>\u6570\u636e\u5e93\u3001Zookeeper\u3001Redis<\/p>\n\n\n\n<p>SPoF: Single Point of Failure\uff0c\u89e3\u51b3\u5355\u70b9\u6545\u969c<\/p>\n\n\n\n<p><strong>3.HPC\uff1aHigh Performance Computing \u9ad8\u6027\u80fd\u96c6\u7fa4<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5b9e\u73b0\u9ad8\u53ef\u7528\uff1a<\/strong><\/h2>\n\n\n\n<p>\u63d0\u5347\u7cfb\u7edf\u9ad8\u7528\u6027\u7684\u89e3\u51b3\u65b9\u6848\uff1a\u964d\u4f4eMTTR- Mean Time To Repair(\u5e73\u5747\u6545\u969c\u65f6\u95f4)<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6848\uff1a\u5efa\u7acb\u5197\u4f59\u673a\u5236<\/p>\n\n\n\n<p>\u4e00\u4e2a\u8282\u70b9\u4f1a\u9762\u4e34\u5355\u70b9\u5931\u8d25\u7684\u95ee\u9898\uff0c\u6240\u4ee5\u51c6\u5907\u4e24\u4e2a\u8282\u70b9\uff0c\u5f7c\u6b64\u4e4b\u95f4\u76d1\u63a7\u5bf9\u65b9\u7684\u72b6\u6001\u3002\u8282\u70b9\u4e4b\u95f4\u901a\u8fc7\u5fc3\u8df3\u7ebfHEARTBEAT\u8fde\u63a5\uff0c\u76f8\u4e92\u901a\u8baf\u5224\u65ad\u5bf9\u65b9\u7684\u5065\u5eb7\u6027\u3002\u4e00\u65e6\u5176\u4e2d\u4e00\u4e2a\u6302\u4e86\uff0c\u5c31\u7531\u53e6\u4e00\u4e2a\u6765\u63d0\u4f9b\u670d\u52a1\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>active\/passive \u4e3b\/\u5907<\/li><li>active\/active \u53cc\u4e3b<\/li><li>active &#8211;&gt; HEARTBEAT &#8211;&gt; passive<\/li><li>active &lt;&#8211;&gt; HEARTBEAT &lt;&#8211;&gt; active<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">HA Cluster\u5b9e\u73b0\u65b9\u6848<\/h2>\n\n\n\n<p><strong>VRRP\uff1aVirtual Router Redundancy Protocol<\/strong><\/p>\n\n\n\n<p>VRRP\u534f\u8bae\uff08\u865a\u62df\u8def\u7531\u5668\u5197\u4f59\u534f\u8bae\uff09\u662fkeepalived\u7684\u4e00\u4e2a\u6838\u5fc3\u7ec4\u4ef6\uff0c\u501f\u9274\u4e86\u7269\u7406\u8def\u7531\u5668\u4e0a\u7684\u6280\u672f\uff0c\u540e\u6765\u88ab\u5f15\u5165\u5230linux\uff0c\u89e3\u51b3\u9759\u6001\u7f51\u5173\u5355\u70b9\u98ce\u9669\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7269\u7406\u5c42:\u8def\u7531\u5668\u3001\u4e09\u5c42\u4ea4\u6362\u673a<\/li><li>\u8f6f\u4ef6\u5c42:keepalived<\/li><\/ul>\n\n\n\n<p><strong>VRRP \u7f51\u7edc\u5c42\u786c\u4ef6\u5b9e\u73b0<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/xiaoqinwa\/frogpic\/img\/20220502a1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u4e0a\u56fe\u4e24\u4e2a\u8def\u7531\u5668\uff08\u5de6R1,\u53f3R2\uff09\u90fd\u6709\u5404\u81ea\u7684IP\uff08201.1.1.1\u548c201.1.1.2\uff09\uff0c\u516c\u53f8\u5185\u90e8\u7684\u673a\u5668\u8981\u548c\u5916\u90e8\u76f8\u8fde\u9700\u8981\u901a\u8fc7\u8def\u7531\u5668\u3002\u516c\u53f8\u5185\u90e8\u673a\u5668\u6307\u5411\u4e24\u4e2a\u4e0d\u540c\u7684\u8def\u7531\u5668\u53ef\u4ee5\u5b9e\u73b0\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u4f46\u662f\u4ecd\u7136\u89e3\u51b3\u4e0d\u4e86\u5355\u70b9\u5931\u8d25\u7684\u95ee\u9898\uff0c\u5982\u679c\u5176\u4e2d\u4e00\u53f0\u8def\u7531\u5668\u574f\u4e86\uff0c\u4e0e\u4e4b\u76f8\u8fde\u7684\u673a\u5668\u5c31\u4f1a\u4e0a\u4e0d\u4e86\u7f51\u3002\u800c\u4e14\u628a\u6240\u6709\u673a\u5668\u90fd\u8fde\u4e0a\u4e24\u4e2a\u8def\u7531\u5668\uff0c\u8ba9\u6570\u636e\u5305\u8f6e\u6d41\u8d70\u4e0d\u540c\u7684\u7f51\u5173\u4e5f\u4e0d\u592a\u73b0\u5b9e\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5229\u7528VRRP\u534f\u8bae\u865a\u62df\u51fa\u4e00\u4e2a\u65b0\u7684\u5730\u5740\uff08201.1.1.3\uff09\uff0c\u8fd9\u4e2a\u5730\u5740\u5c31\u53eb\u505aVIP\uff08\u865a\u62df\u5730\u5740\uff09\u3002\u4e0a\u56fe\u4e24\u4e2a\u7269\u7406\u8def\u7531\u5668\u4e00\u8d77\u7956\u6210\u4e00\u4e2a\u865a\u62df\u8def\u7531\u5668\u3002 \u8ba9\u6240\u6709\u5185\u90e8\u673a\u5668\u7684\u7f51\u5173\u90fd\u6307\u5411\u540c\u4e00\u4e2a\u865a\u62df\u5730\u5740\u3002\u865a\u62df\u5730\u5740\u4e0d\u662f\u56fa\u5b9a\u5728\u67d0\u4e2a\u8def\u7531\u5668\u4e0a\u7684\uff0c\u5b83\u53ef\u80fd\u8fd0\u884c\u5728R1\u4e0a\uff0c\u4e5f\u53ef\u80fd\u8fd0\u884c\u5728R2\u4e0a\u3002\u5f53VIP\u8fd0\u884c\u5728R1\u4e0a\uff0c\u5185\u90e8\u673a\u5668\u5c31\u901a\u8fc7R1\u4e0a\u7f51\uff0c\u4e00\u65e6R1\u574f\u4e86VIP\u4f1a\u5207\u6362\u5230R2\u4e0a\u53bb\u8fd0\u884c\uff0c\u8fd9\u65f6\u5019\u5185\u90e8\u673a\u5668\u5c31\u901a\u8fc7R2\u4e0a\u7f51\uff0c\u89e3\u51b3\u4e86\u8def\u7531\u5668\u7684\u9ad8\u53ef\u7528\u95ee\u9898\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">VRRP \u76f8\u5173\u672f\u8bed<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u865a\u62df\u8def\u7531\u5668\uff1aVirtual Router<\/li><li>\u865a\u62df\u8def\u7531\u5668\u6807\u8bc6\uff1aVRID(0-255)\uff0c\u552f\u4e00\u6807\u8bc6\u865a\u62df\u8def\u7531\u5668<\/li><li>VIP\uff1aVirtual IP<\/li><li>VMAC\uff1aVirutal MAC (00-00-5e-00-01-VRID)<\/li><li>\u7269\u7406\u8def\u7531\u5668\uff1a<\/li><\/ul>\n\n\n\n<p>master\uff1a\u4e3b\u8bbe\u5907 \u200b backup\uff1a\u5907\u7528\u8bbe\u5907 \u200b priority\uff1a\u4f18\u5148\u7ea7<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">VRRP \u76f8\u5173\u6280\u672f<\/h2>\n\n\n\n<p>\u901a\u544a\uff1a\u5fc3\u8df3\uff0c\u4f18\u5148\u7ea7\u7b49\uff1b\u5468\u671f\u6027 \u5de5\u4f5c\u65b9\u5f0f\uff1a\u62a2\u5360\u5f0f\uff0c\u975e\u62a2\u5360\u5f0f\uff08\u751f\u4ea7\u4e2d\u7528\u975e\u62a2\u5360\u5f0f\u66f4\u7a33\u5b9a\uff09<\/p>\n\n\n\n<p>\u5b89\u5168\u8ba4\u8bc1\uff08\u9632\u6b62\u8bef\u64cd\u4f5c\uff09\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u65e0\u8ba4\u8bc1<\/li><li>\u7b80\u5355\u5b57\u7b26\u8ba4\u8bc1\uff1a\u9884\u5171\u4eab\u5bc6\u94a5<\/li><li>MD5<\/li><\/ul>\n\n\n\n<p>\u5de5\u4f5c\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4e3b\/\u5907\uff1a\u5355\u865a\u62df\u8def\u7531\u5668<\/li><li>\u4e3b\/\u4e3b\uff1a\u4e3b\/\u5907\uff08\u865a\u62df\u8def\u7531\u56681\uff09\uff0c\u5907\/\u4e3b\uff08\u865a\u62df\u8def\u7531\u56682\uff09<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">KeepAlived\u67b6\u6784<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/xiaoqinwa\/frogpic\/img\/20220502a3.JPG\" alt=\"\"\/><\/figure>\n\n\n\n<p>KeepAlived\u5206\u6210\u7528\u6237\u7a7a\u95f4\u548c\u5185\u6838\u7a7a\u95f4\u3002IPVS\u662fLVS\u7684\u6838\u5fc3\u7ec4\u4ef6\uff0cIPVS wrapper\u53ef\u4ee5\u628aLVS\u7684\u89c4\u5219\u901a\u8fc7KeepAlived\u5199\u5165\u5230LVS\u7684\u5185\u6838\u7a7a\u95f4\u4e2d\uff0c\u6765\u63a7\u5236LVS\u7684\u8c03\u5ea6\u7b56\u7565\u96c6\u7fa4\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p><strong>\u7528\u6237\u7a7a\u95f4\u6838\u5fc3\u7ec4\u4ef6<\/strong><\/p>\n\n\n\n<p>vrrp stack\uff1aVIP\u6d88\u606f\u901a\u544a checkers\uff1a\u76d1\u6d4breal server system call\uff1a\u5b9e\u73b0 vrrp \u534f\u8bae\u72b6\u6001\u8f6c\u6362\u65f6\u8c03\u7528\u811a\u672c\u7684\u529f\u80fd<\/p>\n\n\n\n<p>SMTP\uff1a\u90ae\u4ef6\u7ec4\u4ef6 IPVS wrapper\uff1a\u751f\u6210IPVS\u89c4\u5219 Netlink Reflector\uff1a\u7f51\u7edc\u63a5\u53e3 WatchDog\uff1a\u76d1\u63a7\u8fdb\u7a0b<\/p>\n\n\n\n<p><strong>\u63a7\u5236\u7ec4\u4ef6<\/strong><\/p>\n\n\n\n<p>\u63d0\u4f9bkeepalived.conf \u7684\u89e3\u6790\u5668\uff0c\u5b8c\u6210Keepalived\u914d\u7f6e<\/p>\n\n\n\n<p><strong>IO\u590d\u7528\u5668<\/strong><\/p>\n\n\n\n<p>\u9488\u5bf9\u7f51\u7edc\u76ee\u7684\u800c\u4f18\u5316\u7684\u81ea\u5df1\u7684\u7ebf\u7a0b\u62bd\u8c61<\/p>\n\n\n\n<p><strong>\u5185\u5b58\u7ba1\u7406\u7ec4\u4ef6<\/strong><\/p>\n\n\n\n<p>\u4e3a\u67d0\u4e9b\u901a\u7528\u7684\u5185\u5b58\u7ba1\u7406\u529f\u80fd\uff08\u4f8b\u5982\u5206\u914d\uff0c\u91cd\u65b0\u5206\u914d\uff0c\u53d1\u5e03\u7b49\uff09\u63d0\u4f9b\u8bbf\u95ee\u6743\u9650<\/p>\n","protected":false},"excerpt":{"rendered":"<p>KeepAlived\u53ef\u4ee5\u89e3\u51b3nginx\u3001LVS\u7b49\u5404\u79cd\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u3002 \u96c6\u7fa4\u53ef\u4ee5\u5206\u4e3a\u4e09\u7c7b\uff1a 1.LB\uff1aLoad Balance \u8d1f\u8f7d\u5747\u8861 LVS\/HAProxy\/nginx\uff08http\/upstream, stream\/upstream\uff09 2.H&#8230;<\/p>\n","protected":false},"author":1,"featured_media":95,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[23,24,22],"topic":[],"class_list":["post-80","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-keepalived","tag-vrrp","tag-22"],"_links":{"self":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=80"}],"version-history":[{"count":7,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":91,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions\/91"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/media\/95"}],"wp:attachment":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=80"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}