一前言
https://www.cnblogs.com/huningfei/p/12758980.html 在这篇文章中只用了一个harpoxy,如果它挂掉之后,后端的数据库也不能访问了,这还是存在单点故障的,所以接下来我准备使用keepalived(双主)+haproxy 去实现
二 环境说明
debian系统
keepalived_master1 +haproxy 192.168.7.32
keepalived_master1 +haproxy 192.168.9.52
mysql_master 192.168.6.123
mysql_slave1 192.168.4.21
mysql_slave2 192.168.9.53
vip1:192.168.8.102
vip2:192.168.8.103
三 keepalived配置文件
1 keepalived配置文件(master1)
master1既是一个主,又是另一个主的从,扮演了两个角色
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id HAproxy237
}
vrrp_script chk_haproxy { #HAproxy 服务监控脚本
script "/etc/keepalived/check_haproxy.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS