官網位址
wget
tar -zxvf keepalived-***.tar.gz
./configure --prefix=/usr/local/keepalived --sysconf=/etc
make
&&make
install
即安裝成功
(master 192.168.1.151)
global_defs
vrrp_instance vi_1
#虛擬出來的ip,可以有多個(vip)
virtual_ipaddress
}
(backup 192.168.1.152)
global_defs
vrrp_instance vi_1
#虛擬出來的ip,可以有多個(vip)
virtual_ipaddress
}
附:檢視網絡卡
進入sbin啟動
./usr/local/keepalive/sbin/keepalive
cd /home/keepalived-***x/keepalived/etc
cp init.d/keepalived /etc/init.d/
cp sysconfig/keepalive /etc/sysconfig/
systemctl daemon-reload
systemctl start keepalive.servie
systemctl stop keepalive.servie
systemctl restart keepalive.servie
(如果主keepalive節點沒有掛而nginx掛了,此時虛擬ip還是跟主繫結,因此需要keepalive能夠自動重啟nginx,實在重啟不了,切換備用節點)
cd /etc/keepalived/
vim check_nginx_alive.sh
#!/bin/bash
a=`ps -
c nginx --no-header |wc -l`
#判斷nginx是否宕機,如果宕機了,嘗試重啟
if[$a -eq 0
];then
/usr/local/nginx/sbin/nginx
#等待一小會再次檢查nginx,如果沒有啟動成功,則停止keepalvie,使其啟動備用機
sleep 3
if[$a -eq 0
];then
killall keepalived
fifi
vim keepalived.conf
global_defs
vrrp_script check_nginx_alive
vrrp_instance vi_1
}
上述方案,備用機並沒有被很好地利用,因此可以採用雙主熱備。
#虛擬出來的ip,可以有多個(vip)
virtual_ipaddress
}vrrp_instance vi_2
#虛擬出來的ip,可以有多個(vip)
virtual_ipaddress
}(backup 192.168.1.152)
global_defs
vrrp_instance vi_1
#虛擬出來的ip,可以有多個(vip)
virtual_ipaddress
}vrrp_instance vi_2
#虛擬出來的ip,可以有多個(vip)
virtual_ipaddress
}
keepalive 安裝和雙機熱備
2 安裝 unzip keepalived master.zip cd keepalived master 或 tar zxvf keepalived 1.2.7.tar.gz cd keepalived 1.2.7 configure prefix usr local keepalived 或 c...
centos7 keepalive雙機熱備
簡單實現keepalive雙擊熱備 摘要 準備兩台虛擬機器a 192.168.161.7 b 192.168.161.35 虛擬ip 192.168.161.10 keepalive程序 具體關於keepalive介紹可直接移步到其官網 原理的話 就是每台虛擬機器將其mac位址發布在內網,將a設定為...
keep alive實現原理
二 keep alive介紹與應用 2.1 keep alive是什麼 keep alive是乙個抽象元件 它自身不會渲染乙個dom元素,也不會出現在父元件鏈中 使用keep alive包裹動態元件時,會快取不活動的元件例項,而不是銷毀它們。乙個場景 使用者在某個列表頁面選擇篩選條件過濾出乙份資料列...