9 以 root 身份运行 agent

自Zabbix 5.0.0起,official packages中用于Zabbix agent的systemd服务file明确包含了针对UserGroup的指令。 两者均被设置为zabbix

不再能通过zabbix_agentd.conf file配置Zabbix agent的运行用户, 因为agent将绕过此配置,并按照systemd服务file中指定的用户run。 若要以root用户run Zabbix agent,需按以下说明进行修改。

Zabbix agent

要覆盖Zabbix agent的默认用户和组,run:

systemctl edit zabbix-agent

然后添加以下内容:

[Service]
       User=root
       Group=root

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

systemctl daemon-reload
       systemctl restart zabbix-agent

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

Zabbix agent 2

要覆盖Zabbix agent 2的默认用户和组,run:

systemctl edit zabbix-agent2

然后添加以下内容:

[Service]
       User=root
       Group=root

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

systemctl daemon-reload
       systemctl restart zabbix-agent2

对于Zabbix agent2,这完全决定了它运行时使用的用户。 无需额外修改。