keepalived 官網
.org/
cd /usr/local/src/
wget
.org/software/keepalived-1.4
.0.tar
.gz
2, 安裝
tar -zxvf keepalived-1.4
.0.tar
.gzcd keepalived-1.4
.0.tar
.gz./configure --prefix=/usr/local/keepalived
make && make install
3,將 keepalived 安裝成 linux 系統服務
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
ln -s /usr/local/sbin/keepalived /usr/sbin/
4, 修改 keepalived 配置檔案
global_defs
## keepalived會定時執行指令碼並對指令碼執行的結果進行分析,動態調整vrrp_instance的優先順序。
##如果指令碼執行結果為0,並且weight配置的值大於0,則優先順序相應的增加。如果指令碼執行結果非0,
##並且weight配置的值小於 0,則優先順序相應的減少。其他情況,維持原本配置的優先順序,即配置檔案中priority對應的值。
vrrp_script chk_nginx
vrrp_instance vi_1
# 虛擬ip,兩個節點設定必須一樣。可以設定多個,一行寫乙個
virtual_ipaddress
track_script
}
5,新增檢測指令碼
建立檢測指令碼bin編輯
vim /etc/keepalived/nginx_check.sh
chmod +x /etc/keepalived/nginx_check.sh
#!/bin/bash
a=`ps -c nginx --no-header | wc -l`
if [ $a
-eq0 ];then
docker start keep_nginx # docker啟動nginx容器
sleep 2
if [ `ps -c nginx --no-header | wc -l` -eq
0 ];then
killall keepalived
fifi
6,啟動keepalived
systemctl start keepalived
keepalived安裝與配置
一 安裝keepalived 1.2.2 yum y install gcc make openssl openssl devel wget kernel devel mkdir p usr local src hasoft cd usr local src hasoft wget tar zxvf...
Keepalived配置安裝
ubuntu 16.04.3系統兩台機器 vipip hostname port 192.168.0.200 192.168.0.129 master wjt ceshiji 80192.168.0.200 192.168.0.129 backup wjt ceshiji22 80wgettar z...
Nginx 配置 keepalived安裝
location urilocation uri 優先順序最高的匹配規則 location uri普通匹配的優先順序要高於正則匹配如果存在多個相同的字首的一般匹配,那麼最終會按照最大長度來做匹配 rewrite通過ngx http rewrite module模組支援url重寫 支援if判斷,但不支...