标签:5.7 counter vim zabbix zab 脚本 virt .com add
一、环境准备:操作系统:CentOS Linux release 7.5.1804 (Core)
mysql版本:mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
主库:172.16.8.247
从库:172.16.8.249
主机名:
172.16.8.247 qas-zabbix-node01
172.16.8.249 qas-zabbix-node02
172.16.8.248 vip
主库:172.16.8.247
从库:172.16.8.249
数据安装参考:
一、Centos7.5安装mysql5.7.24二进制包方式部署
二、Centos7.5安装mysql5.7.24二进制包方式部署(主从复制)
Keepalived 是一个可以快速构建高用服务的解决方案。设计之初针对 LVS 负载均衡提供高可用 的,它集成对 LVS 集群管理,包括健康检查、故障剔除等功能。
Keepalived 使用 VRRP
主库、从库都需要安装
yum -y install keepalived
#vim /etc/keepalived/keepalived.conf
global_defs {
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id mysql-247
}
vrrp_script chk_mysql {
script "/etc/keepalived/scripts/mysql_check.sh"
interval 2
weight -5
fall 2
rise 1
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 61
priority 100
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 2222
}
track_script {
chk_mysql
}
virtual_ipaddress {
172.16.8.248
}
}
检查脚本
vim /etc/keepalived/scripts/mysql_check.sh
#!/bin/bash
counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)
if [ "${counter}" -eq 0 ]; then
service keepalived stop
fi
# vim /etc/keepalived/keepalived.conf
global_defs {
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id mysql-249
}
vrrp_script chk_mysql {
script "/etc/keepalived/scripts/mysql_check.sh"
interval 2
weight -5
fall 2
rise 1
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 61
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 2222
}
track_script {
chk_mysql
}
virtual_ipaddress {
172.16.8.248
}
}
检查脚本
vim /etc/keepalived/scripts/mysql_check.sh
#!/bin/bash
counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)
if [ "${counter}" -eq 0 ]; then
service keepalived stop
fi
Centos7.5安装mysql5.7.24二进制包方式部署(keepalived+主从复制)
标签:5.7 counter vim zabbix zab 脚本 virt .com add
原文地址:http://blog.51cto.com/10880347/2321855