{"id":3476,"date":"2021-03-14T17:51:46","date_gmt":"2021-03-14T09:51:46","guid":{"rendered":"http:\/\/blog.ywdevops.cn\/?p=3476"},"modified":"2021-03-14T17:51:46","modified_gmt":"2021-03-14T09:51:46","slug":"keepalived-2","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2021\/03\/14\/keepalived-2\/","title":{"rendered":"keepalived\u96c6\u7fa4\u4e2dMASTER\u548cBACKUP\u9009\u4e3e\u7b56\u7565"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728keepalived\u4e2d\uff0c\u5e76\u6ca1\u6709\u4e25\u683c\u610f\u4e49\u4e0a\u7684\u4e3b\u8282\u70b9\u548c\u5907\u8282\u70b9\uff0c\u867d\u7136\u53ef\u4ee5\u5728keepalived.conf\u4e2d\u914d\u7f6estate\u9009\u9879\u8bbe\u7f6e\u4e3aMASTER\u72b6\u6001\uff0c\u4f46\u662f\u4e0d\u610f\u5473\u6b64\u8282\u70b9\u4e00\u76f4\u5c31\u662fMASTER\u8282\u70b9\uff0c\u63a7\u5236\u8282\u70b9\u89d2\u8272\u7684\u9009\u9879\u662fpriority\u7684\u503c\uff0c\u53e6\u4e00\u4e2a\u80fd\u63a7\u5236\u8282\u70b9\u89d2\u8272\u7684\u9009\u9879\u662fvrrp_script\u6a21\u5757\u4e2d\u8bbe\u7f6e\u7684weight\u7684\u503c \uff0c\u8fd9\u4e24\u4e2a\u9009\u9879\u7684\u503c\u90fd\u662f\u4e00\u4e2a\u6574\u6570\u503c\uff0c\u5176\u4e2d&#8221;weight&#8221;\u7684\u503c\u53ef\u4ee5\u662f\u8d1f\u6570\uff0c\u4e5f\u53ef\u4ee5\u662f\u6b63\u6570\uff0c\u96c6\u7fa4\u4e2d\u8282\u70b9\u7684\u89d2\u8272\u5c31\u662f\u901a\u8fc7\u8fd9\u4e24\u4e2a\u503c\u7684\u5927\u5c0f\u51b3\u5b9a\u7684<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728vrrp_script\u6a21\u5757\u4e2d\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6eweight\u9009\u9879\u503c\uff0c\u90a3\u4e48\u96c6\u7fa4\u8282\u70b9\u7684\u4f18\u5148\u7ea7\u5c06\u7531priority\u7684\u503c\u6765\u51b3\u5b9a\uff0c\u5982\u679c\u9700\u8981\u5bf9\u96c6\u7fa4\u4f18\u5148\u7ea7\u8fdb\u884c\u7075\u6d3b\u63a7\u5236\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728vrrp_script\u6a21\u5757\u4e2d\u8bbe\u7f6e&#8221;weight&#8221;\u7684\u503c\u6765\u5b9e\u73b0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4f8b\u5982\uff1a<\/strong>\u6709A\u3001B\u4e24\u4e2a\u8282\u70b9\u7ec4\u6210keepalived\u96c6\u7fa4\uff0c\u5728A\u8282\u70b9\u4e2d\u8bbe\u7f6epriority\u7684\u503c\u4e3a100\uff0cB\u8282\u70b9\u7684priority\u7684\u503c\u4e3a80\uff0cA\u548cB\u8282\u70b9\u90fd\u4f7f\u7528\u4e86vrrp_script\u6a21\u5757\u6765\u76d1\u63a7mysql\u670d\u52a1\uff0c\u540c\u65f6\u8bbe\u7f6e\u4e86&#8221;weight&#8221;\u7684\u503c\u4e3a10 \uff0c\u5c06\u4f1a\u51fa\u73b0\u4e00\u4e0b\u72b6\u51b5\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e24\u4e2a\u8282\u70b9\u90fd\u542f\u52a8keepalived\u540e\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0bA\u8282\u70b9\u6210\u4e3a\u96c6\u7fa4\u4e2d\u7684master\u8282\u70b9\uff0cB\u8282\u70b9\u4e3abackup\u8282\u70b9\uff0c\u5982\u679c\u6b64\u65f6\u5c06A\u8282\u70b9\u7684MySQL\u670d\u52a1\u5173\u95ed\uff0c\u901a\u8fc7\u65e5\u5fd7\u67e5\u770b\u53ef\u4ee5\u53d1\u73b0B\u8282\u70b9\u5e76\u6ca1\u6709\u63a5\u7ba1A\u8282\u70b9\u7684\u65e5\u5fd7\uff0cB\u8282\u70b9\u4ecd\u7136\u5904\u4e8ebackup\u72b6\u6001\uff0cA\u8282\u70b9\u4f9d\u65e7\u662fmaster\u72b6\u6001\uff0c\u6b64\u65f6\u96c6\u7fa4\u5c06\u5931\u53bb\u610f\u4e49<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u9020\u6210\u8fd9\u79cd\u60c5\u51b5\u7684\u4e3b\u8981\u539f\u56e0\u5c31\u662f\u9009\u4e3e\u7b56\u7565\u51fa\u73b0\u4e86\u95ee\u9898<\/strong>\uff0c\u56e0\u4e3avrrp_script\u6a21\u5757\u4e2d\u914d\u7f6e\u4e86weight\uff0cweight\u7684\u503c\u53ef\u4ee5\u662f\u6b63\u6570\u4e5f\u53ef\u4ee5\u662f\u8d1f\u6570\uff0c\u56e0\u6b64keepalived\u5728\u4f7f\u7528vrrp_script\u6a21\u5757\u65f6\uff0c\u96c6\u7fa4\u7684\u9009\u4e3e\u7b56\u7565\u8981\u5206\u4ee5\u4e0b\u4e24\u79cd\u60c5\u51b5\u8bf4\u660e\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1\u3001&#8221;weight&#8221;\u7684\u503c\u4e3a\u6b63\u6570\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728vrrp_script\u4e2d\u6307\u5b9a\u7684\u811a\u672c\u5982\u679c\u68c0\u6d4b\u6210\u529f(\u8fd4\u56de\u503c\u4e3a0)\uff0c\u90a3\u4e48master\u8282\u70b9\u7684\u6743\u503c\u5c06\u662f&#8221;weight&#8221;\u503c\u548c&#8221;priority&#8221;\u503c\u7684\u548c\uff0c\u5982\u679c\u68c0\u6d4b\u5931\u8d25(\u8fd4\u56de\u503c\u4e3a1)\uff0c\u90a3\u4e48master\u8282\u70b9\u7684\u6743\u503c\u5c06\u4fdd\u6301\u4e3a&#8221;priority&#8221;\u7684\u503c\uff0c\u56e0\u6b64\u5207\u6362\u7b56\u7565\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f53master\u8282\u70b9\u7684&#8221;vrrp_script&#8221; \u4e2d\u811a\u672c\u68c0\u6d4b\u5931\u8d25\u65f6(\u8fd4\u56de\u503c1)\uff0c\u5982\u679cmaster\u4e2d\u7684&#8221;priority&#8221;\u503c\u5c0f\u4e8ebackup\u4e2d\u7684&#8221;weight&#8221;\u4e0e&#8221;priority&#8221;\u503c\u4e4b\u548c\uff0c\u5c06\u53d1\u751f\u4e3b\u5907\u5207\u6362\uff0c\u5426\u5219\u4e0d\u5207\u6362<\/li><li>\u5f53master\u8282\u70b9\u7684&#8221;vrrp_scrity&#8221;\u4e2d\u811a\u672c\u68c0\u6d4b\u6210\u529f\u65f6(\u8fd4\u56de\u503c0)\uff0c\u5982\u679cmaster\u8282\u70b9\u7684&#8221;weight&#8221;\u7684\u503c\u4e0e&#8221;priority&#8221;\u7684\u503c\u4e4b\u548c\u5927\u4e8ebacku\u4e2d&#8221;weight&#8221;\u4e0e&#8221;priority\u503c\u4e4b\u548c\uff0c\u4e0d\u53d1\u751f\u5207\u6362\uff0c\u5426\u4fa7\u5207\u6362<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2\u3001&#8221;weight&#8221;\u7684\u503c\u4e3a\u8d1f\u6570\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728&#8221;vrrp_script&#8221;\u4e2d\u6307\u5b9a\u7684\u811a\u672c\u5982\u679c\u68c0\u6d4b\u6210\u529f\uff0c\u90a3\u4e48master\u8282\u70b9\u7684\u6743\u503c\u4ecd\u4e3a&#8221;priority&#8221;\u503c\uff0c\u5f53\u68c0\u6d4b\u5931\u8d25\u65f6\uff0cmaster\u7684\u503c\u5c06\u662f&#8221;weight&#8221;\u4e0e&#8221;priority&#8221;\u7684\u503c\u4e4b\u5dee\uff0c\u56e0\u6b64\u5207\u6362\u7b56\u7565\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f53master\u8282\u70b9\u7684vrrp_script\u811a\u672c\u68c0\u6d4b\u5931\u8d25\u65f6(\u8fd4\u56de\u503c1)\uff0c\u5982\u679cmaster\u8282\u70b9\u7684priority\u7684\u503c\u4e0eweight\u7684\u503c\u4e4b\u5dee\u5c0f\u4e8ebackup\u8282\u70b9\u7684priority\u7684\u503c\uff0c\u5c06\u53d1\u751f\u4e3b\u5907\u5207\u6362\uff0c\u5426\u5219\u4e0d\u5207\u6362<\/li><li>\u5f53master\u8282\u70b9\u7684vrrp_scrity\u7684\u811a\u672c\u68c0\u6d4b\u6210\u529f\u65f6(\u8fd4\u56de\u503c0),\u5982\u679cmaster\u8282\u70b9\u7684priority\u7684\u503c\u5927\u4e8ebackup\u8282\u70b9\u7684priority\u7684\u503c\uff0c\u4e3b\u8282\u70b9\u4f9d\u65e7\u4e3a\u4e3b\u8282\u70b9\uff0c\u4e0d\u5207\u6362\uff0c\u5426\u5219\u5207\u6362<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\u7684\u4f8b\u5b50\uff0c\u7b26\u5408\u7b2c\u4e00\u79cd\u7b56\u7565\uff0cweight\u7684\u503c\u4e3a\u6b63\u6570\uff0c\u5f53Mysql\u670d\u52a1\u5173\u95ed\u540e\uff0cmaster\u4e2d\u7684priority\u7684\u503c(100)\u4f9d\u65e7\u5927\u4e8ebackup\u8282\u70b9\u4e2dweight\u4e0epriority\u7684\u503c\u4e4b\u548c(90)\uff0c\u56e0\u6b64\u4e0d\u4f1a\u53d1\u751f\u4e3b\u5907\u5207\u6362<\/p>\n\n\n\n<p class=\"has-background has-luminous-vivid-amber-background-color wp-block-paragraph\">*\u6ce8\u610f\uff1a\u5bf9\u4e8eweight\u7684\u503c\uff0c\u6709\u4e00\u4e2a\u7b80\u5355\u7684\u6807\u51c6\uff0c\u5373&#8221;weight&#8221;\u7684\u503c\u7684\u7edd\u5bf9\u503c\u8981\u5927\u4e8emaster\u548cbackup\u8282\u70b9\u7684priority\u7684\u503c\u4e4b\u5dee\uff0c\u4e0a\u8ff0\u4f8b\u5b50\u53ea\u8981\u5c06weight\u7684\u503c\u8bbe\u7f6e\u4e3a\u5927\u4e8e20\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728keepalived\u4e2d\uff0c\u5e76\u6ca1\u6709\u4e25\u683c\u610f\u4e49\u4e0a\u7684\u4e3b\u8282\u70b9\u548c\u5907\u8282\u70b9\uff0c\u867d\u7136\u53ef\u4ee5\u5728keepalived.conf\u4e2d\u914d\u7f6est [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":3479,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,22],"tags":[],"class_list":["post-3476","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-server"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/3476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=3476"}],"version-history":[{"count":3,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/3476\/revisions"}],"predecessor-version":[{"id":3480,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/3476\/revisions\/3480"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/3479"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}