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

LVS-DR deployment

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

LVS-DR deployment script

#! / bin/bash

VIP=192.168.11.100

DIP=192.168.11.11

RIP1=192.168.11.12

RIP2=192.168.11.13

POST=80

Lvs_dr () {

Ifconfig eth0:0$ VIP netmask 255.255.255.0 up

Route add-host $VIP dev eth0:0

Rpm-Q ipvsadm & & echo "ipvsadm exists" | | yum-y install ipvsadm & > / dev/null

Echo 1 > / proc/sys/net/ipv4/ip_forward

Ipvsadm-C

Ipvsadm-At ${VIP}: ${POST}-s wrr

Ipvsadm-at ${VIP}: ${POST}-r ${RIP1}: ${POST}-g-w 1

Ipvsadm-at ${VIP}: ${POST}-r ${RIP2}: ${POST}-g-w 3

Ipvsadm-Ln

}

Rs_web () {

Ifconfig lo:0$ VIP netmask 255.255.255.255 up

Route add-host $VIP dev lo:0

Rpm-Q httpd & & echo "httpd already installd" | | yum-y install httpd & > / dev/null

Systemctl restart httpd

Systemctl enable httpd

Web_ip=$ (ifconfig eth0 | awk'/ netmask/ {print $2}')

Echo $web_ip > / var/www/html/index.html

Curl $web_ip

Echo 1 > / proc/sys/net/ipv4/conf/lo/arp_ignore

Echo 1 > / proc/sys/net/ipv4/conf/all/arp_ignore

Echo 2 > / proc/sys/net/ipv4/conf/lo/arp_announce

Echo 2 > / proc/sys/net/ipv4/conf/all/arp_announce

Sysctl-p

}

Case $1 in

Start)

Lvs_dr

Ipvsadm-save

Stop)

Ipvsadm-C

Ipvsadm-Ln

Rs_web)

Rs_web

*)

Echo "usage: $0 [start | stop | rs_web]"

Esac

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

Servers

Wechat

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

12
Report