keepalive实现VIP高可用

1.keepalive原理图

2.keepalive下载

官方下载路径www.keepalived.org

3.keepalive安装

下载后是未编译的源码<spanlang="en-us>">

需要编译安装

Unzip keepalived-1.3.6.zip
Cd keepalived-1.3.6
./configure
Make all
Make install

4.keepalive配置

创建配置目录

Mkdir -p /etc/<wiz_tmp_highlight_tag class="cm-searching" style="background: yellow;">keepalived

编辑<wiz_tmp_highlight_tag class="cm-searching" style="background: yellow;">keepalived.conf文件

! Configuration File for keepalived
 
global_defs {
   router_id router2
}
 
vrrp_instance VI_2 {
    state BACKUP
    interface eth1
    virtual_router_id 188
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 2222
    }
    virtual_ipaddress {
        134.64.14.175   
    }
}
! Configuration File for keepalived
 
global_defs {
   router_id router1
}
 
vrrp_instance VI_2 {
    state BACKUP
    interface eth1
    virtual_router_id 188
    priority 101
    nopreempt
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 2222
    }
    virtual_ipaddress {
        134.64.14.175 #vip
    }
}

5.keepalive启动

/usr/local/sbin/keepalived -f /etc/keepalived/keepalived.conf

keepalived启动后会有三个进程

父进程:内存管理,子进程管理等等

子进程:VRRP子进程

子进程:healthchecker子进程

6.加入系统自启动

cp /usr/local/sbin/keepalived /etc/rc.d/init.d/
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/sbin/keepalived /usr/sbin/
vi /etc/rc.local
/etc/init.d/keepalived start

7.重启验证ip切换情况

8.问题解决

在配置过程中遇到一个报错,vip拉不起来

Jan 16 20:04:23 ty14165 Keepalived_vrrp[15067]: VRRP_Instance(VI_2) ignoring received advertisment...
Jan 16 20:04:24 ty14165 Keepalived_vrrp[15067]: (VI_2): ip address associated with VRID 88 not present in MASTER advert : 134.64.14.175
Jan 16 20:04:24 ty14165 Keepalived_vrrp[15067]: bogus VRRP packet received on eth1 !!!

问题原因是virtual_router_id 在同一网络中不同的集群,该参数值不能一致,必须修改

转载于:https://www.cnblogs.com/tonnytangy/p/8298768.html

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值