170配置
192.168.31.169 cip 代表客戶機
192.168.31.170 代表路由裝置外網位址
192.168.160.136 代表路由裝置內網位址
10.0.0.200 代表路由器在內網被vip指向外網的位址
170和136用裝置模擬路由器效果
192.168.160.140 rip 代表http伺服器
192.168.160.150 rip 代表http伺服器
192.168.160.160 dip 代表lvs裝置內網位址
192.168.160.170 dip 代表lvs裝置內網位址
192.168.160.200 vip 代表lvs裝置外網位址
yum install keepalived.x86_64 -y
ssh-keygen
ssh-copy-id 192.168.160.170
vim /etc/hosts
192.168.160.160 ka1
192.168.160.170 ka2
! configuration file for keepalived
global_defs
#設定發郵件的是誰
notification_email_from keepalived@localhost
#設定發郵件的位址
smtp_server 127.0.0.1
smtp_connect_timeout 30
#設定發郵件的id名稱
router_id ka1
#設定多播位址
vrrp_mcast_group4 224.100.100.100
}vrrp_instance vi_1
#設定虛擬的vip位址
virtual_ipaddress
#新增指令碼,在狀態變更時可以傳送郵件提醒狀態變化
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
vim notify.sh
#!/bin/bash
#contact=
'root@localhost'
notify(
)case
$1in
master)
notify master;;
backup)
notify backup;;
fault)
notify fault;;
*)echo
"usage: $(
basename $0)
"exit 1;;
esac
! configuration file for keepalived
global_defs
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id ka2
vrrp_mcast_group4 224.100.100.100
}vrrp_instance vi_1
virtual_ipaddress
}
Keepalived 實現高可用
對於主負載均衡伺服器,修改配置檔案 vim etc keepalived keepalived.conf configuration file for keepalived global defs vrrp instance vi 1 virtual ipaddress 備用負載均衡伺服器 vim ...
keepalived實現高可用
一.keepalived是什麼 keepalived最初是為lvs負載均衡設計的,用於監控lvs集群系統中的各個節點的服務狀態。後來又加入了基於vrrp的高可用功能,所以也可以作為nginx,mysql等服務的高可用解決方案使用。vrrp virtual router redundancy prot...
keepalived實現nginx的高可用
前言 優化nginx proxy 可能出現單點故障的情況,通過keepalived得方式來完成nginx proxy伺服器之間的高可用,因為keepalived的工作機制是通過心跳線來檢測伺服器之間是否出現故障,但是並不能檢測nginx proxy 服務是否正常工作,所以需要採用編寫指令碼判斷的方式...