On this page
13 其他问题
登录和 systemd
我们建议创建一个 zabbix 用户作为系统用户,也就是不能用于登录的用户。有些用户忽略了这一建议,仍然使用同一个账户登录到运行 Zabbix 的主机(例如通过 SSH)。这可能会在注销时导致 Zabbix 守护进程崩溃。在这种情况下,您会在 Zabbix 服务器日志中看到类似如下内容:
zabbix_server [27730]: [file:'selfmon.c',line:375] lock failed: [22] Invalid argument
zabbix_server [27716]: [file:'dbconfig.c',line:5266] lock failed: [22] Invalid argument
zabbix_server [27706]: [file:'log.c',line:238] lock failed: [22] Invalid argument
以及在 Zabbix agent 日志中看到:
zabbix_agentd [27796]: [file:'log.c',line:238] lock failed: [22] Invalid argument
这是因为 /etc/systemd/logind.conf 中配置了 systemd 的默认设置 RemoveIPC=yes。当您从系统注销时,之前由 Zabbix 创建的信号量会被移除,从而导致崩溃。
systemd 文档中的一段说明如下:
RemoveIPC=
Controls whether System V and POSIX IPC objects belonging to the user shall be removed when the
user fully logs out. Takes a boolean argument. If enabled, the user may not consume IPC resources
after the last of the user's sessions terminated. This covers System V semaphores, shared memory
and message queues, as well as POSIX shared memory and message queues. Note that IPC objects of the
root user and other system users are excluded from the effect of this setting. Defaults to "yes".
解决此问题有 2 种方法:
- (推荐)不要再使用 zabbix 账户执行除 Zabbix 进程之外的任何操作,为其他用途创建一个专用账户。
- (不推荐)在
/etc/systemd/logind.conf中设置RemoveIPC=no,然后重启系统。请注意,RemoveIPC是一个系统级参数,修改它会影响整个系统。
Zabbix 前端使用代理
如果 Zabbix 前端在代理服务器后面运行,则需要重写代理配置文件中的 cookie 路径以匹配反向代理路径。请参阅下面的示例。如果不重写 cookie 路径,用户在尝试登录 Zabbix 前端时可能会遇到授权问题。
nginx 的示例配置
# ..
location / {
# ..
proxy_cookie_path /zabbix /;
proxy_pass http://192.168.0.94/zabbix/;
# ..
Apache 的示例配置
# ..
ProxyPass "/" http://host/zabbix/
ProxyPassReverse "/" http://host/zabbix/
ProxyPassReverseCookiePath /zabbix /
ProxyPassReverseCookieDomain host zabbix.example.com
# ..