九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Nginx+keepalived架構(gòu)基于WEB的負(fù)載均衡
Nginx+keepalived架構(gòu)基于WEB的負(fù)載均衡(轉(zhuǎn)載)

 

 

 



服務(wù)器故障:(服務(wù)器故障包括:服務(wù)器宕機(jī)、web服務(wù)終止、網(wǎng)線松動等等)
①當(dāng)lvs-master故障時(shí),無法再接受用戶請求并將請求轉(zhuǎn)發(fā)給真實(shí)的web服務(wù)器(即便真實(shí)web服務(wù)器正常)從而導(dǎo)致整個(gè)web服務(wù)的癱瘓,也就是lvs控制器存在單點(diǎn)故障問題。
②當(dāng)lvs-master正常時(shí),真實(shí)地web服務(wù)器如web1-realserver故障。此時(shí)lvs-master并不知道真實(shí)服務(wù)器是否在正常提供web服務(wù),所以仍然在向故障的web1-realserver轉(zhuǎn)發(fā)用戶請求。這樣的結(jié)果是用戶請求無法被故障web服務(wù)器相應(yīng),某些用戶可以訪問網(wǎng)站有些則無法訪問。
基于以上的問題,我們需要想辦法實(shí)現(xiàn)對lvs控制器和web服務(wù)器的健康監(jiān)測,一旦服務(wù)出現(xiàn)問題能保證服務(wù)不中斷的情況下排除故障。即增加lvs控制器實(shí)現(xiàn)主備模式避免單點(diǎn)故障以及自動刪除故障web服務(wù)結(jié)點(diǎn)并當(dāng)它恢復(fù)后再自動添加到群集中這樣的功能,這就是LVS+keepalived能實(shí)現(xiàn)的功能。整個(gè)線上環(huán)境由Linuxtone的站長netseek提供,這里表示感謝,整個(gè)系統(tǒng)的拓補(bǔ)如下:

 

名稱

IP

LVS-DR-Master

61.164.122.6

LVS-DR-BACKUP

61.164.122.7

LVS-DR-VIP

61.164.122.8

WEB1-Realserver

61.164.122.9

WEB2-Realserver

61.164.122.10

實(shí)施步驟:
①在realserver主機(jī)上實(shí)行腳本realserver,為lo:0綁定VIP地址61.164.122.8,這步分別在二個(gè)web主機(jī)上61.164.122.9、61.164.122.10實(shí)施。這步提前做,是因?yàn)橐院蟮倪^程中這一步是不會發(fā)生更改的。
#vim /usr/local/sbin/realserver
#!/bin/bash
SNS_VIP=61.164.122.8
. /etc/rc.d/init.d/functions
case "$1" in
start)
ifconfig lo:0 $SNS_VIP netmask 255.255.255.255 broadcast $SNS_VIP
/sbin/route add -host $SNS_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 $SNS_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

②為二臺lvs主機(jī)安裝lvs腳本,這步并非必要。做完這步時(shí)可以檢測到用軟件實(shí)現(xiàn)了LVS/DR的雙機(jī)互備機(jī)制,但并不能實(shí)現(xiàn)的智能自動增加刪除故障的web站點(diǎn),所以這個(gè)靠keepalived來實(shí)現(xiàn)。過程如下:
#mkdir /usr/local/src/lvs
#cd /usr/local/src/lvs
#wget
http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
#ln -s /usr/src/kernels/2.6.18-53.el5PAE-i686/ /usr/src/linux
#tar zxvf ipvsadm-1.24.tar.gz
#cd ipvsadm-1.24
#make
#make install
lvs腳本如下 /usr/local/src/lvs/lvs
#!/bin/bash
#website director vip.
SNS_VIP=61.164.122.8
SNS_RIP1=61.164.122.9
SNS_RIP2=61.164.122.10

