设为首页 收藏本站
查看: 1522|回复: 0

[经验分享] IP Failover Setup using Keepalived on CentOS/Redhat 6

[复制链接]

尚未签到

发表于 2015-9-4 08:24:03 | 显示全部楼层 |阅读模式
  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 this tutorial 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:
DSC0000.png

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...

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-109205-1-1.html 上篇帖子: 虚拟机 搭建LVS + NAT + keepalived 高可用负载均衡 下篇帖子: install keepalived on RedHat/CentOS to provide IP failover for web cluster
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表