首页 > 代码库 > keepalive配置
keepalive配置
eepalived配置及典型应用案例
使用源码先安装keepalived 1.2.6
cd /usr/local/src
wget http://www.keepalived.org/software/keepalived-1.2.6.tar.gz
tar zxf keepalived-1.2.6.tar.gz
cd keepalived-1.2.6
./configure --prefix=/usr/local/keepalived
make
make install
所设keepalived安装到/usr/local/keepalived, 则所有配置文件均位于此目录之下。 我一直没搞明白一个问题,Linux默认总是将程序安装到/usr/local目录下,所有程序共享了/usr/local/sbin目录。这对一些人的操作习惯是有影响的。为何不考虑使用每个软件一个独立的目录呢?
1. 建立服务启动脚本,以便使用service命令控制之
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/keepalived
chmod +x /etc/init.d/keepalived
因为我们使用非默认路径(/usr/local)安装keepalived, 故需要修改几处路径,以保证keepalived能正常启动, 需要修改的文件如下:
2. 修改/etc/init.d/keepalived, 寻找大约15行左右的. /etc/sysconfig/keepalived, 修改为:
. /usr/local/keepalived/etc/sysconfig/keepalived, 即指向正确的文件位置
同时在上述行下添加以下内容(将keepavlied主程序所在路径导入到环境变量PATH中):
PATH="$PATH:/usr/local/keepalived/sbin"
export PATH
3. 修改/usr/local/keepalived/etc/sysconfig/keepalived文件,设置正确的服务启动参数
KEEPALIVED_OPTIONS="-D -f /usr/local/keepalived/etc/keepalived/keepalived.conf"
4. 经过以上修改,keepalived基本安装即可完成,启动测试之:
service keepalived restart
5. 切勿忘记将此服务设置为开机启动
chkconfig keepalived on
默认的配置文件中,指定了两个数个虚拟IP : 192.168.200.16 192.168.200.17 192.168.200.18
本文出自 “小屁孩儿” 博客,请务必保留此出处http://865516915.blog.51cto.com/9037379/1873552
keepalive配置