标签:keepalived
一、keepalived的基本原理介绍
keepalived最初设计的目的是为了实现lvs前端director的高可用,非常轻量级。主要的实现的vrrp协议。
VRRP是一种容错协议,它保证当主机的下一跳路由器出现故障时,由另一台路由器来代替出现故障的路由器进行工作,从而保持网络通信的连续性和可靠性。
VRRP具有如下优点:
-
简化网络管理:在具有多播或广播能力的局域网(如以太网)中,借助VRRP 能在某台设备出现故障时仍然提供高可靠的缺省链路,有效避免单一链路发生故障后网络中断的问题,而无需修改动态路由协议、路由发现协议等配置信息,也无需修改主机的默认网关配置。
-
适应性强:VRRP 报文封装在 IP 报文中,支持各种上层协议。
-
网络开销小:VRRP 只定义了一种报文——VRRP 通告报文,并且只有处于Master 状态的路由器可以发送 VRRP 报文。
LAMP平台实现搭建好了。。如有需要请参考上一篇文章。yum搭建的很快捷、、主要想演示keepalived。
主server 192.168.1.111 eth0
备server 192.168.1.10 eth0
vip 192。168.1.222
yum -y install gcc*
yum install -y openssl openssl-devel poptpopt-devel libnl libnl-devel kernel-devel
mkdir /usr/local/keepalived
yum install popt-devel -y
mv Desktop/keepalived-1.2.2.tar.gz /home/
cd /home/
tar -zxvf keepalived-1.2.2.tar.gz
cd keepalived-1.2.2
./configure --prefix=/usr/local/keepalived
make && make install
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
chkconfig --add keepalived
chkconfig keepalived on
vim /etc/keepalived/keepalived.conf --编辑主机的配置文件
service keepalived restart
用ip a 进行查看。
备机安装keepalived的方式与主机一样,不做解释。。
备机的配置文件也要进行修改:
ip addr show dev eth0
查看关联的ip
好我们测试:
下面我们模拟主机宕机一下。
service keepalived stop
然后在备机上查看关联ip
在浏览器上查看
完事。主备机的实验就完成,,很简单。。还有主主的服务负载均衡,改天再给大家演示。
keepalived 主备服务负载均衡、基于LAMP平台
标签:keepalived
原文地址:http://blog.csdn.net/androidmylove/article/details/41645157