测试keepalived是否配置并启动成功,可以通过如下命令来查看keepalived的进程
ps -ef | grep keepalived
到此keepalived就安装配置成功了。
如何停止keepalived?
可以通过查出keepalived的进程号,然后kill掉这个进程
ps -ef|grep keepalived
kill 9 7234
但是不建议那样做,可以把keepalived的服务注册到系统里,那该如何进行配置呢?
首先,进入到keepalived的解压目录之下,然后在进入keepalived目录之下,再进入到etc目
录之下,如下所示:
然后拷贝如下两个文件到系统服务下,如下操作:
然后刷新系统服务,使用如下命令:
systemctl daemon-reload
接着,使用如下命令进行启动keepalived:
systemctl start keepalived.service
重启keepalived服务:
systemctl restart keepalived.service
停止keepalived服务:
systemctl stopkeepalived.service
如果机器重启之后keepalived没有启动的话,可以安装如下设置Keepalived开机自启动
chkconfig --add keepalived
chkconfig keepalived on
注意:
添加时,必须保证/etc/init.d/keepalived存在
查看系统服务
chkconfig list