linux 高可用
keepalived 的介绍
使用keepalived配置高可用
master 上
yum install -y keepalivedyum install -y nginxvim /etc/keepalived/keepalived.conf
global_defs {
notification_email {
xx@qq.com # 告警邮件
}
notification_email_from root@qq.com # 告警邮件服务器
smtp_server 127.0.0.1 # smtp 服务器器
smtp_connect_timeout 30 # 超时时间
router_id LVS_DEVEL
}
vrrp_script chk_nginx {
script "/usr/local/sbin/check_ng.sh" # 心跳检测脚本
interval 3 # 检测的时间间隔,单位s
}
vrrp_instance VI_1 {
state MASTER # 角色,MASTER | BACKUP
interface ens33 # 使用的网卡
virtual_router_id 51 # 路由id
priority 100 # 权重,权重越高优先级越高
advert_int 1 #
authentication { # 认证
auth_type PASS # 密码认证
auth_pass 123456 # 密码
}
virtual_ipaddress {
192.168.127.100 # 共有ip
}
track_script {
chk_nginx # 检测的脚本
}
}slave 上
测试高可用
最后更新于