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漂移
- oracle rac vip 漂移過程Oracle
- 10.2.0.3 VIP 漂移問題
- rac 手動漂移scan ip vip
- RAC_網路_VIP漂移_SCAN IP
- linux start_udev 導致VIP漂移Linuxdev
- 談談VIP漂移那點破事薦
- Oracle 10g RAC vip 漂移問題Oracle 10g
- 手動進行oracle rac vip 漂移的步驟 。Oracle
- Oracle RAC ASM磁碟組擴容時遇到的VIP漂移OracleASM
- 一次RAC VIP漂移的結果診斷及修復
- 通過keepalived實現 MySQL VIP 自動切換MySql
- 由VIP漂移引發的演算法異常問題調查和解決演算法
- MYSQL + MHA +keepalive + VIP安裝配置(三)--keepalived安裝配置MySql
- 主打漂移的賽車遊戲《漂移19》:前無古人的嚴肅漂移遊戲
- 絕對漂移Absolute Drift for Mac(賽車漂移遊戲)Mac遊戲
- rac 新增第二public ip 和 vip
- 【IT老齊075】高可用架構避免單點經典方案Keepalived+VIP架構
- 10g VIP網路卡斷開導致漂移,網路正常後一般如何恢復回去
- 10gR2 rac vip服務頻繁重啟及在節點間漂移的一種解決辦法
- How to Change IP and VIP in Oracle Clusterware(二)-實操篇Oracle
- 資料庫VIP地址無法訪問(二)資料庫
- VRRP虛IP漂移VR
- keepalived(四)Keepalived+NginxNginx
- keepalived
- redis flushdb造成的哨兵漂移Redis
- MYSQL + MHA +keepalive + VIP安裝配置(二)--MHA的配置MySql
- How to change VIP and VIP/Hostname in 10g
- 【網路】ip地址漂移技術
- mysql with keepalivedMySql
- How to update SCAN VIP (ora.scan.vip) [ID 952903.1]
- 【RAC】如何修改vip 或者vip 對應的hostname
- 更改VIP、IP
- vip會員
- VIP影片解析
- Keepalived - Keepalived 實現 tomcat雙機熱備Tomcat
- 手柄漂移背後的科學原理
- LNMP+HAProxy+Keepalived負載均衡(二)- 基礎服務準備LNMP負載