Centos7.5安装mysql5.7.24二进制包方式部署(keepalived+主从复制)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7.5安装mysql5.7.24二进制包方式部署(keepalived+主从复制)相关的知识,希望对你有一定的参考价值。
一、环境准备:
操作系统: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
二、mysql5.7安装及主从复制配置
主库:172.16.8.247
从库:172.16.8.249
数据安装参考:
一、Centos7.5安装mysql5.7.24二进制包方式部署
二、Centos7.5安装mysql5.7.24二进制包方式部署(主从复制)
三、Keepalived概述
Keepalived 是一个可以快速构建高用服务的解决方案。设计之初针对 LVS 负载均衡提供高可用 的,它集成对 LVS 集群管理,包括健康检查、故障剔除等功能。
Keepalived 使用 VRRP
四 、Keepalived安装及配置
1、安装keepalived
主库、从库都需要安装
yum -y install keepalived
2、 配置keeepalived配置文件(主库)
#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
3、 配置keeepalived配置文件(从库)
# 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+主从复制)的主要内容,如果未能解决你的问题,请参考以下文章
Centos7.5安装mysql5.7.24二进制包方式部署(keepalived+主从复制)