码迷,mamicode.com
首页 > 数据库 > 详细

mysql + keepalvied

时间:2018-11-13 20:20:12      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:rip   netlink   进程   email   auto   virt   cas   type   connect   

技术分享图片
2.1.增加配置

master
auto-increment-increment = 2  
auto-increment-offset = 1    

auto-increment-increment = 2     
auto-increment-offset = 2  

1.下载keepalived

http://www.keepalived.org/software/keepalived-1.4.2.tar.gz
yum -y install openssl openssl-devel  
yum -y install libnl libnl-devel
yum install -y libnfnetlink-devel

./configure --prefix=/usr/local/keepalived
make
make install

cp keepalived/etc/init.d/keepalived /etc/init.d/
cp keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp sbin/keepalived /usr/sbin/

查看vip是否抢占
ip addr show dev ens160

keepalived.conf

! Configuration File for keepalived

global_defs {
notification_email {
xxx@xxx.cn
}

notification_email_from ops@wangshibo.cn
smtp_server 127.0.0.1 
smtp_connect_timeout 30
router_id MASTER-HA
}

vrrp_script chk_mysql_port {     #检测mysql服务是否在运行。有很多方式,比如进程,用脚本检测等等
    script "/opt/chk_mysql.sh"   #这里通过脚本监测
    interval 2                   #脚本执行间隔,每2s检测一次
    weight -5                    #脚本结果导致的优先级变更,检测失败(脚本返回非0)则优先级 -5
    fall 2                    #检测连续2次失败才算确定是真失败。会用weight减少优先级(1-255之间)
    rise 1                    #检测1次成功就算成功。但不修改优先级
}

vrrp_instance VI_1 {
    state BACKUP  
    interface ens160      #指定虚拟ip的网卡接口
    mcast_src_ip xxxxx
    virtual_router_id 51    #路由器标识,MASTER和BACKUP必须是一致的
    priority 101            #定义优先级,数字越大,优先级越高,在同一个vrrp_instance下,MASTER的优先级必须大于BACKUP的优先级。这样MASTER故障恢复后,就可以将VIP资源再次抢回来 
    advert_int 1         
    authentication {   
        auth_type PASS 
        auth_pass 1111     
    }
    virtual_ipaddress {    
        xxxxxx 没有被分配的ip
    }

track_script {               
   chk_mysql_port             
}
}

mysql + keepalvied

标签:rip   netlink   进程   email   auto   virt   cas   type   connect   

原文地址:http://blog.51cto.com/12473494/2316539

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!