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

mysql集群之keepalived简单搭建

时间:2015-10-22 14:33:15      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:keepalived mysql

1安装必须的相关包

yum -y install  kernel-devel  openssl* popt popt-devel 


2下载安装

wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gz

tar  -xf keepalived-1.2.9.tar.gz 

mkdir /usr/local/keepalived 

cd ~/ keepalived-1.2.9

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

make && make install

cp /usr/local/keepalived/sbin/keepalived  /usr/sbin/ 

cp /usr/local/keepalived/etc/sysconfig/keepalived  /etc/sysconfig

cp /usr/local/keepalived/etc/rc.d/init.d/keepalived  /etc/init.d/

chmod +x /etc/init.d/keepalived

mkdir /etc/keepalived

cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived


3修改配置文件如下

[root@M128 ~]# vim /etc/keepalived/keepalived.conf

global_defs {

    notification_email {

 jikaituo@126.com

    }

    notification_email_from jikaituo@126.com

      smtp_server smtp.126.com   # 邮件服务器地址  

    smtp_connect_timeout 30     # 连接超时时间  

    router_id LVS_Master

}

vrrp_script chk_http_port {

    script  "/etc/keepalived/check_haproxy.sh"    # haproxy运行检测脚本[haproxy宕掉重启haproxy服务]  

    interval        5                     # 脚本执行间隔  

    weight         -5                    # 执行脚本后优先级变更:5表示优先级+5;-5则表示优先级-5

}

vrrp_instance VI_A {

    state MASTER                    # 主上此值为MASTER,从上为BACKUP 

    interface eth0

    virtual_router_id 50           # 此值主从必须一致

    priority 100

    advert_int 1

    authentication {                   # authentication两个参数值,主从也必须一致  

        auth_type PASS

    auth_pass yiban

    }

track_script {

    chk_http_port

    }

    virtual_ipaddress {

          192.168.78.220

    }

}


5启动keepalived

确保网络正常

service network restart (线上不要这么做) 

/etc/init.d/keepalived start

查看结果

ip a


                     

本文出自 “雪藤六” 博客,请务必保留此出处http://879100963.blog.51cto.com/6686639/1705086

mysql集群之keepalived简单搭建

标签:keepalived mysql

原文地址:http://879100963.blog.51cto.com/6686639/1705086

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