How to install and configure lvs in centos

Source: Internet
Author: User
Cthis article mainly introduces how to install and configure lvs in centos. all of the following operations need to disable Selenge and iptables. for details, refer to CentOS.

I. lvs-nat mode

Network configuration:

Copy codeThe code is as follows:
Lvs-server eth0: host-only adapter 192.168.56.101
Lvs-server eth1: Internal 192.168.0.1
Real-server-1 eth0: Internal 192.168.0.2
Real-server-2 eth0: Internal 192.168.0.3

 
Lvs-server:
1. install ipvsadm software

Copy codeThe code is as follows:
Yum-y install ipvsadm *
Echo 1>/proc/sys/net/ipv4/ip_forward vro function, ip forwarding
Ipvsadm-C
Ipvsadm-At 192.168.56.101: 80-s rr call mode
Ipvsadm-at 192.168.56.101: 80-r 192.168.0.2-m
Ipvsadm-at 192.168.56.101: 80-r 192.168.0.3-m
Ipvsadm-L-n

2. real-server-1:

Copy codeThe code is as follows:
Ifconfig eth0 192.168.0.2 netmask 255.255.255.0
Route add default gw 192.168.0.1

3. real-server-2

Copy codeThe code is as follows:
Ifconfig eth0 192.168.0.3 netmask 255.255.255.0
Route add default gw 192.168.0.1
Route-n View route table

 
II. lvs-ipturn

Network configuration:

Copy codeThe code is as follows:
Lvs-server eth0: host-only adapter 192.168.56.101
Real-server-1 eth0: host-only adapter 192.168.56.102
Real-server-2 eth0: host-only adapter 192.168.56.103

Lvs-server:
Configure virtual ip (vip)

Copy codeThe code is as follows:
Ifconfig tunl0 192.168.56.10 netmask 255.255.255.255 up
Route add-host 192.168.56.10 dev tunl0

Ivsadm-C
Ipvsadm-At 192.168.56.10: 80-s rr
Ipvsadm-at 192.168.56.10: 80-r 192.168.56.102-I
Ipvsadm-at 192.168.56.10: 80-r 192.168.56.103-I
Ipvsadm-L-n

Real-server-1:

Copy codeThe code is as follows:
Ifconfig tunl0 192.168.56.10 netmask 255.255.255.255 up
Route add-host 192.168.56.10 dev tunl0
Echo 1>/proc/sys/net/ipv4/conf/tunl0/arp_ignore
Echo 2>/proc/sys/net/ipv4/conf/tunl0/arp_announce
Echo 1>/proc/sys/net/ipv4/conf/all/arp_ignore
Echo 2>/proc/sys/net/ipv4/conf/all/arp_announce

Real-server-2:

Copy codeThe code is as follows:
Ifconfig tunl0 192.168.56.10 netmask 255.255.255.255 up
Route add-host 192.168.56.10 dev tunl0
Echo 1>/proc/sys/net/ipv4/conf/tunl0/arp_ignore
Echo 2>/proc/sys/net/ipv4/conf/tunl0/arp_announce
Echo 1>/proc/sys/net/ipv4/conf/all/arp_ignore
Echo 2>/proc/sys/net/ipv4/conf/all/arp_announce

 
III. lvs-dr

Network configuration:

Copy codeThe code is as follows:
Lvs-server eth0: host-only adapter 192.168.56.101

Real-server-1 eth0: host-only adapter 192.168.56.102

Real-server-2 eth0: host-only adapter 192.168.56.103

Lvs-server:

Ifconfig eth0: 0 192.168.56.10 netmask 255.255.255.255

Route add-host 192.168.56.10 dev eth0: 0

Ipvs:

Copy codeThe code is as follows:
Ipvsadm-C ipvsadm-At 192.168.56.10: 80-s rr ipvsadm-at 192.168.56.10: 80-r 192.168.56.102-g ipvsadm-at 192.168.56.10: 80-r 192.168.56.103-g ipvsadm-L-n

Real-server-1: ifconfig lo: 0 192.168.56.10 netmask 255.255.255.255 route add-host 192.168.56.10 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

Real-server-2: ifconfig lo: 0 192.168.56.10 netmask 255.255.255.255 route add-host 192.168.56.10 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

Related Article

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.