keepalived安装配置(二)

keepalived安装完成后,配置keepalived环境变量并设置系统服务。

将keepalived写入环境变量
echo 'export PATH=/usr/local/keepalived/sbin:$PATH' >> /etc/profile
tial -l /etc/profile
source /etc/profile
echo $PATH

配置keepalived为系统服务
copy keepalived source目录keepalived-1.3.2/keepalived/etc/init.d下的启动脚本文件到/etc/init.d/,重命名为keepalived。

keepalived-1.3.2/keepalived/etc/init.d 该目录下一般有三个启动脚本:
keepalived -- 通用启动脚本
keepalived.rh.init -- redhat 系统启动脚本
keepalived.suse.init -- suse系统启动脚本
因为我的系统是Centos,所以使用keepalived.rh.init脚本。

给启动脚本赋予执行权限,并设置开机自动启动
chmod 755 /etc/init.d/keepalived
chkconfig —add keepalived
chkconfig keepalived on
chkconfig —list keepalived

以上配置都完成后,使用service命令启动keepalived。
service keepalived start
如果报一下错误:
Starting Keepalived for LVS: /bin/bash: keepalived: command not found [FAILED]
修改/etc/init.d/keepalived,
将 daemon keepalived -D 改为 指向keepalived的sbin具体位置的写法:
daemon /usr/local/keepalived/sbin/keepalived -D
保存退出。

重新执行启动命令,成功启动keepalived。



上一篇:Java NIO之选择器


下一篇:图论——最短路——Dijkstra算法