首页 > 代码库 > keepalived编译安装
keepalived编译安装
编译安装keepalived
使用源码先安装keepalived 1.2.6
cd/usr/local/src
wget http://www.keepalived.org/software/keepalived-1.2.6.tar.gz
tarzxf keepalived-1.2.6.tar.gz
cdkeepalived-1.2.6
./configure--prefix=/usr/local/keepalived
make
makeinstall
所设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"
exportPATH
3. 修改/usr/local/keepalived/etc/sysconfig/keepalived文件,设置正确的服务启动参数
KEEPALIVED_OPTIONS="-D -f/usr/local/keepalived/etc/keepalived/keepalived.conf"
4. 经过以上修改,keepalived基本安装即可完成,启动测试之:
service keepalived restart
5. 切勿忘记将此服务设置为开机启动
chkconfigkeepalived on
本文出自 “11736718” 博客,请务必保留此出处http://11746718.blog.51cto.com/11736718/1876213
keepalived编译安装