博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IP Failover Setup using Keepalived on CentOS/Redhat 6
阅读量:5857 次
发布时间:2019-06-19

本文共 3994 字,大约阅读时间需要 13 分钟。

source url:

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

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 eth1state MASTERvirtual_router_id 10priority 101   # 101 on master, 100 on backupvirtual_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 eth1state BACKUPvirtual_router_id 10priority 100   # 101 on master, 100 on backupvirtual_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: 
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 STATEMar 19 17:30:25 localhost Keepalived_vrrp[6958]: VRRP_Instance(VI_1) Entering MASTER STATEMar 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 addedMar 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.

转载地址:http://rgojx.baihongyu.com/

你可能感兴趣的文章
FastD 最佳实践一: 构建 API
查看>>
Mycat安装以及使用测试
查看>>
JS里验证信息
查看>>
Microsoft Quantum Katas帮助开发人员探索使用Q#实现量子计算
查看>>
Akka actor tell, ask 函数的实现
查看>>
windows10 chrome 调试 ios safari 方法
查看>>
Hello , Ruby!
查看>>
Netty 4.1.35.Final 发布,经典开源 Java 网络服务框架
查看>>
详解Microsoft.AspNetCore.CookiePolicy
查看>>
go与c互相调用
查看>>
如何优雅地用Redis实现分布式锁
查看>>
从零开始Docker化你的Node.js应用
查看>>
SCDPM2012 R2实战一:基于SQL 2008 R2集群的SCDPM2012 R2的安装
查看>>
SQL SERVER中字段类型与C#数据类型的对应关系
查看>>
保存对象、关系映射
查看>>
Java堆和栈的区别
查看>>
Linux lsof命令详解
查看>>
SVG path
查看>>
js判断checkbox是否选中
查看>>
【转】TabError:inconsistent use of tabs and spaces
查看>>