keepalived简介
keepalived是一个类似于layer3, 4 & 5交换机制的软件,也就是我们平时说的第3层、第4层和第5层交换。Keepalived的作用是检测web服务器的状态,如果有一台web服务器死机,或工作出现故障,Keepalived将检测到,并将有故障的web服务器从系统中剔除,当web服务器工作正常后Keepalived自动将web服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人工做的只是修复故障的web服务器。
keepalived下载:
下载地址:http://www.keepalived.org/download.html 可以选择需要的版本。
wget http://www.keepalived.org/software/keepalived-1.2.1.tar.gz
实验环境
两台Redhat Linux RHEL 5.5:
解压keepalived-1.2.1.tar到/usr/src
cd /usr/src/keepalived-1.2.1
./configure --prefix=/usr/local/keepalived
make
make install
不出意外,安装过程就完毕了,接下来要手动复制一些东西,设置成系统服务启动运行:
可以看到/usr/local/keepalived下面有几个文件,我们需要复制一些文件到其他文件夹里面,下面为操作方法:
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 --level 345 keepalived on
手动启动或停止服务是service keepalived start|stop|restart
接下来是配置conf文件,只有配置/etc/keepalived/keepalived.conf才生效。
本文出自 “boyhack” 博客,请务必保留此出处http://461205160.blog.51cto.com/274918/1740070
原文地址:http://461205160.blog.51cto.com/274918/1740070