133.1 Keepalived安装
yum -y install keepalived
systemctl enable keepalived
#!/bin/bash
MYSQL_PING=`mysqladmin -uroot -p123456 ping`
MYSQL_OK="mysqld is alive"
if [[ "$MYSQL_PING" != "$MYSQL_OK" ]]
then
echo "mysql is not running"
killall keepalived
else
echo "mysql is running"
fi
[root@vm1 ~]# chmod +x /etc/keepalived/check_mysql.sh
[root@vm1 ~]# ll /etc/keepalived/check_mysql.sh
-rwxr-xr-x 1 root root 233 Dec 29 07:34 /etc/keepalived/check_mysql.sh
[root@vm1 ~]#
[root@vm1 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
}
vrrp_script check_mysql {
script "/etc/keepalived/check_mysql.sh"
interval 2
}
vrrp_instance VI_1 {
state BACKUP
interface ens192
virtual_router_id 51
priority 100
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.188
}
track_script {
check_mysql
}
}
[root@vm1 ~]# systemctl start keepalived
[root@vm2 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
}
vrrp_script check_mysql {
script "/etc/keepalived/check_mysql.sh"
interval 2
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.188
}
track_script {
check_mysql
}
}
[root@vm2 ~]# systemctl start keepalived
大数据视频推荐:
网易云课堂
CSDN
人工智能算法竞赛实战
AIops智能运维机器学习算法实战
ELK7 stack开发运维实战
PySpark机器学习从入门到精通
AIOps智能运维实战
腾讯课堂
大数据语音推荐:
ELK7 stack开发运维
企业级大数据技术应用
大数据机器学习案例之推荐系统
自然语言处理
大数据基础
人工智能:深度学习入门到精通