2018-4-11 Linux Learning Notes

Source: Internet
Author: User
Tags haproxy

18.11 LVS Dr Mode construction
  • The LVS NAT mode requires fewer public IP addresses and is suitable for up to 10 servers. Then the DR mode is more suitable for large-scale speech.
  • (1) Prepare three machines
  • Dispatcher, also known as the Scheduler (dir)
    192.168.168.129
  • Rs1
    192.168.168.130
  • Rs2
    192.168.168.131
  • VIP (need to set up on all three machines)
    192.168.168.200

  • (2) Scripting on Dir
  • vim/usr/local/sbin/lvs_dr.sh
  • Add content as follows
    ----------------------------------------------------------------------------------------------
    #! /bin/bash
    Echo 1 >/proc/sys/net/ipv4/ip_forward
    ipv=/usr/sbin/
    Ipvsadm
    vip=192.168.168.200
    rs1=192.168.168.130
    rs2=192.168.168.131
    #注意这里的网卡名字
    Ifdown Ens33
    Ifup Ens33
    #以上2句作用是让再次执行脚本时不用再次设置vip
    Ifconfig ens33:2 $VIP broadcast $VIP netmask 255.255.255.255 up
    Route add-host $vip Dev ens33:2
    $IPV-C
    $IPV-A-t $VIP: 80-s WRR
    $IPV-A-t $vip: 80-r $rs 1:80-g-W 1
    $IPV-A-t $vip: 80-r $rs 2:80-g-W 1
    ----------------------------------------------------------------------------------------------
    Note: -G in the last 2 lines above represents the DR Mode .
  • Set the execution script to complete
    sh/usr/local/sbin/lvs_dr.sh

  • (3) scripts are also written on both Rs
  • vim/usr/local/sbin/lvs_rs.sh
  • Add content as follows
    ----------------------------------------------------------------------------------------------------------
    #/bin/bash
    vip=192.168.168.200
    #把vip绑定在lo上, is to implement RS directly return the results to the client
    Ifdown Lo
    Ifup Lo
    Ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
    Route Add-host $vip lo:0
    #以下操作为更改arp内核参数 to enable RS to send the MAC address to the client successfully
    #参考文档www. cnblogs.com/lgfeng/archive/2012/10/16/2726308.html
    echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
    echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
    ---------------------------------------------------------------------------------------------------------
  • Execute these scripts on Dir and two RS respectively
    sh/usr/local/sbin/lvs_rs.sh
  • (4) Dr Mode Test
    Access VIP 192.168.168.200 in the browser
18.12 keepalived + LVS DR
    • Extended Learning:
      Haproxy+keepalived http://blog.csdn.net/xrt95050/article/details/40926255
      Nginx, LVS, haproxy comparison http://www.csdn.net/article/2014-07-24/2820837
      Custom Script Vrrp_script http://my.oschina.net/hncscwc/blog/158746 in keepalived
      The LVS Dr Mode only uses a public IP implementation method http://storysky.blog.51cto.com/628458/338726

2018-4-11 Linux Learning Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.