您好,登錄后才能下訂單哦!
yum install ipvsadm keepalived -y
net.ipv4.ip_forward=1
//proc響應(yīng)關(guān)閉重定向功能
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0
sysctl -p 這條命令是讓以上配置生效
cp ifcfg-ens33 ifcfg-ens33:0
vim ifcfg-ens33:0
刪除原來所有信息,添加以下代碼:
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.100.10
NETMASK=255.255.255.0
ifup ens33:0
#!/bin/bash
GW=192.168.100.1
VIP=192.168.100.10
RIP1=192.168.100.221
RIP2=192.168.100.222
case "$1" in
start)
/sbin/ipvsadm --save > /etc/sysconfig/ipvsadm
systemctl start ipvsadm
/sbin/ifconfig ens33:0 $VIP broadcast $VIP netmask 255.255.255.255 broadcast $VIP up
/sbin/route add -host $VIP dev ens33:0
/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
echo "ipvsadm starting------------------[ok]"
;;
stop)
/sbin/ipvsadm -C
systemctl stop ipvsadm
ifconfig ens33:0 down
route del $VIP
echo "ipvsamd stoped--------------------[ok]"
;;
stop)
/sbin/ipvsadm -C
systemctl stop ipvsadm
ifconfig ens33:0 down
route del $VIP
echo "ipvsamd stoped--------------------[ok]"
;;
status)
if [ ! -e ar/lock/subsys/ipvsadm ];then
echo "ipvsadm stoped--------------------"
exit 1
else
echo "ipvsamd Runing-------------[ok]"
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
esac
exit 0
chmod +x dr.sh
service dr.sh start
yum install httpd -y
systemctl start httpd.service //開啟服務(wù)
路徑:/var/www/html
echo "this is accp web" > index.html
1、路徑:/etc/sysconfig/network-scripts/
2、復(fù)制網(wǎng)卡信息加以修改
cp ifcfg-lo ifcfg-lo:0
3、vim ifcfg-lo:0
刪除原來所有信息,添加以下內(nèi)容:
DEVICE=lo:0
IPADDR=192.168.100.10
NETMASK=255.255.255.0
ONBOOT=yes
#!/bin/bash
VIP=192.168.100.10
case "$1" in
start)
ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP
/sbin/route add -host $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/lo/arp_ignore
echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce
sysctl -p > /dev/null 2>&1
echo "RealServer Start OK "
;;
stop)
ifconfig lo:0 down
route del $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"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
chmod +x web.sh //添加權(quán)限
service web.sh start //啟動服務(wù)
ifup lo:0
路徑:/var/www/html
echo "this is benet web" > index.html
systemctl start keepalived.service
systemctl start keepalived.service
ifdown ens33:0
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。