LVS-DR for Centos SERVER CLUSTERS

Source: Internet
Author: User

Topology:


1. LVS configuration script:

Installation required: ipvsadm-1.24-10.i386.rpm

Vi/etc/rc. d/init. d/lvsdr
#! /Bin/bash
Vip = 192.168.1.249
Web1 = 192.168.1.20.
Web2 = 192.168.1.252
./Etc/rc. d/init. d/functions
Case "$1" in
Start)
Echo "start lvs-dr"
Echo "1">/proc/sys/net/ipv4/ip_forward
Ifconfig eth0: 0 $ {vip} broadcast $ {vip} netmask 255.255.255.255 up
Route add-host $ {vip} dev eth0: 0
Ipvsadm-C
Ipvsadm-A-t $ {vip}: 80-s rr
Ipvsadm-a-t $ {vip}: 80-r $ {web1}: 80-g
Ipvsadm-a-t $ {vip}: 80-r $ {web2}: 80-g
Ipvsadm
;;
Stop)
Echo "stop lvs-dr"
Echo "0">/proc/sys/net/ipv4/ip_forward
Ipvsadm-C
Ifconfig eth0: 0 down
;;

*)
Echo "Usage: $0 {start | stop }"
Exit 1
Esac

Start:

[Root @ linux-1 lvs] # service lvsdr start
Start lvs-dr
IP Virtual Server version 1.2.1 (size = 4096)
Prot LocalAddress: Port sched1_flags
-> RemoteAddress: Port Forward Weight ActiveConn InActConn
TCP 192.168.1.249: http rr
-> 192.168.1.252: http Route 1 0 0
-> 192.168.1.133: http Route 1 0 0

Ii. web1 configuration script

Vi/etc/rc. d/init. d/lvsweb
#! /Bin/bash
Vip = 192.168.1.249
./Etc/rc. d/init. d/functions
Case "$1" in

Start)
Echo "start lvs-web1"
Ifconfig lo: 0 $ {vip} broadcast $ {vip} netmask 255.255.255.255 up
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
;;

Stop)
Echo "stop lvs-web1"
Ifconfig lo: 0 down
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 "Usage: $0 {start | stop }"
Exit 1
Esac

STARTUP script:

[Root @ linux-2 local] # service lvsweb start
Start lvs-web1

Create a file named index.html on/var/www/html on web1.

Cat/var/www/html/index.html
The is web1

3. web2 configuration script

Vi/etc/rc. d/init. d/lvsweb
#! /Bin/bash
Vip = 192.168.1.249
./Etc/rc. d/init. d/functions
Case "$1" in

Start)
Echo "start lvs-web2"
Ifconfig lo: 0 $ {vip} broadcast $ {vip} netmask 255.255.255.255 up
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
;;

Stop)
Echo "stop lvs-web2"
Ifconfig lo: 0 down
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 "Usage: $0 {start | stop }"
Exit 1
Esac

STARTUP script:

[Root @ linux-3 ~] # Service lvsweb start
Start lvs-web2

Create a file named index.html on/var/www/html on web2.

Cat/var/www/html/index.html
The is web2

##################### Success of the simple LVS-DR cluster ############ ######

4. Monitor LVS (installed on the LVS server)

1. Install rrdtool

Wget http://down1.chinaunix.net/distfiles/rrdtool-1.2.30.tar.gz

Tar zxvf rrdtool-1.2.30.tar.gz

Cd rrdtool-1.2.30

./Configure -- prefix =/usr/local/rrdtool

Make & make install

Echo "/usr/local/rrdtool/lib">/etc/ld. so. conf

Ldconf-v

2. Install lvs-rrd

Wget http://tepedino.org/lvs-rrd/lvs-rrd-v0.7.tar.gz

Tar zxvf lvs-rrd-v0.7.tar.gz

Music lvs-rrd-v0.7/var/www/html/lvs-rrd

3. Configure lvs-rrd

Cd/var/www/html/lvs-rrd

Vi lvs. rrd. update (you only need to configure the specified path)

RRDTOOL = "/usr/local/rrdtool/bin/rrdtool"
IPVSADM = "/sbin/ipvsadm"
WORKDIR = "/var/www/html/lvs-rrd"

Vi graph-lvs.sh

WORKDIR = "/var/www/html/lvs-rrd"
RRDTOOL = "/usr/local/rrdtool/bin/rrdtool"
GRAPHS = "$ WORKDIR/graphs"
WEBPATH = "/lvs-rrd/graphs"

4. Set permissions:

Chown-R apache. apache graphs/

5. Use crontab to update

Crontab-e

* ***/Var/www/html/lvs-rrd/lvs. rrd. update 2>/dev/null

############ ##################

Test results:

Http: // 192.168.1.250/lvs-rrd/





This article from the "game technology blog" blog, please be sure to keep this source http://youzao.blog.51cto.com/3946111/751443


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.