Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

DR script for LVS

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Director script:

#! / bin/bash## LVS script for VS/DR#. / etc/rc.d/init.d/functions#VIP=192.168.0.210RIP1=192.168.0.221RIP2=192.168.0.222PORT=80#case "$1" instart) / sbin/ifconfig eth0:1$ VIP broadcast $VIP netmask 255.255.255.255 up / sbin/route add-host $VIP dev eth0:1# Since this is the Director we must be able to forward packets echo 1 > / proc/sys/net/ipv4/ip_forward# Clear all iptables rules. / sbin/iptables-F # Reset iptables counters. / sbin/iptables-Z# Clear all ipvsadm rules/services. / sbin/ipvsadm-C # Add an IP virtual service for VIP 192.168.0.219 port 8 In this recipe, we will use the round-robin scheduling method. # In production, however, you should use a weighted, dynamic scheduling method. / sbin/ipvsadm-A-t $VIP:80-s wlc# Now direct packets for this VIP to# the real server IP (RIP) inside the cluster / sbin/ipvsadm-a-t $VIP:80-r $RIP1-g-w 1 / sbin/ipvsadm-a-t $VIP:80-r $RIP2-g-w 2 / bin/touch / var/lock/subsys/ipvsadm & > / dev/null Stop) # Stop forwarding packets echo 0 > / proc/sys/net/ipv4/ip_forward# Reset ipvsadm / sbin/ipvsadm-C # Bring down the VIP interface / sbin/ifconfig eth0:1 down / sbin/route del $VIP / bin/rm-f / var/lock/subsys/ipvsadm echo "ipvs is stopped...";; status) if [!-e / var/lock/subsys/ipvsadm]; then echo "ipvsadm is stopped..." Else echo "ipvs is running..." Ipvsadm-L-n fi;;*) echo "Usage: $0 {start | stop | status}";; esac

Realserver script:

#! / bin/bash## Script to start LVS DR real server.# description: LVS DR real server#. / etc/rc.d/init.d/functionsVIP=192.168.0.219host= `/ bin/ hostname`case "$1" instart) # Start LVS-DR real server on this machine. / sbin/ifconfig lo down / sbin/ifconfig lo 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 / sbin/ifconfig lo:0$ VIP broadcast $VIP netmask .255.255.255 up / sbin/route add-host $VIP dev lo:0 ; stop) # Stop LVS-DR real server loopback device (s). / sbin/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;;status) # Status of LVS-DR real server. Islothere= `/ sbin/ifconfig lo:0 | grep $VIP` isrothere= `netstat-rn | grep "lo:0" | grep $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 real server Running." Fi;;*) # Invalid entry. Echo "$0: Usage: $0 {start | status | stop}" exit 1 politics ESAC

Note: this script comes from the Internet.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report