9 以 root 身份运行 agent

自Zabbix 5.0.0版本起,official packages中Zabbix agent的systemd服务文件已明确包含UserGroup指令。 两者均被设置为zabbix

由于agent会绕过此配置并按照systemd服务文件中指定的用户运行,因此不再能通过zabbix_agentd.conf文件配置Zabbix agent的运行用户。 如需以root身份运行Zabbix agent,需按以下说明进行修改。

Zabbix agent

要覆盖Zabbix agent的默认用户和组,请运行:

systemctl edit zabbix-agent

然后添加以下内容:

[Service]
       User=root
       Group=root

重新加载守护进程并重启zabbix-agent服务:

systemctl daemon-reload
       systemctl restart zabbix-agent

对于Zabbix agent,这将重新启用通过zabbix_agentd.conf文件配置用户的功能。 现在您需要在agent的configuration file中设置User=rootAllowRoot=1配置参数。

Zabbix agent 2

要覆盖Zabbix agent 2的默认用户和组,请运行:

systemctl edit zabbix-agent2

然后添加以下内容:

[Service]
       User=root
       Group=root

重新加载守护进程并重启zabbix-agent2服务:

systemctl daemon-reload
       systemctl restart zabbix-agent2

对于Zabbix agent2,这将完全确定其运行用户。 无需进行其他修改。