当前位置:网站首页>Keeping MySQL highly available
Keeping MySQL highly available
2022-07-25 12:24:00 【Tota King Li】
keeplived Realization mysql High availability
Prerequisite
Two sets of server It's all installed mariadb
server1: 10.243.68.158
server2: 10.243.68.159
virtual ip:10.243.68.160
install keepalived
download keepalived Of rpm package :keepalived-1.3.5-8.el7_6.x86_64.rpm
install keeepalived
[[email protected] ~]# ll
total 356
-rw-r--r--. 1 root root 210 Feb 25 03:33 chk_rtm.sh
-rw-r--r--. 1 root root 336976 Feb 25 03:33 keepalived-1.3.5-8.el7_6.x86_64.rpm
-rw-r--r--. 1 root root 690 Feb 25 03:33 keepalived.conf
-rw-r--r--. 1 root root 1113 Feb 25 03:33 my.cnf
-rw-r--r--. 1 root root 10249 Feb 25 03:33 zabbix_agentd.conf
[[email protected] ~]# rpm -ivh keepalived-1.3.5-8.el7_6.x86_64.rpm
warning: keepalived-1.3.5-8.el7_6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:keepalived-1.3.5-8.el7_6 ################################# [100%]
[[email protected] ~]#
To configure keepalived
To configure 10.243.68.158 server Configuration modification file /etc/keepalived/keepalived.conf as follows :
[[email protected] ~]# cat /etc/keepalived/keepalived.conf
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server root
smtp_connect_timeout 30
router_id RTM # Load balancing flag , It should be unique in the LAN .
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_script chk_rtm {
script "/etc/keepalived/chk_rtm.sh"
interval 3
weight -20
}
vrrp_instance VI_1 {
state BACKUP
interface enp0s3 # network card
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_rtm
}
virtual_ipaddress {
10.243.68.160
}
}
To configure 10.243.68.159 server Configuration modification file /etc/keepalived/keepalived.conf as follows :
[[email protected] ~]# cat /etc/keepalived/keepalived.conf
global_defs { ### Global configuration
notification_email { ###keepalived The destination address of the email sent in case of failure
[email protected]
}
notification_email_from [email protected] ###keepalived The source address of the email sent in case of failure
smtp_server root ### mail smtp Address
smtp_connect_timeout 30 ### Connect smtp Timeout time
router_id RTM
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_script chk_rtm { ### Check performed mysql Script for , If mysql Hang up , The server The priority of is reduced 20
script "/etc/keepalived/chk_rtm.sh"
interval 3
weight -20
}
vrrp_instance VI_1 { ## The instance configuration ,VI_1 For instance name , Modifiable
state BACKUP ### state , It can be MASTER or BACKUP
interface enp0s3 ### node IP Network card of , For hair VRRP package .
virtual_router_id 51 ## Example of ID
priority 100 ### priority , The higher the priority, the higher
advert_int 1 ### Heartbeat interval , I can't receive my heartbeat for a second The standby node takes over
authentication { ### Password authentication between services
auth_type PASS
auth_pass 1111
}
track_script { ## Configure script check mysql Normal service
chk_rtm
}
virtual_ipaddress { ##vip binding , Bound to the interface Set the network card
10.243.68.160
}
}
Add script file chk_rtm.sh Executable rights :
[[email protected] keepalived]# pwd
/etc/keepalived
[[email protected] keepalived]# ll
total 8
-rw-r--r--. 1 root root 218 Feb 21 20:25 chk_rtm.sh
-rw-r--r--. 1 root root 728 Feb 21 19:08 keepalived.conf
[[email protected] keepalived]# chmod +x chk_rtm.sh
[[email protected] keepalived]# ll
total 8
-rwxr-xr-x. 1 root root 218 Feb 21 20:25 chk_rtm.sh
-rw-r--r--. 1 root root 728 Feb 21 19:08 keepalived.conf
Check the script
#!/bin/bash
MYSQL_PROCESS_EXISTED=$(systemctl status mysql | grep "active (running)" | wc -l)
if [ "${MYSQL_PROCESS_EXISTED}" == "1" ];then
exit 0
else
exit 1
fi
restart keepalived
[[email protected] keepalived]#systemctl enable keepalived
test
1. In two server The terminal execution of ip a see server Is there a virtual ip:10.243.68.160
[[email protected] keepalived]#ip a
2. Virtual in ip Of server Stop on the terminal mysql service , View virtual ip Whether it exists in another server
边栏推荐
- Basic concepts of NLP 1
- 【7】 Layer display and annotation
- Eureka registration center opens password authentication - record
- OSPF comprehensive experiment
- Video caption (cross modal video summary / subtitle generation)
- 【6】 Map box settings
- Multi label image classification
- Go garbage collector Guide
- keepalived实现mysql的高可用
- Behind the screen projection charge: iqiyi's quarterly profit, is Youku in a hurry?
猜你喜欢

给生活加点惊喜,做创意生活的原型设计师丨编程挑战赛 x 选手分享

The first scratch crawler

From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"

Crawler crawls dynamic website

Zero shot image retrieval (zero sample cross modal retrieval)

Communication bus protocol I: UART

Intelligent information retrieval (overview of intelligent information retrieval)

Figure neural network for recommending system problems (imp-gcn, lr-gcn)

基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现

3.2.1 what is machine learning?
随机推荐
Zuul gateway use
Median (two point answer + two point search)
Scott+scott law firm plans to file a class action against Yuga labs, or will confirm whether NFT is a securities product
Multi label image classification
客户端开放下载, 欢迎尝鲜
logstash
【Flutter -- 实例】案例一:基础组件 & 布局组件综合实例
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
【11】 Production and adjustment of vector and grid data Legends
Zuul网关使用
那些离开网易的年轻人
NLP knowledge - pytorch, back propagation, some small pieces of notes for predictive tasks
2.1.2 application of machine learning
Fault tolerant mechanism record
Mirror Grid
【2】 Grid data display stretch ribbon (take DEM data as an example)
循环创建目录与子目录
Ups and downs of Apple's supply chain in the past decade: foreign head teachers and their Chinese students
Jenkins configuration pipeline
Pytorch project practice - fashionmnist fashion classification