mysql + keepalvied

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql + keepalvied相关的知识,希望对你有一定的参考价值。

技术分享图片
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 {
[email protected]
}

notification_email_from [email protected]
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的主要内容,如果未能解决你的问题,请参考以下文章

部分代码片段

linux中怎么查看mysql数据库版本

从mysql的片段中加载ListView

连接MySQL出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)(代码片段

使用 json rereiver php mysql 在片段中填充列表视图

关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4Unknown system variable ‘query_cache_size(代码片段