MySQL
常用语句
用户相关\管理相关\数据相关
视图\事件\存储过程\函数\游标\触发器
事务\分区
常用工具
管理优化
锁问题
MySQL日志
异步复制
半同步复制
复制管理
5.7开启并行复制
双主备份
故障问题
索引
时区
mysql_random_data_load 数据生成
表的导出导入
MySQLdump逻辑备份
XtraBackup全备
XtraBackup增备
XtraBackup原表数据恢复
安装MySQL
ProxySQL中间件
Atlas中间件
keepalived安装
MHA安装
MHA恢复
mha复制检查报错及解决过程
集群Cluster安装
维护Cluster
开启审计功能
本文档使用MrDoc发布
返回首页
-
+
keepalived安装
2019年11月16日 22:17
admin
###安装 yum -y install keepalived ###启动与停止 systemctl start keepalived.service systemctl status keepalived.service ###修改主配置 vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id MySQL1 vrrp_skip_check_adv_addr vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script chek_mysql { script "/etc/keepalived/mysql_down.sh" interval 2 } vrrp_instance VI_1 { state BACKUP #角色 interface ens33 #绑定网卡 virtual_router_id 60 priority 100 #优先级,越高为主 advert_int 1 nopreempt #非抢占模式 authentication { auth_type PASS auth_pass 1qaz@WSX } track_script { chek_mysql #监控脚本 } virtual_ipaddress { 192.168.31.240 } } ####主脚本 vim /etc/keepalived/mysql_down.sh #!/bin/bash Ng=`ps -C mysqld --no-header | wc -l` if [ $Ng -eq 0 ];then pkill keepalived fi ###修改从配置 vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id MySQL1 vrrp_skip_check_adv_addr vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script chek_mysql { script "/etc/keepalived/mysql_down.sh" interval 2 } vrrp_instance VI_1 { state BACKUP #角色 interface ens33 #绑定网卡 virtual_router_id 60 priority 90 #优先级,越高为主 advert_int 1 nopreempt #非抢占模式 authentication { auth_type PASS auth_pass 1qaz@WSX } track_script { chek_mysql #监控脚本 } virtual_ipaddress { 192.168.31.240 } } ####从脚本 vim /etc/keepalived/mysql_down.sh #!/bin/bash Ng=`ps -C mysqld --no-header | wc -l` if [ $Ng -eq 0 ];then pkill keepalived fi ###keepalived配置,解决vip无法ping通,虚拟服务器端口无法访问的问题 keepalived.conf中vip配置好后,通过ip addr可以看到vip已经顺利挂载,但是无法ping通,并且防火墙都已关闭,**原因是keepalived.conf配置中默认vrrp_strict打开了,需要把它注释掉。重启keepalived即可ping通。**
分享到: