{"id":160,"date":"2019-03-05T14:32:20","date_gmt":"2019-03-05T06:32:20","guid":{"rendered":"https:\/\/www.aiqinqin.info\/?p=160"},"modified":"2019-03-05T14:33:05","modified_gmt":"2019-03-05T06:33:05","slug":"keepalived-lvs-dr%e6%a8%a1%e5%bc%8f%e6%90%ad%e5%bb%ba%e4%b8%80%e4%b8%aa%e9%ab%98%e5%8f%af%e7%94%a8%e7%9a%84nginx%e8%b4%9f%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/www.aiqinqin.info\/?p=160","title":{"rendered":"keepalived  LVS DR\u6a21\u5f0f\u642d\u5efa\u4e00\u4e2a\u9ad8\u53ef\u7528\u7684nginx\u8d1f\u8f7d"},"content":{"rendered":"<blockquote><p>\n  LVS\u4f5c\u4e3a\u7b2c\u56db\u5c42\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u6548\u7387\u6bd4NGINX HA\u7b49\u65b9\u5f0f\u642d\u5efa\u7684\u8d1f\u8f7d\u5747\u8861\u6548\u7387\u8981\u9ad8\u4e9b\uff0c\u5728\u4f01\u4e1a\u4e2d\u4f7f\u7528DR\u6a21\u5f0f\u53c8\u6bd4\u4f7f\u7528NAT\u6a21\u5f0f\u7684\u573a\u666f\u66f4\u5e7f\uff0c\u4e0b\u9762\u5c31\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u9a8c\u3002\n<\/p><\/blockquote>\n<ul>\n<li>\u73af\u5883\u51c6\u5907<\/li>\n<\/ul>\n<pre><code class=\"\">vip 172.16.50.65\nReal server 1: 172.16.50.66\nReal server 2: 172.16.50.67\nDirector Server: 172.16.50.10(MASTER)\nDirector Server: 172.16.50.11(BACKUP)\n<\/code><\/pre>\n<ul>\n<li>Director Server\u5173\u95edselinux\u548c\u9632\u706b\u5899\u529f\u80fd \u5b89\u88c5 keepalived \u548c ipvsadm<\/li>\n<li>172.16.50.10\u4e0a\u9762keepalived.conf\u7684\u914d\u7f6e\u6587\u4ef6\u4e3a\uff1a<\/li>\n<\/ul>\n<pre><code class=\"\">! Configuration File for keepalived\n\nglobal_defs {\n   notification_email {\n    qq@qq.com\n   }\n   notification_email_from Alexandre.Cassen@firewall.loc\n   smtp_server 192.168.200.1\n   smtp_connect_timeout 30\n   router_id LVS_DEVEL\n   vrrp_skip_check_adv_addr\n   #vrrp_strict\n   vrrp_garp_interval 0\n   vrrp_gna_interval 0\n}\n\nvrrp_instance VI_1 {\n    state MASTER\n    interface ens32\n    virtual_router_id 51\n    priority 100\n    advert_int 1\n    authentication {\n        auth_type PASS\n        auth_pass yourpassword\n    }\n    virtual_ipaddress {\n        172.16.50.65\n    }\n}\n\nvirtual_server 172.16.50.65 80 {\n    delay_loop 6\n    lb_algo rr\n    lb_kind DR\n    #persistence_timeout 50\n    protocol TCP\n\n    real_server 172.16.50.66 80 {\n        weight 1\n        TCP_CHECK {\n            connect_port 80\n            connect_timeout 2\n        }\n    }\n\n    real_server 172.16.50.67 80 {\n        weight 2\n        TCP_CHECK {\n            connect_port 80\n            connect_timeout 2\n        }\n    }\n}\n\n<\/code><\/pre>\n<ul>\n<li>172.16.50.11\u4e0a\u9762keepalived.conf\u7684\u914d\u7f6e\u6587\u4ef6\u4e3a\uff1a<\/li>\n<\/ul>\n<pre><code class=\"\">! Configuration File for keepalived\n\nglobal_defs {\n   notification_email {\n    qq@qq.com\n   }\n   notification_email_from Alexandre.Cassen@firewall.loc\n   smtp_server 192.168.200.1\n   smtp_connect_timeout 30\n   router_id LVS_DEVEL\n   vrrp_skip_check_adv_addr\n   #vrrp_strict\n   vrrp_garp_interval 0\n   vrrp_gna_interval 0\n}\n\nvrrp_instance VI_1 {\n    state BACKUP\n    interface ens32\n    virtual_router_id 51\n    priority 90\n    advert_int 1\n    authentication {\n        auth_type PASS\n        auth_pass yourpassword\n    }\n    virtual_ipaddress {\n        172.16.50.65\n    }\n}\n\nvirtual_server 172.16.50.65 80 {\n    delay_loop 6\n    lb_algo rr\n    lb_kind DR\n    #persistence_timeout 50\n    protocol TCP\n\n    real_server 172.16.50.66 80 {\n        weight 1\n        TCP_CHECK {\n            connect_port 80\n            connect_timeout 2\n        }\n    }\n\n    real_server 172.16.50.67 80 {\n        weight 2\n        TCP_CHECK {\n            connect_port 80\n            connect_timeout 2\n        }\n    }\n}\n\n<\/code><\/pre>\n<ul>\n<li>\u5728Real server\u4e2d\u914d\u7f6eNGINX VIP\u548c\u6dfb\u52a0\u8def\u7531<\/li>\n<\/ul>\n<pre><code class=\"\">ifconfig lo:0 172.16.50.65 netmask 255.255.255.255 broadcast 172.16.50.65\nroute add -host 172.16.50.65  dev lo:0\n<\/code><\/pre>\n<ul>\n<li>\u5728Real server\u4fee\u6539\u5185\u6838\u53c2\u6570\uff0c\u63a7\u5236Real server\u7684\u54cd\u5e94\u6a21\u5f0f<\/li>\n<\/ul>\n<pre><code class=\"\">net.ipv4.conf.all.arp_ignore=1\nnet.ipv4.conf.lo.arp_ignore=1\nnet.ipv4.conf.all.arp_announce=2\nnet.ipv4.conf.lo.arp_announce=2\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>LVS\u4f5c\u4e3a\u7b2c\u56db\u5c42\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u6548\u7387\u6bd4NGINX HA\u7b49\u65b9\u5f0f\u642d\u5efa\u7684\u8d1f\u8f7d\u5747\u8861\u6548\u7387\u8981\u9ad8\u4e9b\uff0c\u5728\u4f01\u4e1a\u4e2d\u4f7f\u7528DR\u6a21\u5f0f\u53c8\u6bd4\u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160"}],"version-history":[{"count":3,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":163,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions\/163"}],"wp:attachment":[{"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiqinqin.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}