IP Failover Setup using Keepalived on CentOS/Redhat 6
source url:http://tecadmin.net/ip-failover-setup-using-keepalived-on-centos-redhat-6/
Keepalived is used for IP failover between two servers. It facilities for load balancing and high-availability to Linux based infrastructures. It works on VRRP ( Virtual Router Redundancy Protocol ) protocol. We have running two load balance servers using HAProxy and now we need to implement VRRP between both servers. This tutorial will help you to configure KeepAliveD, Use thistutorial to configure HAProxy on both servers.
Network Scenario:
1. LB1 Server: 192.168.10.111 ( eth1 )
2. LB2 Server: 192.168.10.112 ( eth1 )
3. Virtual IP: 192.168.10.121
Now we are implementing ip failover setup between LB1 and LB2 servers.
Graphical representation of Fail over Setup:

Step 1: Install Required Packages
Use following command to install required packages to configure Keepalived on server.
# yum install gcc kernel-headers kernel-devel
Step 2: Install Keepalived
Keepalived is available in centos base repository. Install it using yum command line tool.
# yum install keepalived
Keepalived configuration File: /etc/keepalived/keepalived.conf
Step 3: Configure Keepalived on LB1.
Edit Keepalived configuration file on LB1 and add following configuration.
vrrp_instance VI_1 {
interface eth1
state MASTER
virtual_router_id 10
priority 101 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.10.121
}
}
Step 4: Configure Keepalived on LB2.
Edit Keepalived configuration file on LB2 and add following configuration.
vrrp_instance VI_1 {
interface eth1
state BACKUP
virtual_router_id 10
priority 100 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.10.121
}
}
Note: 1. priority value will be higher on Master server, It doesn't matter what you used in state. If your state is MASTER but your priority is lower than the router with BACKUP, you will lose the MASTER state.
2. virtual_router_id should be same on both LB1 and LB2 servers.
3. By default single vrrp_instance support up to 20 virtual_ipaddress. In order to add more addresses you need to add more vrrp_instance
Step 5: Start Keepalived
Start Keepalived service using following command and also configure to auto start on system boot.
# service keepalived start
# chkconfig keepalived on
Step 6: Check Virtual IPs
By default virtual ip will assigned to master server, In case of master get down, it will automatically assigned to slave server. Use following command to show assigned virtual ip on interface.
# ip addr show eth1
Sample output
2: eth1: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:0c:29:6f:ed:60 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.111/24 brd 192.168.1.255 scope global eth1
inet 192.168.10.121/32 scope global eth1
inet6 fe80::20c:29ff:fe6f:ed60/64 scope link
valid_lft forever preferred_lft forever
Verify IP Failover
1. Shutdown master server ( LB1 ) and check if ips are automatically assigned to slave server.
# ip addr show eth1
2. Now start LB1 and stop slave server ( LB2 ). IPs will automatically assigned to master server.
# ip addr show eth1
3. Watch log files to insure its working
# tailf /var/log/messages
Sample Output
Mar 19 17:30:24 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 19 17:30:25 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) Entering MASTER STATE
Mar 19 17:30:25 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) setting protocol VIPs.
Mar 19 17:30:25 localhost Keepalived_healthcheckers[6957]: Netlink reflector reports IP 192.168.10.121 added
Mar 19 17:30:25 localhost avahi-daemon[1407]: Registering new address record for 192.168.10.121 on eth1.IPv4.
Mar 19 17:30:25 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for
I hope this article will help to setup IP failover between two load balance servers.
Related posts:
- How to Enable Email Alerts in Keepalived Its a good practice to enable email alerts in your...
- How to Setup Master Slave DNS Server on CentOS 6 and RHEL The DNS ( Domain Name System ) is a distributed...
- Install and Configure Sendmail on CentOS/RHEL 6 Sendmail is a mail server used for sending and receiving...
- Keep your CentOS/Redhat server up to date Hi Guys, Being a system administrator, you always need to...
IP Failover Setup using Keepalived on CentOS/Redhat 6的更多相关文章
- install keepalived on RedHat/CentOS to provide IP failover for web cluster
Contents [hide] 1 Introduction 2 Our Sample Setup 3 Install Keepalived 4 Install Kernel Headers 5 C ...
- CentOS / Redhat : Configure CentOS as a Software Router with two interfaces
CentOS / Redhat : Configure CentOS as a Software Router with two interfaces Linux can be easily co ...
- 定制CentOS (Redhat AS 5.1)安装盘
CentOS(Redhat)提供了一套完整的自动化安装机制,利用该机制,我们可以自己定制无人值守的自动安装光盘,也可以进行系统裁减,甚至可以以CentOS为基础制作自己软件系统的系统安装盘.以下全部内 ...
- 在Windows基础上(硬盘)安装Linux操作系统(CentOS/RedHat)
注:该方法安装CentOS ,RedHat均没有问题,其它Linux操作系统,没有尝试过. 0.创建一个fat32的盘.我分了8G给这个盘,盘符为F.F盘以后的内存所有删除,作为未分配的内存.这个留用 ...
- setup FTP server on CentOS 7
Setup FTP Server on CentOS 7 Install vsftpd vsftpd (Very Secure File Transport Protocol Daemon) is a ...
- Xrdp - 通过Windows的RDP连接Linux远程桌面(Ubuntu/CentOS/Redhat 7)(转载)
您多久访问一次Linux桌面? 您使用什么工具来访问远程桌面? Xrdp是一个开源工具,允许用户通过Windows RDP访问Linux远程桌面. 除了Windows RDP之外,xr ...
- Xrdp - 通过Windows的RDP连接Linux远程桌面(Ubuntu/CentOS/Redhat 7)
Xrdp - 通过Windows的RDP连接Linux远程桌面(Ubuntu/CentOS/Redhat 7) 您多久访问一次Linux桌面? 您使用什么工具来访问远程桌面? Xrdp是一个开源工具, ...
- CentOS(RedHat) 6.2 Samba share权限拒绝访问
在实现<CentOS(RedHat) 6.2下Samba配置>的过程中,发现CentOS 6.2的Samba share总是没有权限写文件,已经试过在Windows XP/Windows ...
- Linux/centos/redhat下各种压缩解压缩方式详解
1.zip命令 zip -r myfile.zip ./* 将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件. 2.unzip unzip -o -d ...
随机推荐
- SQLSERVER新建表的时候页面分配情况是怎样的?
SQLSERVER新建表的时候页面分配情况是怎样的? 再次感谢sqlskill网站和转载sqlskill网站文章并翻译的人,因为您们的转载和翻译让小弟又学习到新的东西o(∩_∩)o 文章中用到的工具: ...
- 微信商城系统与手机APP的优势对比!
随着移动互联网的大势到来,手机移动应用已经成为未来的主流市场,很多企业也在投入精力和财力进行研发自己的手机APP,以便更好的迎合市场的需求. 然而当微信公众平台开放以后,新的机会出现了! 很多企业已经 ...
- 【高德地图API】如何设置Icon的imageSize?
在地图开发中,我们需要把标注换成各种各样的图片,以突显个性. 在高分辨率的手机下,图片尺寸需要压缩至一半,以保持图片清晰.让我们来看一看,应该如何实现. 有开发者为了改变图片的尺寸,直接写成了 ...
- C#--GDI+的LinearGradientBrush类
命名空间:System.Drawing.Drawing2D LinearGradientBrush对象用颜色线性渐变填充图形.简言之,颜色渐变包含一种在两种指定的颜色之间渐变的颜色,渐变的方向是沿着指 ...
- WPF应用程序最小化到系统托盘
using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows; u ...
- 【linux】修改文件所属用户和组
使用chown命令可以修改文件或目录所属的用户: 命令:chown 用户 目录或文件名 例如:chown qq /home/qq (把home目录下的qq目录的拥有者改为qq用户) 使用chgrp命 ...
- 在Windows 2008/2008 R2 上配置IIS 7.0/7.5 故障转移集群
本文主要是从:http://support.microsoft.com/kb/970759/zh-cn,直接转载,稍作修改裁剪而来,其中红色粗体部分,是我特别要说明的 若要配置 IIS 7.0 和 7 ...
- 无须任何软件配置iis+ftp服务器图文说明
1.1 检查是否安装已安装IIS6组件 在windows service 2003 操作系统中,windows组件“IIS6.0”是用户搭建站点以及ftp文件共享的服务器. 具体检查步骤如下: 进入“ ...
- oracle小数点前零丢失的问题
1.问题起源 oracle 数据库 字段值为小于1的小数时,使用char类型处理,会丢失小数点前面的0 例如0.2就变成了.2 2.解决办法: (1)用to_char函数 ...
- iis,w3wp一直出现WerFault.exe应用程序错误
这个进程是Windows错误报告技术里的一个东西,来收集软件崩溃或者挂起后的数据然后向微软反馈报告.关闭系统的错误报告功能后看看 1:打开 运行 (热键:win+R)输入 gpedit.msc 打开 ...