码迷,mamicode.com
首页 > 其他好文 > 详细

公司nginx keepalived tomcat cxf 搭建高可用负载均衡实战系列1- keepalived的安装配置

时间:2017-09-09 13:49:19      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:cat   star   ipad   for   bsp   figure   top   server   读取   

 

1,ip说明

 

vip

10.50.13.67

server1

10.50.13.68

server2

10.50.13.140

 

2,keepalived安装

keepalived通常与lvs或者nginx结合使用保证集群的高可用,keepalived的master会绑定一个vip用来对外服务并定期向backup发送消息,当backup接收不到消息时则会判定master已经挂掉,backup将升为master并且绑定vip继续对外提供服务,从而保证高可用。下面介绍keepalived的安装

安装依赖 openssl-devel popt-devel

yum install -y gcc openssl-devel popt-devel

技术分享

 

技术分享

 

下载 /keepalived-1.2.24.tar.gz
 wget http://www.keepalived.org/software/keepalived-1.2.24.tar.gz
 
tar zxvf keepalived-1.2.24.tar.gz
 
cd keepalived-1.2.24
 
./configure --prefix=/opt/wacos/aaatool/keepalived
 
make && make install
 
设置开机启动
cp /opt/wacos/aaatool/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
cp /opt/wacos/aaatool/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
 
cp /ut/server/keepalived-1.2.24/sbin/keepalived /usr/sbin/
 
cp /opt/wacos/aaatool/keepalived/sbin/keepalived /usr/sbin/
 
chmod 755 /etc/init.d/keepalived
 
keepalived启动会默认读取keepalived/keepalived.conf配置文件
mkdir /etc/keepalived
 拷贝keepalived.conf配置文件到/etc/keepalived/
 
 keepalived.conf配置文件如下
 
! Configuration File for keepalived
 
global_defs {
   router_id edu-proxy-02
}
 
vrrp_script chk_nginx {
    script "/etc/keepalived/nginx_check.sh"
    interval 2
    weight -20
}
 
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    mcast_src_ip 10.50.13.68
    priority 90
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
 
    track_script {
        chk_nginx
    }
 
    virtual_ipaddress {
        10.50.13.67
    }
}
 
 
 启动 关闭 keepalived
 
service keepalived start[stop]
 
 
 
ip a查看是否绑定虚拟ip10.50.13.67
 
技术分享

 

 3,备keepalived安装

 和说明主keepalived 过程一样,只是配置文件/etc/keepalived/keepalived。conf一处需要修改

 mcast_src_ip 10.50.13.140

 

4,测试高可用

关掉10.50.13.67的keepalived后,发现vip绑定到了10.50.13.140

重启10.50.13.67的keepalived,vip又重新绑定到了10.50.13.67

 

公司nginx keepalived tomcat cxf 搭建高可用负载均衡实战系列1- keepalived的安装配置

标签:cat   star   ipad   for   bsp   figure   top   server   读取   

原文地址:http://www.cnblogs.com/yeyusheng/p/7497965.html

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