#configuration File for keepalived
global_defs {
router_id LVS_1
}
vrrp_instance VI_1 {
state BACKUP
interface enp4s0
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass szspzw
}
virtual_ipaddress {
14.232.7.202
}
}
virtual_server 14.232.7.202 5460 {
delay_loop 30
lb_algo wlc
lb_kind DR
protocol TCP
real_server 14.232.7.12 5460 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 5460
}
}
real_server 14.232.7.13 5460 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 5460
}
}
real_server 14.232.7.14 5460 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 5460
}
}
}
########### cos ############
vrrp_instance VI_2 {
state MASTER
interface enp4s0
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass szspzw
}
virtual_ipaddress {
14.232.7.203
}
}
virtual_server 14.232.7.203 5460 {
delay_loop 30
lb_algo wlc
lb_kind DR
protocol TCP
real_server 14.232.7.22 5460 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 5460
}
}
real_server 14.232.7.23 5460 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 5460
}
}
real_server 14.232.7.24 5460 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 5460
}
}
}
virtual_server 14.232.7.203 1443 {
delay_loop 30
lb_algo wlc
lb_kind DR
protocol TCP
real_server 14.232.7.22 1443 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 1443
}
}
real_server 14.232.7.23 1443 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 1443
}
}
real_server 14.232.7.24 1443 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 1443
}
}
}
virtual_server 14.232.7.203 80 {
delay_loop 30
lb_algo wlc
lb_kind DR
protocol TCP
real_server 14.232.7.22 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 80
}
}
real_server 14.232.7.23 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 80
}
}
real_server 14.232.7.24 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 80
}
}
}
########### lingmou_private ############
vrrp_instance VI_3 {
state MASTER
interface enp4s0
virtual_router_id 53
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass szspzw
}
virtual_ipaddress {
14.232.7.201
}
}
# nacos
virtual_server 14.232.7.201 8848 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 8848 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 8848
}
}
real_server 14.232.7.36 8848 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 8848
}
}
real_server 14.232.7.37 8848 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 8848
}
}
}
# frontend_http
virtual_server 14.232.7.201 82 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 82 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 82
}
}
real_server 14.232.7.36 82 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 82
}
}
real_server 14.232.7.37 82 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 82
}
}
}
# deviceServer
virtual_server 14.232.7.201 20062 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20062 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20062
}
}
real_server 14.232.7.36 20062 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20062
}
}
real_server 14.232.7.37 20062 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20062
}
}
}
# placeServer
virtual_server 14.232.7.201 20068 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20068 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20068
}
}
real_server 14.232.7.36 20068 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20068
}
}
real_server 14.232.7.37 20068 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20068
}
}
}
# tagServer
virtual_server 14.232.7.201 20071 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20071 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20071
}
}
real_server 14.232.7.36 20071 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20071
}
}
real_server 14.232.7.37 20071 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20071
}
}
}
# personServer
virtual_server 14.232.7.201 20072 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20072 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20072
}
}
real_server 14.232.7.36 20072 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20072
}
}
real_server 14.232.7.37 20072 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20072
}
}
}
# rule_engine
virtual_server 14.232.7.201 20086 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20086 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20086
}
}
real_server 14.232.7.36 20086 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20086
}
}
real_server 14.232.7.37 20086 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20086
}
}
}
# subscribServer
virtual_server 14.232.7.201 20087 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20087 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20087
}
}
real_server 14.232.7.36 20087 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20087
}
}
real_server 14.232.7.37 20087 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20087
}
}
}
# preventionServer
virtual_server 14.232.7.201 20088 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20088 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20088
}
}
real_server 14.232.7.36 20088 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20088
}
}
real_server 14.232.7.37 20088 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20088
}
}
}
# aidTagServer
virtual_server 14.232.7.201 20099 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20099 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20099
}
}
real_server 14.232.7.36 20099 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20099
}
}
real_server 14.232.7.37 20099 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20099
}
}
}
# aid_archive
virtual_server 14.232.7.201 20201 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20201 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20201
}
}
real_server 14.232.7.36 20201 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20201
}
}
real_server 14.232.7.37 20201 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20201
}
}
}
# extension
virtual_server 14.232.7.201 20203 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20203 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20203
}
}
real_server 14.232.7.36 20203 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20203
}
}
real_server 14.232.7.37 20203 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20203
}
}
}
# place_archive
virtual_server 14.232.7.201 20204 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20204 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20204
}
}
real_server 14.232.7.36 20204 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20204
}
}
real_server 14.232.7.37 20204 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20204
}
}
}
# rule_compare
virtual_server 14.232.7.201 20206 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20206 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20206
}
}
real_server 14.232.7.36 20206 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20206
}
}
real_server 14.232.7.37 20206 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20206
}
}
}
# motor_plate_id_server
virtual_server 14.232.7.201 20208 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20208 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20208
}
}
real_server 14.232.7.36 20208 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20208
}
}
real_server 14.232.7.37 20208 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20208
}
}
}
# egl
virtual_server 14.232.7.201 20212 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20212 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20212
}
}
real_server 14.232.7.36 20212 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20212
}
}
real_server 14.232.7.37 20212 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20212
}
}
}
# communityServer
virtual_server 14.232.7.201 20215 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20215 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20215
}
}
real_server 14.232.7.36 20215 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20215
}
}
real_server 14.232.7.37 20215 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20215
}
}
}
# visa/iss
virtual_server 14.232.7.201 29998 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 29998 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 29998
}
}
real_server 14.232.7.36 29998 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 29998
}
}
real_server 14.232.7.37 29998 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 29998
}
}
}
# tokenserver
virtual_server 14.232.7.201 20073 {
delay_loop 30
lb_algo rr
lb_kind DR
protocol TCP
real_server 14.232.7.35 20073 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20073
}
}
real_server 14.232.7.36 20073 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20073
}
}
real_server 14.232.7.37 20073 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 2
delay_before_retry 2
connect_port 20073
}
}
}
VIP
#!/bin/bash
command=${1}
V_IP_LIST="14.232.7.202"
num=0
echo "${V_IP_LIST}" |tr ',' '\n'|while read V_IP
do
case "${command}" in
start)
ifconfig lo:${num} ${V_IP} netmask 255.255.255.255 broadcast ${V_IP}
/sbin/route add -host ${V_IP} dev lo:${num}
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 "${V_IP}:RealServer Start OK"
;;
stop)
ifconfig lo:${num} down
route del ${V_IP} > /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 "${V_IP}:RealServer Stoped"
;;
status)
# Status of LVS-DR real server.
islothere=`/sbin/ifconfig lo:${num} | grep "${V_IP}"`
isrothere=`netstat -rn | grep "lo:${num}" | grep "${V_IP}"`
if [ ! "$islothere" -o ! "isrothere" ];then
# Either the route or the lo:0 device
# not found.
echo "${V_IP}:LVS-DR real server Stopped."
else
echo "${V_IP}:LVS-DR Running."
fi
;;
*)
# Invalid entry.
echo "Usage: $0 {start|status|stop}"
exit 1
;;
esac
let num=${num}+1
sleep 1;
done
exit 0