您好,登錄后才能下訂單哦!
? ? Keepalived高可用
1.Keepalived通知配置?
發(fā)件人配置:
[root@s2 ~]# yum install mailx -y
[root@s2 ~]# vim /etc/mail.rc
set from=398808313@qq.com
set smtp=smtp.qq.com
set smtp-auth-user=398808313@qq.com
set smtp-auth-password=mfcjxxjezawgdgee?
set smtp-auth=login
set ssl-verify=ignore
?
set smtp-auth-password=mfcjxxjezawgdgee詳解:
(1)進(jìn)入qq郵箱
開啟這個選項,然后按照一步步的生成這個值。
?
Keepalived通知腳本
[root@localhost keepalived]# cat /etc/keepalived/notify.sh
#!/bin/bash
contact='2973707860@qq.com'
notify() {
mailsubject="$(hostname) to be $1, vip 轉(zhuǎn)移"
mailbody="$(date +'%F %T'): vrrp transition, $(hostname) changed to be $1"
echo "$mailbody" | mail -s "$mailsubject" $contact
}
case $1 in
master)
notify master
;;
backup)
notify backup
;;
fault)
notify fault
;;
*)
echo "Usage: $(basename $0) {master|backup|fault}"
exit 1
;;
esac
?
Keepalived通知配置?
? 定義通知腳本:
notify_master <STRING>|<QUOTED-STRING>:
當(dāng)前節(jié)點成為主節(jié)點時觸發(fā)的腳本
notify_backup <STRING>|<QUOTED-STRING>:
當(dāng)前節(jié)點轉(zhuǎn)為備節(jié)點時觸發(fā)的腳本
notify_fault <STRING>|<QUOTED-STRING>:
當(dāng)前節(jié)點轉(zhuǎn)為“失敗”狀態(tài)時觸發(fā)的腳本
notify <STRING>|<QUOTED-STRING>:
通用格式的通知觸發(fā)機(jī)制,一個腳本可完成以上三種狀態(tài)的轉(zhuǎn)換時的通知
?
2.?keepalived+haproxy
???當(dāng)haproxy宕機(jī)后,vip也會漂移到其他的備份主機(jī)上。
??高可用HAProxy(keepalived主配置文件)?
vrrp_script chk_haproxy {
script "/etc/keepalived/chk_haproxy.sh"
interval 1
weight -80
fall 3
rise 5
timeout 2
}
有要求
track_script {
chk_haproxy
}
?
[root@s1 ~]# yum install psmisc -y (killall程序包)
[root@s1 ~]# cat /etc/keepalived/chk_haproxy.sh
#!/bin/bash
/usr/bin/killall -0 haproxy (檢查程序是否存活)
[root@s1 ~]# chmod a+x /etc/keepalived/chk_haproxy.sh
?
?
?
?
?
?
?
?
?
3.?keepalived+nginx
和上面的haproxy差不多。
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
4.Keepalived案例一:實現(xiàn)LVS-DR模式?
virtual_server 172.18.200.248 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
#persistence_timeout 120 #會話保持時間
protocol TCP
sorry_server 172.18.200.105 80
real_server 172.18.200.103 80 {
weight 1
TCP_CHECK {
connect_timeout 5
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
?}
real_server 172.18.200.104 80 {
weight 1
TCP_CHECK {
connect_timeout 5
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
?}
?}
?
?
?
?
?
?
免責(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)容。