LVS配置脚本。
原地址:%3D1
LVS
( l% _% z; t8 v4 ]& ?4 e1:LVS架构
6 K5 x) o& y, ^. f# z) YVIP:192.168.253.100
4 E& H) t: A) c* r: b( o3 {; Z4 E9 TDR:192.168.253.34
0 r" G1 X+ z# B& h) F- zRIP:192.168.253.33
- v* n8 G2 G; z8 R# w0 p$ ]RIP:192.168253.6
2 Q+ a! S9 o' B3 R5 g" X2:DR配置
) S7 D; n) `9 G* h[root@localhost /]# more ipad.sh
3 Y$ C0 X" g) u+ }# x# E#!/bin/sh
' @! `! R1 c; T3 ` _: C#create in 20070509 by yezi
) N, T' x, d; x9 j7 k7 U* P9 R# description: start LVS of Directorserver
8 b$ d5 X3 S3 s) XVIP=192.168.253.100
, Z7 _; |4 l; G/ S* O k6 GRIP1=192.168.253.33
2 \: A" w$ ^2 I0 U* Q; C9 ^% eRIP2=192.168.253.6
. P$ E( e$ Y/ Z5 c& ~5 w, tGW=192.168.253.1
+ R* p, z6 S3 |' d6 x/ R . u, r2 O$ t6 V0 r8 [. /etc/rc.d/init.d/functions
$ X/ T2 @& m G( d + I2 \5 J e1 ]: t ucase "$1" in
+ z! B% Q/ ~! |* k6 b! K, K; e' [ start)
- }& E) }9 M( u# m' y echo " start LVS of DirectorServer"
W& K' X, h3 @5 n3 C7 k/ u # set the Virtual IP Address
$ L8 ^) g+ h, t2 u% f /sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
( j# p' ^" [6 |; i8 N0 D /sbin/route add -host $VIP dev eth0:0
5 Z* f3 e4 z8 o #Clear IPVS table
9 J2 @- L* i4 W2 r) j% p1 s' q1 { /sbin/ipvsadm -C
& r3 S4 u5 Q/ E5 L% I2 z4 I #set LVS
( s a( Y9 I2 T6 t: r; \2 F /sbin/ipvsadm -A -t $VIP:80 -s rr
+ d- s6 L& y0 {9 D /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
- f# Y) [9 p* T4 }6 M /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
& S/ q$ Y+ O. T; W; W" w #/sbin/ipvsadm -a -t $VIP:80 -r $RIP3:80 -g
: ?4 a ^/ a8 i #Run LVS
4 }; e) x$ q5 k /sbin/ipvsadm
! E+ C V Q$ @" L #end
6 B4 ^# a+ r5 M1 n ;;
: p) K* ?$ ^' l- j! _8 {- _ stop)
% A1 p% Q6 o8 ^5 Z( n6 N echo "close LVS Directorserver"
& H3 R( I) v l0 f0 M /sbin/ipvsadm -C
- R2 e# P+ e3 R/ Y. S- r( i) \- ? ;;
! ~( L1 g9 R* @, E! @+ J *)
e3 }" A! ?) ^+ A( B6 A echo "Usage: $0 {start|stop}"
$ L; ^' D$ M2 e7 p! g; B exit 1
: ?) T( l4 f' H: S( M+ @esac
4 u9 }+ x! K$ F- ~[root@localhost /]#
- D! G- v8 K9 `* C' c" V3:RIP配置
' f' C9 n8 C5 O[root@localhost ~]# more real.sh
/ e. t- g" _6 D7 ?#!/bin/bash
. U1 `9 K5 |; b1 n1 w, d/ Y#description : start realserver
! Q' W. b3 b) g' D; l# R9 Y; W1 ~! kVIP=192.168.253.100
( A; D7 Z2 N: h" R/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
' @/ u) W1 Y) |4 g( r5 M/sbin/route add -host $VIP dev lo:0
& ^4 a1 ], Q/ d$ ?( Gecho "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
4 B" F8 r5 D$ W9 Hecho "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
) J# R. z/ ?$ d- [+ ~2 Xecho "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
# h u P) N9 P2 xecho "2" >/proc/sys/net/ipv4/conf/all/arp_announce
$ J, ?- w" a2 } i" q( q' n1 lsysctl -p
) \) [- `5 {) B/ v[root@localhost ~]#
阅读(4372) | 评论(3) | 转发(0) |