欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

解决Keepalived脚本启动时warning、Unsafe

程序员文章站 2022-05-02 10:39:24
...

WARNING - script '/etc/keepalived/XXXXXX' is not executable for uid:gid 0:0 - disabling.

Unsafe permissions found for script '/etc/keepalived/XXXXXXX'

WARNING - default user 'keepalived_script' for script execution does not exist - please create.

背景

在使用keepalived的时候,我们可能会作息配置,配置一些脚本,例如检测服务的脚本,例如当keepalived成为主节点的时候。如下脚本就是当keepalived成为主节点的时候,执行的脚本。

notify_master "/etc/keepalived/bin/recover.sh"

 但是这个脚本的权限却被keepalived检测出来是不安全的,或者被检测出来是不可执行的,或者会有其他的一些警告。让我们一一解决。

解决Keepalived脚本启动时warning、Unsafe

WARNING - script '/etc/keepalived/bin/check.sh' is not executable for uid:gid 0:0 - disabling.
 

首先我们先去查看脚本的权限,如下图所示,脚本在没有执行权限,需要赋予执行权限。

解决Keepalived脚本启动时warning、Unsafe

chmod 744 /etc/keepalived/bin/check.sh

 解决Keepalived脚本启动时warning、Unsafe

Unsafe permissions found for script '/etc/keepalived/bin/recover.sh'.

查看脚本权限,发现权限是777,这样不行,改成744.

解决Keepalived脚本启动时warning、Unsafe

chmod 744 /etc/keepalived/bin/recover.sh

 解决Keepalived脚本启动时warning、Unsafe

WARNING - default user 'keepalived_script' for script execution does not exist - please create.

 这个错误的原因在于配置文件的错误,在global_defs中加入如下两行即可。

   script_user root
   enable_script_security

打开配置文件。

vi /etc/keepalived/keepalived.conf

找到相应位置添加即可。 

解决Keepalived脚本启动时warning、Unsafe

重启服务,测试结果

systemctl stop keepalived
systemctl start keepalived

解决Keepalived脚本启动时warning、Unsafe

 查看日志

解决Keepalived脚本启动时warning、Unsafe