{"id":592,"date":"2022-08-24T11:36:57","date_gmt":"2022-08-24T03:36:57","guid":{"rendered":"https:\/\/frogvps.com\/?p=592"},"modified":"2022-08-24T11:36:57","modified_gmt":"2022-08-24T03:36:57","slug":"lvs%e7%9a%84dr%e6%a8%a1%e5%bc%8f%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/frogvps.com\/?p=592","title":{"rendered":"LVS\u7684DR\u6a21\u5f0f\u642d\u5efa"},"content":{"rendered":"\n<p>DR\u6a21\u578b\u4e2d\u5404\u4e3b\u673a\u4e0a\u5747\u9700\u8981\u914d\u7f6eVIP\uff0c\u89e3\u51b3\u5730\u5740\u51b2\u7a81\u7684\u65b9\u5f0f\u6709\u4e09\u79cd\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u5728\u524d\u7aef\u7f51\u5173\u505a\u9759\u6001\u7ed1\u5b9a<\/li><li>\u5728\u5404RS\u4f7f\u7528arptables<\/li><li>\u5728\u5404RS\u4fee\u6539\u5185\u6838\u53c2\u6570\uff0c\u6765\u9650\u5236arp\u54cd\u5e94\u548c\u901a\u544a\u7684\u7ea7\u522b<\/li><\/ol>\n\n\n\n<p><strong>\u9650\u5236\u54cd\u5e94\u7ea7\u522b\uff1aarp_ignore<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>0\uff1a\u9ed8\u8ba4\u503c\uff0c\u54cd\u5e94\u4efb\u610f\u7f51\u5361\u4e0a\u63a5\u6536\u5230\u7684\u5bf9\u672c\u673aIP\u5730\u5740\u7684arp\u8bf7\u6c42\uff08\u5305\u62ec\u73af\u56de\u7f51\u5361\u4e0a\u7684\u5730\u5740\uff09<\/li><li>1\uff1a\u53ea\u54cd\u5e94\u76ee\u7684IP\u5730\u5740\u4e3a\u63a5\u6536\u7f51\u5361\u4e0a\u7684\u672c\u5730\u5730\u5740\u7684arp\u8bf7\u6c42<\/li><\/ul>\n\n\n\n<p><strong>\u9650\u5236\u901a\u544a\u7ea7\u522b\uff1aarp_announce<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>0\uff1a\u9ed8\u8ba4\u503c\uff0c\u628a\u672c\u673a\u6240\u6709\u63a5\u53e3\u7684\u6240\u6709\u4fe1\u606f\u5411\u6bcf\u4e2a\u63a5\u53e3\u7684\u7f51\u7edc\u8fdb\u884c\u901a\u544a<\/li><li>1\uff1a\u5c3d\u91cf\u907f\u514d\u5c06\u63a5\u53e3\u4fe1\u606f\u5411\u975e\u76f4\u63a5\u8fde\u63a5\u7f51\u7edc\u8fdb\u884c\u901a\u544a<\/li><li>2\uff1a\u5fc5\u987b\u907f\u514d\u5c06\u63a5\u53e3\u4fe1\u606f\u5411\u975e\u672c\u7f51\u7edc\u8fdb\u884c\u901a\u544a RS \u4e00\u822c\u81f3\u5c11\u4e24\u4e2a\u7aef\u53e3 \u4e24\u4e2aip\uff0ceth0 \u6709ip\uff0clo: 0\u4e5f\u7ed1\u5b9a\u4e86\u4e00\u4e2aVIP\u3002 \u6839\u636earp\u534f\u8bae\uff0carp \u8bf7\u6c42\u5305\u4e2d\u5fc5\u987b\u5305\u542b\u6e90\u4e3b\u673a\u7684IP\u5730\u5740\u548cMac\u5730\u5740\uff0c\u5bf9\u65b9\u6536\u5230\u8bf7\u6c42\u5305\u540e\uff0c\u8bb0\u5f55\u4e0b\u8be5\u6e90\u5730\u5740\u548cMac\u5730\u5740\uff0c\u5efa\u7acb\u4e00\u5bf9\u4e00\u7684\u6620\u5c04\uff0c\u90a3\u4e48\u5bf9\u4e8e\u8fd9\u79cd\u591aIP\u7684\u60c5\u51b5\uff0cRS\u53d1\u9001arp\u8bf7\u6c42\u62a5\u7684\u65f6\u5019\u8be5\u5982\u4f55\u53d6\u820d\uff0c\u5c06\u54ea\u4e2aip\u4f5c\u4e3a\u6e90\u5730\u5740\uff1f \u53c2\u6570arp_anonunce \u6b63\u597d\u662f\u7528\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\uff0carp_announce=2 \u5b98\u65b9\u8868\u8ff0\u4e3a\u4f7f\u7528\u6700\u9002\u5f53\u7684\u672c\u5730\u5730\u5740\uff0c\u5176\u5b9e\u5c31\u662f\u5c06eth0\u4e0a\u7684IP\u4f5c\u4e3a\u6e90\u5730\u5740\u3002\u5982\u679c\u5c06VIP\u4f5c\u4e3a\u6e90\u5730\u5740\uff0c\u5bf9\u65b9\u5c31\u4f1a\u5c06VIP\u4e0eRS\u7684mac\u5730\u5740\u6620\u5c04\u8d77\u6765\uff0c\u5bfc\u81f4\u8bf7\u6c42\u5305\u90fd\u53d1\u7ed9RS\uff0c\u800c\u4e0d\u7ecf\u8fc7LVS<\/li><\/ul>\n\n\n\n<p><strong>\u914d\u7f6e\u8981\u70b9<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Director \u670d\u52a1\u5668\u91c7\u7528\u53ccIP\u6865\u63a5\u7f51\u7edc\uff0c\u4e00\u4e2a\u662fVIP\uff0c\u4e00\u4e2aDIP<\/li><li>Web\u670d\u52a1\u5668\u91c7\u7528\u548cDIP\u76f8\u540c\u7684\u7f51\u6bb5\u548cDirector\u8fde\u63a5<\/li><li>\u6bcf\u4e2aWeb\u670d\u52a1\u5668\u914d\u7f6eVIP<\/li><li>\u6bcf\u4e2aweb\u670d\u52a1\u5668\u53ef\u4ee5\u51fa\u5916\u7f51<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"454\" src=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a1-1024x454.jpg\" alt=\"\" class=\"wp-image-593\" srcset=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a1-1024x454.jpg 1024w, https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a1-300x133.jpg 300w, https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a1-768x341.jpg 768w, https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a1.jpg 1057w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>LVS DR \u6a21\u5f0f<\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u73af\u5883\u51c6\u5907<\/h2>\n\n\n\n<p>\u5ba2\u6237\u7aef<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eth0: \u4ec5\u4e3b\u673a 192.168.10.6\/24 GW:192.168.10.200<\/code><\/pre>\n\n\n\n<p>\u8def\u7531\u5668<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eth0: NAT 10.0.0.200\/24\neth1: \u4ec5\u4e3b\u673a 192.168.10.200\/24\n\u542f\u7528 IP_FORWARD<\/code><\/pre>\n\n\n\n<p>LVS<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eth0: NAT DIP 10.0.0.8\/24 GW: 10.0.0.200\nlo: VIP 10.0.0.100\/32<\/code><\/pre>\n\n\n\n<p>RS1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eth0: NAT 10.0.0.7\/24 GW\uff1a10.0.0.200\nlo: VIP 10.0.0.100\/32<\/code><\/pre>\n\n\n\n<p>RS2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eth0: NAT 10.0.0.17\/24 GW\uff1a10.0.0.200\nlo: VIP 10.0.0.100\/32<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f51\u7edc\u914d\u7f6e<\/h2>\n\n\n\n<p>centos \u7f51\u5361\u914d\u7f6e\u6587\u4ef6\uff1a\/etc\/sysconfig\/network-scripts<\/p>\n\n\n\n<p><strong>\u5ba2\u6237\u7aef<\/strong><\/p>\n\n\n\n<p>ifcfg-eth0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>BOOTPROTO=static\nNAME=eth0\nDEVICE=eth0\nONBOOT=yes\nIPADDR=192.168.10.6\nPREFIX=24\nGATEWAY=192.168.10.200<\/code><\/pre>\n\n\n\n<p><strong>\u8def\u7531\u5668<\/strong><\/p>\n\n\n\n<p>ifcfg-eth0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DEVICE=eth0\nNAME=eth0\nBOOTPROTO=static\nIPADDR=10.0.0.200\nPREFIX=24\nONBOOT=yes\nGATEWAY=10.0.0.2<\/code><\/pre>\n\n\n\n<p>ifcfg-eth1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DEVICE=eth1\nNAME=eth1\nBOOTPROTO=static\nIPADDR=192.168.10.200\nPREFIX=24\nONBOOT=yes<\/code><\/pre>\n\n\n\n<p><strong>LVS<\/strong><\/p>\n\n\n\n<p>ifcfg-eth0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DEVICE=eth0\nNAME=eth0\nBOOTPROTO=static\nIPADDR=10.0.0.8\nPREFIX=24\nGATEWAY=10.0.0.200\nONBOOT=yes<\/code><\/pre>\n\n\n\n<p><strong>RS1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DEVICE=eth0\nNAME=eth0\nBOOTPROTO=static\nIPADDR=10.0.0.7\nPREFIX=24\nGATEWAY=10.0.0.200\nONBOOT=yes<\/code><\/pre>\n\n\n\n<p><strong>RS2<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DEVICE=eth0\nNAME=eth0\nBOOTPROTO=static\nIPADDR=10.0.0.17\nPREFIX=24\nGATEWAY=10.0.0.200\nONBOOT=yes<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u670d\u52a1\u914d\u7f6e<\/h2>\n\n\n\n<p><strong>LVS<\/strong><\/p>\n\n\n\n<p>-g \u8868\u793aDR\u6a21\u5f0f\uff08\u9ed8\u8ba4\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ifconfig lo:1 10.0.0.100\/32\nyum -y install ipvsadm\nipvsadm -A -t 10.0.0.100:80 -s rr\nipvsadm -a -t 10.0.0.100:80 -r 10.0.0.7:80 -g\nipvsadm -a -t 10.0.0.100:80 -r 10.0.0.17:80 -g<\/code><\/pre>\n\n\n\n<p><strong>\u8def\u7531\u5668<\/strong><\/p>\n\n\n\n<p>\u5f00\u542fip_forward<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/etc\/sysctl.conf\nnet.ipv4.ip_forward = 1\nsysctl -p<\/code><\/pre>\n\n\n\n<p><strong>RS1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum -y install httpd\necho rs1 10.0.0.7 &gt;\/var\/www\/html\/index.html \nsystemctl start httpd\necho 1 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_ignore\necho 1 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_ignore\necho 2 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_announce\necho 2 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_announce\nifconfig lo:1 10.0.0.100\/32<\/code><\/pre>\n\n\n\n<p><strong>RS2<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum -y install httpd\necho rs2 10.0.0.17 &gt;\/var\/www\/html\/index.html \nsystemctl start httpd\necho 1 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_ignore\necho 1 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_ignore\necho 2 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_announce\necho 2 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_announce\nifconfig lo:1 10.0.0.100\/32<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6d4b\u8bd5\u8bbf\u95ee<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>while :;do curl 10.0.0.100;sleep 0.5;done<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"883\" height=\"537\" src=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a2.jpg\" alt=\"\" class=\"wp-image-594\" srcset=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a2.jpg 883w, https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a2-300x182.jpg 300w, https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220824a2-768x467.jpg 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><figcaption>\u6d4b\u8bd5\u8bbf\u95ee\u6210\u529f<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5feb\u901f\u914d\u7f6eVIP\u7684shell\u811a\u672c<\/h2>\n\n\n\n<p>\u76f4\u63a5\u628a\u53d8\u91cf\u4fee\u6539\u4e0b\u5c31\u80fd\u7528<\/p>\n\n\n\n<p>lvs_dr_rs.sh<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#Author: qinwa\nvip=10.0.0.100\nmask='255.255.255.255'\ndev=lo:1\ncase $1 in\nstart)\necho 1 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_ignore\necho 1 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_ignore\necho 2 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_announce\necho 2 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_announce\nifconfig $dev $vip netmask $mask\necho \"The RS Server is Ready!\"\n;;\nstop)\nifconfig $dev down\necho 0 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_ignore\necho 0 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_ignore\necho 0 &gt; \/proc\/sys\/net\/ipv4\/conf\/all\/arp_announce\necho 0 &gt; \/proc\/sys\/net\/ipv4\/conf\/lo\/arp_announce\necho \"The RS Server is Canceled!\"\n;;\n*)\necho \"Usage: $(basename $0) start|stop\"\nexit 1\n;;\nesac<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>DR\u6a21\u578b\u4e2d\u5404\u4e3b\u673a\u4e0a\u5747\u9700\u8981\u914d\u7f6eVIP\uff0c\u89e3\u51b3\u5730\u5740\u51b2\u7a81\u7684\u65b9\u5f0f\u6709\u4e09\u79cd\uff1a \u5728\u524d\u7aef\u7f51\u5173\u505a\u9759\u6001\u7ed1\u5b9a \u5728\u5404RS\u4f7f\u7528arptables \u5728\u5404RS\u4fee\u6539\u5185\u6838\u53c2\u6570\uff0c\u6765\u9650\u5236arp\u54cd\u5e94\u548c\u901a\u544a\u7684\u7ea7\u522b \u9650\u5236\u54cd\u5e94\u7ea7\u522b\uff1aarp_ignore 0\uff1a\u9ed8\u8ba4\u503c\uff0c\u54cd\u5e94\u4efb\u610f\u7f51\u5361\u4e0a\u63a5\u6536\u5230\u7684&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[46,19],"topic":[],"class_list":["post-592","post","type-post","status-publish","format-standard","hentry","category-linux","tag-lvs","tag-19"],"_links":{"self":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/592","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=592"}],"version-history":[{"count":2,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/592\/revisions"}],"predecessor-version":[{"id":596,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/592\/revisions\/596"}],"wp:attachment":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=592"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}