配好yum倉庫解決
yum -y install keepalived-1.2.7-3.el6.x86_64.rpm
#安裝keepalived包
[root@zys data]# rpm -aq keepalived
keepalived-1.2.7-3.el6.x86_64
[root@zys data]# /etc/init.d/keepalived start
正在啟動 keepalived: [確定]
[root@zys data]# ps -el | grep keep
1 s root 4153 1 0 80 0 - 27526 poll_s 23:38 ? 00:00:00 /usr/sbin/keepalived -d
1 s root 4155 4153 0 80 0 - 28052 poll_s 23:38 ? 00:00:00 /usr/sbin/keepalived -d
5 s root 4156 4153 0 80 0 - 28052 poll_s 23:38 ? 00:00:00 /usr/sbin/keepalived -d
啟動後有3個keepalived程序表示安裝正確
[root@zys data]# ip add | grep 192.168
inet 192.168.227.11/24 brd 192.168.227.255 scope global eth0
inet 192.168.200.16/32 scope global eth0
inet 192.168.200.17/32 scope global eth0
inet 192.168.200.18/32 scope global eth0
預設有三個vip位址
主配置檔案
vim /etc/keepalived/keepalived.conf
修改主配置檔案
1 ! configuration file for keepalived
2 3 global_defs
9 notification_email_from [email protected]
10 smtp_server 192.168.200.1
11 smtp_connect_timeout 30#11行以前是keepalive的郵件報警設定,預設即可
12 router_id ningx01#唯一識別符號,主節點與備節點的router_id不能相同
13 }
14 15 vrrp_script chk_nginx
21 22 vrrp_instance vi_1
32 virtual_ipaddress
35 track_script
38 }
前11行為設定報警郵件的設定,預設即可,報警郵件可用zabbix
[root@zys data]# /etc/init.d/keepalived restart
停止 keepalived: [確定]
正在啟動 keepalived: [確定]
重啟服務
[root@zys data]# ip add | grep eth0
2: eth0:
mtu 1500 qdisc pfifo_fast state up qlen 1000
inet 192.168.227.11/24 brd 192.168.227.255 scope global eth0
inet 192.168.227.10/24 scope global secondary eth0:1
檢查192.168.227.10的vip已經出現
backup的配置檔案和master的一樣,除下表的內容外
keepalived配置引數master節點backup節點
router_id(唯一標識)router_id lb01router_id lb02
state(角色狀態)state masterstate backup
priority(優先順序)priority 150priority 100
nginx服務掛了,自動關閉keepalived,
自動關閉keepalived服務指令碼
[root@zys data]# cat chk_nginx.py
#!/usr/bin/env python
import commands
state,valu = commands.getstatusoutput("netstat -atupn | grep nginx | grep listen| wc -l")
if valu == "0":
print "ooo"
commands.getstatusoutput("service keepalived stop")
Keepalived高可用集群部署
keepalived高可用集群部署 部署三颱linux伺服器,兩台做web伺服器,並部署keepalived高可用軟體,一台作為客戶端主機 client 192.168.10.1 web1 主 192.168.10.10 web2 從 192.168.10.20 部署vip 192.168.4.15...
部署高可用keepalived元件
執行 keepalived 和 haproxy 的節點稱為 lb 節點。由於 keepalived 是一主多備執行模式,故至少兩個 lb 節點。本文件復用 master 節點的三颱機器,haproxy 監聽的埠 8443 需要與 kube apiserver 的埠 6443 不同,避免衝突。keep...
Keepalived高可用集群
目錄 keepalived keepalived實現主備 keepalived軟體起初是專為lvs負載均衡軟體設計的,用來管理並監控lvs集群系統中各個伺服器節點的狀態,後來又加入了實現高可用的vrrp功能。因此 keepalived 除了能夠管理lvs軟體外,還可以作為其他服務 例如 nginx ...