Centos7의 lvs DR 구성

7160 단어
서버 호스트:
  10.200.3.100       DirectServer
  10.200.3.99         RealServer1
  10.200.3.101  RealServer2
       10.200.3.200      VIP
설치 구성:
DirectServer 측 작업:
yum install ipvsadm

DirectServer를 구성하여 파일/etc/init를 만듭니다.d/lvs_vsadm.sh, 실행 권한 부여
#!/bin/sh
 
VIP=10.200.3.200
RIP1=10.200.3.99
RIP2=10.200.3.101
/etc/rc.d/init.d/functions

case "$1" in
start)
  echo "start LVS of DirectorServer"
  #set the Virtual IP Address
   ifconfig ens160:0 $VIP/24
   #/sbin/route add -host $VIP dev ens160:0
   #Clear IPVS table
   /sbin/ipvsadm -C
  #set LVS
  /sbin/ipvsadm -A -t $VIP:80 -s rr
  /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
  /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
  #Run LVS
  /sbin/ipvsadm
  #end
;;
stop)
 echo "close LVS Directorserver"
/sbin/ipvsadm -C
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac

lvsadm 서비스 시작:
#/etc/init.d/lvs_vsadm.sh start
start LVS of DirectorServer
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  Pt-gitlab:http rr
  -> 10.200.3.99:http             Route   1      0          0         
  -> 10.200.3.101:http            Route   1      0          0         

RealServer 구성, 두 개의 구성과 마찬가지로 새 파일/etc/init.d/realserver.sh 및 실행 권한 부여
#!/bin/sh
VIP=10.200.3.200
/etc/rc.d/init.d/functions
case "$1" in
    start)
        echo "Start LVS of RealServer"
        /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
        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)
        /sbin/ifconfig lo:0 down
        echo "Stop LVS of RealServer"
        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

실행 스크립트를 시작합니다.
# /etc/init.d/lvs_dr.sh start 

 
이로써 단일 노드 lvsadm 배치가 완료되었습니다.

좋은 웹페이지 즐겨찾기