There are many LVS + keepalived configuration memo LVS + keepalived documents for implementing load balancing. here we will not repeat the description, but only record what is easy to forget during the configuration process. 1. make sure that the IP forwarding function enables Shell code # sysctl-a | grepip_forwardnet.ipv4.ip... there are many LVS + keepalived configuration memo LVS + keepalived documents for implementing load balancing. here we will not repeat the description, but only record what is easy to forget during the configuration process. 1. make sure that the IP forwarding function enables Shell code # sysctl-a | grep ip_forward net. ipv4.ip _ forward = 1 method there are san types 1) sysctl net. ipv4.ip _ forward = 1 2) echo "1">/proc/sys/net/ipv4/ip_forward 3) modify sysctl. conf, net. ipv4.ip _ forward = 1, run the sysctl-p Command 2. the virtual ip configuration keepalived uses the RD forwarding mode to test the topology. linux director ip: 192.168.1.199 vip: 192.168.1.210 ++ ++ | real server ip address: 192.168.1.13 ip: 192.168.1.14 vip: 192.168.1.210 vip: 192.168.1.210 lvs client is the real server vip, to be consistent with the linux director vip lvs-real.sh Shell code #! /Bin/bash VIP = 192.168.1.210/etc/rc. d/init. d/functions case "$1" in start) ifconfig lo: 0 $ VIP netmask 255.255.255.255.255 broadcast $ VIP/sbin/route add-host $ VIP dev lo: 0 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 sysctl-p >/dev/null 2> & 1 echo "Re AlServer Start OK "; stop) ifconfig lo: 0 down route del $ VIP>/dev/null 2> & 1 echo "0">/proc/sys/net/ipv4/conf/lo/arp_ignore echo "0">/ proc/sys/net/ipv4/conf/lo/arp_announce echo "0">/proc/sys/net/ipv4/conf/all/arp_ignore echo "0">/proc/ sys/net/ipv4/conf/all/arp_announce echo "RealServer Stoped ";; *) echo "Usage: $0 {start | stop}" exit 1 esac exit 0 keepalived on linux ctor. conf Shell code! Configuration File for keepalived global_defs {icationication_email {# huaying@staff.sina.com.cn} # Small Alexandre.Cassen@firewall.loc # smtp_server 127.0.0.1 # Small 30 router_id regular} virtual_server 192.168.1.210 80 {delay_loop 3 large rr DR large 120 protocol TCP real_server 192.168.1.13 {weight 100 TCP_CHECK {connect_timeout 3 Nb_get_retry 3 listen 3 connect_port 80} real_server 192.168.1.14 80 {weight 100 TCP_CHECK {connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80} note: The lvs is responsible for balancing the function, vrrp_instance is not configured. In practice, you can configure dual-linux ctor. Therefore, manually add vip: 192.168.1.210 on linux ctor. you can use the following Shell code # ip addr add 192.168.1.210 dev eth0 3. in keepalived DR forwarding mode, you must set the ip address of the real server and virtual ip address in the same network segment. linux ctor needs to install ipvsadm. after ipvsadm is started, you can check whether it is loaded with Shell code # lsmod | grep ip_vs 94742 5 # lpvsadm-ln IP Virtual Server version 1.2.1 (size = 4096) prot LocalAddress: Port sched1_flags-> RemoteAddress: Port Forward Weight ActiveConn InActConn TCP 192.168.1.210: 80 rr persistent 120-> 192.168.1.13: 80 Route 100 0 0-> 192.168.1.14: 80 Route 100 0 0 5. if the configuration is correct, consider whether to compile the S s framework into keepalived 6. if not, consider other reasons. xxx todo: configure the NAT forwarding mode before testing.
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