ip
主機名節點型別
192.168.100.61
server1
master
192.168.100.62
server2
backup
建議關閉防火牆和selinux
學習目標:
1.部署keepalived;
2.配置keepalived日誌;
3.配置自定義監測httpd服務指令碼;
一、安裝keepalived和httpd(兩個節點都需要執行)
二、修改keepalived配置檔案
master節點:
[root@server1 ~]
# vim /etc/keepalived/keepalived.conf
global_defs
vrrp_script chk_nginx
vrrp_instance vi_1
virtual_ipaddress
track_script
}
backup節點:
[root@server2 ~]
# vim /etc/keepalived/keepalived.conf
global_defs
vrrp_script chk_nginx
vrrp_instance vi_1
virtual_ipaddress
track_script
}
三、建立健康檢查指令碼並授執行許可權 (以下兩個節點都需要執行)
授權
# chmod 755 /usr/local/sbin/chk_httpd.sh
四、設定日誌系統(兩個節點都設定,以便日後運維排錯)
# vim /etc/sysconfig/keepalived
keepalived_options=
"-d -d -s 0"
# vim /etc/rsyslog.conf
//找到此行
$actionfiledefaulttemplate rsyslog_traditionalfileformat
//在下面新增此行
local0.* /var/log/keepalived.log
五、重啟rsyslog和keepalived生效配置(兩個節點都執行)
# systemctl restart rsyslog
# systemctl restart keepalived
六、測試
關閉server1的keepalived,測試vip是否會跳到backup節點
檢視server2的網絡卡資訊,檢視vip是否已經轉到server2
檢視兩個主機的日誌,可以看到剛剛主機的活動過程,這裡使用「 tail -f [檔名] 」可實施檢視日誌的更新
一、安裝郵件服務
[root@server1 ~]
# yum -y install mailx sendmail
修改郵件服務配置檔案
[root@server1 ~]
# vim /etc/mail.rc
##在配置檔案中新增以下引數
set from=******[email protected] //郵箱賬號
set smtp=smtp.qq.com
set smtp-auth-user=******[email protected] //郵箱賬號
set smtp-auth-password=*********xx //郵箱smtp驗證碼
set smtp-auth=login
二、編寫郵件通知指令碼
[root@server1 ~]
# vim /etc/keepalived/notify.sh
#!/bin/bash
contact=
notify(
)case
$1in
master)
notify master ;;
backup)
notify backup ;;
fault)
notify fault ;;
*)echo
"usage: $(
basename $0)
" ecit 1 ;;
esac
三、開啟觸發動作
[root@server1 ~]
# vim /etc/keepalived/keepalived.conf
vrrp_instance vi_1
virtual_ipaddress
track_script
##新增以下引數
notify_master "/bin/bash /etc/keepalived/notify.sh master" //當此節點成為master的時候執行後面的動作
notify_backup "/bin/bash /etc/keepalived/notify.sh backup" //當此節點成為backup的時候執行後面的動作
notify_fault "/bin/bash /etc/keepalived/notify.sh fault" //當此節點狀態報錯的時候執行後面的動作
}
四、測試
關閉server節點的keepalived
[root@server1 ~]
# systemctl stop keepalived
qq郵箱收到郵件,提示server2已經成為新的節點
keepalived安裝部署
上傳伺服器安裝 tar xvf cd keepalived 1.3.5 configure prefix usr local keepalived make make install ln s usr local keepalived sbin usr bin ln s usr local keep...
Keepalived安裝部署
通過ftp工具上傳到linux中,home software 解壓tar zxvf keepalived 2.0.18.tar.gz解壓後進入到解壓出來的目錄,看到會有configure,那麼就可以做配置了 配置安裝和nginx一模一樣 使用configure命令配置安裝目錄與核心配置檔案所在位置 ...
Keepalived 概述及部署
keepalived 軟體起初是專為lvs 負載均衡軟體設計的,用來管理並監控lvs 集群系統中各個服務節點的狀態,後來又加入了可以實現高可用的vrrp 功能。因此,keepalived除了能夠管理lvs軟體外,還可以作為其他服務 例如 nginx haproxy mysql等 的高可用解決方案軟體...