lvs+keeplive 관련
[root@localhost ~]# cat lvs.sh
ption: Config realserver lo and apply noarp
WEB_VIP=192.168.0.90
. /etc/rc.d/init.d/functions
case "$1" in
start)
ifconfig lo:0 $WEB_VIP netmask 255.255.255.255 broadcast $WEB_VIP
/sbin/route add -host $WEB_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 "RealServer Start OK"
;;
stop)
ifconfig lo:0 down
route del $WEB_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"
;;
status)
# Status of LVS-DR real server.
islothere=`/sbin/ifconfig lo:0 | grep $WEB_VIP`
isrothere=`netstat -rn | grep "lo:0" | grep $web_VIP`
if [ ! "$islothere" -o ! "isrothere" ];then
# Either the route or the lo:0 device
# not found.
echo "LVS-DR real server Stopped."
else
echo "LVS-DR Running."
fi
;;
*)
# Invalid entry.
echo "$0: Usage: $0 {start|status|stop}"
exit 1
;;
esac
exit 0
관련 route 및 lo:0 주의
ipvsadm 방식 셸 코드
[root@localhost ~]# cat lvs_dr.sh
#!/bin/bash
# description: start LVS of DirectorServer
GW=192.168.0.1
# website director vip.
WEB_VIP=192.168.0.90
WEB_RIP1=192.168.0.7
WEB_RIP2=192.168.0.8
. /etc/rc.d/init.d/functions
logger $0 called with $1
case "$1" in
start)
# Clear all iptables rules.
/sbin/iptables -F
# Reset iptables counters.
/sbin/iptables -Z
# Clear all ipvsadm rules/services.
/sbin/ipvsadm -C
#set lvs vip for dr
/sbin/ipvsadm --set 30 5 60
/sbin/ifconfig eth0:0 $WEB_VIP broadcast $WEB_VIP netmask 255.255.255.255 up
/sbin/route add -host $WEB_VIP dev eth0:0
/sbin/ipvsadm -A -t $WEB_VIP:8080 -s wrr -p 3
/sbin/ipvsadm -a -t $WEB_VIP:8080 -r $WEB_RIP1:8080 -g -w 1
/sbin/ipvsadm -a -t $WEB_VIP:8080 -r $WEB_RIP2:8080 -g -w 1
touch /var/lock/subsys/ipvsadm >/dev/null 2>&1
# set Arp
/sbin/arping -I eth0 -c 5 -s $WEB_VIP $GW >/dev/null 2>&1
;;
stop)
/sbin/ipvsadm -C
/sbin/ipvsadm -Z
ifconfig eth0:0 down
route del $WEB_VIP >/dev/null 2>&1
rm -rf /var/lock/subsys/ipvsadm >/dev/null 2>&1
/sbin/arping -I eth0 -c 5 -s $WEB_VIP $GW
echo "ipvsadm stoped"
;;
status)
if [ ! -e /var/lock/subsys/ipvsadm ];then
echo "ipvsadm is stoped"
exit 1
else
ipvsadm -ln
echo "..........ipvsadm is OK."
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
esac
exit 0
keeplive를 사용하지 않으면 위 코드로 바로 호출할 수 있습니다
Keeplive를 사용하면 위 코드, keeplive 프로필을 사용하지 않습니다
[root@localhost ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
# [email protected]
# [email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
# smtp_connect_timeout 30
# router_id LVS_DEVEL
lvs_id string
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.90
}
}
virtual_server 192.168.0.90 80 {
delay_loop 3
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.0.7 80 {
weight 3
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.0.8 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
여러 VIP가 있으면 계속 추가,
ipvsadm 설치 오류 해결 방법
ln -s /usr/src/kernels/2.6.18-128.el5-x86_64/ /usr/src/linux
cp /usr/src/kernels/2.6.18-128.el5-x86_64/include/net/ip_vs.h /usr/include/net
설치 전 확인
[root@localhost ~]# modprobe -l | grep ip_vs
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_dh.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_ftp.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_lblc.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_lblcr.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_lc.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_nq.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_rr.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_sed.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_sh.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_wlc.ko
/lib/modules/2.6.18-128.el5/kernel/net/ipv4/ipvs/ip_vs_wrr.ko
[root@localhost ~]# lsmod | grep ip_vs
ip_vs_rr 35009 1
ip_vs_wrr 35905 0
ip_vs 121217 5 ip_vs_rr,ip_vs_wrr
[root@localhost ~]#
[root@localhost ~]# modprobe ip_vs
2.4 ip_vs,2.4
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
LVS---5. 단일 노드 LVS 활성화 - LVS 배포 성공 여부 확인keepalived는 업무 서버와 두 대의 물리기에 속한다 앞에 설정한 IP와 같은 네트워크 접근 요청을 만듭니다 우리가 방문이 성공하지 못한 것을 발견했을 때, 오류 정보를 보십시오 해결 방법: 같은 네트워크 구간...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.