keepalived(二)vip漂移
實驗
內容:測試vip能否正常切換
架構圖
環境
ip | 系統 | 安裝的軟體 |
---|---|---|
192.168.253.158 | CentOS7 | keepalived |
192.168.253.128 | CentOS7 | keepalived |
第一步:在192.168.253.128主機上安裝keepalived和發郵件的工具
yum install mailx -y
yum install keepalived -y
第二步:在192.168.253.128主機上修改配置檔案/etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id 192.168.253.128
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 15
priority 95
advert_int 1
authentication {
auth_type PASS
auth_pass 1234
}
virtual_ipaddress {
192.168.253.190 dev ens33
}
notify_master "/etc/keepalived/notify.sh master" ##這個指令碼稍後會建立
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/nofify.sh fault"
}
第三步:建立keepalived狀態發生變化時觸發的指令碼/etc/keepalived/nofify.sh
#!/bin/bash
#發郵件通知root,keepalived狀態發生改變
contact='root@localhost'
notify() {
local mailsubject="$(hostname) to be $1, vip floating"
local 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
第四步:在192.168.253.158上安裝keepalived,將192.168.253.128的指令碼與配置檔案傳送到192.168.253.158上
192.168.253.158端操作
yum install keepalived -y
yum install mailx -y
192.168.253.128端操作
scp /etc/keepalived/keepalived.conf root@192.168.253.158:/etc/keepalived/keepalived.conf
scp /etc/keepalived/notify.sh root@192.168.253.158:/etc/keepalived/notify.sh
第五步:在192.168.253.158上修改配置檔案
[root@localhost ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id 192.168.253.158 ##修改為當前主機的主機名,這裡直接用ip了
}
vrrp_instance VI_1 {
state BACKUP ##設定為BACKUP節點
interface ens33
virtual_router_id 15
priority 90 ##優先順序
advert_int 1
authentication {
auth_type PASS
auth_pass 1234
}
virtual_ipaddress {
192.168.253.190 dev ens33
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/nofify.sh fault"
}
第六步:測試
我們先啟動192.168.253.158備用節點的keepalived
systemctl start keepalived
看一下vip是否在192.168.253.158主機上
這裡可以看出192.168.253.158正在廣播自己的心跳資訊。
這時候我們吧192.168.253.128啟動起來
systemctl start keepalived
這裡可以看到通告的人變成192.168.253.128了
vip這時候也飄過來了。說明沒問題。
我們再看一下192.168.253.128主機上指令碼是否成功觸發了
收到郵件,成功
相關文章
- MHA高可用+VIP漂移
- linux start_udev 導致VIP漂移Linuxdev
- Oracle RAC ASM磁碟組擴容時遇到的VIP漂移OracleASM
- 由VIP漂移引發的演算法異常問題調查和解決演算法
- 【IT老齊075】高可用架構避免單點經典方案Keepalived+VIP架構
- rac 新增第二public ip 和 vip
- 主打漂移的賽車遊戲《漂移19》:前無古人的嚴肅漂移遊戲
- 絕對漂移Absolute Drift for Mac(賽車漂移遊戲)Mac遊戲
- keepalived(三)LVS+Keepalived
- keepalived(四)Keepalived+NginxNginx
- VRRP虛IP漂移VR
- keepalived
- Keepalived - Keepalived 實現 tomcat雙機熱備Tomcat
- VIP影片解析
- 快速掌握keepalived
- keepalived安裝
- openGauss+KeepAlived
- LVS搭配Keepalived
- Keepalived 高可用
- parameter hj8828vip installed Oracle h518vip onOracleH5
- LNMP+HAProxy+Keepalived負載均衡(二)- 基礎服務準備LNMP負載
- DrawIO 二開 —— 是時候給你的 ProcessOn 充值終身 VIP 了
- rac vip failback issueAI
- 手柄漂移背後的科學原理
- keepalived配置問題
- KeepAlived+LVS+NginxNginx
- keepalived 安裝部署
- keepalived 主備使用
- LVS+Keepalived群集
- Python抓取VIP電影Python
- Keepalived 高可用詳解
- Keepalived 原理與實戰
- 高併發和 keepalived
- RabbitMQ+haProxy+keepalived使用MQ
- Keepalived服務詳解
- mysql高可用之keepalivedMySql
- LVS+keepalived高可用
- 高可用(keepalived)部署方案