. /etc/rc.d/init.d/functions
logger $0 called with $1
case "$1" in
start)
# set squid vip
/sbin/ipvsadm --set 30 5 60
/sbin/ifconfig eth0:0 $SNS_VIP broadcast $SNS_VIP netmask 255.255.255.255
broadcast $SNS_VIP up
/sbin/route add -host $SNS_VIP dev eth0:0
/sbin/ipvsadm -A -t $SNS_VIP:80 -s wrr -p 3
/sbin/ipvsadm -a -t $SNS_VIP:80 -r $SNS_RIP1:80 -g -w 1
/sbin/ipvsadm -a -t $SNS_VIP:80 -r $SNS_RIP2:80 -g -w 1
touch /var/lock/subsys/ipvsadm >/dev/null 2>&1
;;
stop)
/sbin/ipvsadm -C
/sbin/ipvsadm -Z
ifconfig eth0:0 down
ifconfig eth0:1 down
route del $SNS_VIP
route del $SS_VIP
rm -rf /var/lock/subsys/ipvsadm >/dev/null 2>&1
echo "ipvsadm stoped"
;;
status)

if [ ! -e /var/lock/subsys/ipvsadm ];then
echo "ipvsadm stoped"
exit 1
else
echo "ipvsadm OK"
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
esac
exit 0

③關(guān)閉lvs腳本./lvs stop,編輯keepalived.conf文件,用keepalived實(shí)現(xiàn)負(fù)載均衡及高可用性。
a)Keepalved的安裝
#wget
http://www.keepalived.org/software/keepalived-1.1.15.tar.gz
#tar zxvf keepalived-1.1.15.tar.gz
#cd keepalived-1.1.15
#./configure
#make
#make install
將keepalived做成啟動腳務(wù),方便管理:
#cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
#cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
#mkdir /etc/keepalived
#cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
#cp /usr/local/sbin/keepalived /usr/sbin/
#service keepalived start|stop

b)Keealived的配置
1、配置在主負(fù)載均衡服務(wù)器上配置keepalived.conf
#vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
yuhongchun027@163.com
}
notification_email_from
sns-lvs@gmail.com
smtp_server 127.0.0.1
# smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {
state MASTER #備份服務(wù)器上將MASTER改為BACKUP
interface eth0
virtual_router_id 51
priority 100 #備份服務(wù)上將100改為99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
61.164.122.8
}
}

virtual_server 61.164.122.8 80 {
delay_loop 6 #(每隔10秒查詢r(jià)ealserver狀態(tài))
lb_algo wrr #lvs 算法
lb_kind DR #Direct Route
persistence_timeout 60 #同一IP的連接60秒內(nèi)被分配到同一臺realserver
protocol TCP #用TCP協(xié)議檢查realserver狀態(tài)

real_server 61.164.122.9 80 {
weight 3 #權(quán)重
TCP_CHECK {
connect_timeout 10#10秒無響應(yīng)超時(shí)
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 61.164.122.10 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
2、BACKUP服務(wù)器同上配置,先安裝lvs再按裝keepalived,仍后配置/etc/keepalived/keepalived.conf,只需將紅色標(biāo)示的部分改一下即可。
3、停掉lvs腳本,分別在二臺lvs機(jī)上啟動servcie keepalived start就可實(shí)現(xiàn)負(fù)載均衡及高可用集群。

※值得注意的是:
1、你必須向你的服務(wù)器所在機(jī)房IDC多申請一個(gè)IP供VIP使用。
2、服務(wù)器的iptables、SElinux均關(guān)閉,在生產(chǎn)過程中,我就遇到了iptables的NAT轉(zhuǎn)發(fā)問題,導(dǎo)致了lvs失敗。
3、修改keepalved.conf文件請直接修改/etc/keealived/keepalived.conf,因?yàn)閗eepalived啟動時(shí)會以這個(gè)為默認(rèn)。
4、系統(tǒng)排障時(shí)多用ipvsadm -ln和tail -f /var/log/messages。以上架構(gòu)我在生產(chǎn)環(huán)境、局域網(wǎng)、虛擬機(jī)下均實(shí)現(xiàn),有興趣的同志可以對照實(shí)驗(yàn),有問題的話歡迎來信交流yuhongchun027@163.com(撫琴煮酒)

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
利用LVS+Keepalived 實(shí)現(xiàn)高性能高可用負(fù)載均衡服務(wù)器 - 負(fù)載均衡 - IT運(yùn)...
集群系列四(基于ivs
LVS負(fù)載均衡
LVS(DR) KeepAlived On CentOS6 安裝配置說明書
mysql dba系統(tǒng)學(xué)習(xí)(19)配置mysql+lvs+keeplived實(shí)現(xiàn)Mysql讀操作的負(fù)載均衡
Keepalived + LVS(DR) 高可用負(fù)載均衡集群
更多類似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服