使用源码先安装keepalived 1.2.6
创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、成都网站制作、苏家屯网络推广、成都小程序开发、苏家屯网络营销、苏家屯企业策划、苏家屯品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供苏家屯建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com
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