9 以 root 用户身份运行agent

从版本 5.0.0 版本开始,Zabbix agent 服务的启动文件 official packages 已更新为显示包含 UserGroup的参数. 两者都设置为 zabbix.

这将忽略旧的Zabbix agent 指定 zabbix_agentd.conf 运行的用户 ,而是将以启动文件中指定的用户运行。

要覆盖上述行为,请创建一个包含以下内容的文件 /etc/systemd/system/zabbix-agent.service.d/override.conf :

  1. [Service]
  2. User=root
  3. Group=root

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

  1. systemctl daemon-reload
  2. systemctl restart zabbix-agent

这完全决定了 Zabbix agent2 的运行用户

对于旧的agent,只会在 zabbix_agentd.conf 文件中重新启用配置用户的功能。因此,为了以 root 身份运行 zabbix agent,您仍然需要编辑 agent [配置文件](/manual/annex/config/zabbix_agentd)并指定 User=root 以及 AllowRoot=1 两个参数。

Zabbix agent

To override the default user and group for Zabbix agent, run:

  1. systemctl edit zabbix-agent

Then, add the following content:

  1. [Service]
  2. User=root
  3. Group=root

Reload daemons and restart the zabbix-agent service:

  1. systemctl daemon-reload
  2. systemctl restart zabbix-agent

For Zabbix agent this re-enables the functionality of configuring user in the zabbix_agentd.conf file. Now you need to set User=root and AllowRoot=1 configuration parameters in the agent configuration file.

Zabbix agent 2

To override the default user and group for Zabbix agent 2, run:

  1. systemctl edit zabbix-agent2

Then, add the following content:

  1. [Service]
  2. User=root
  3. Group=root

Reload daemons and restart the zabbix-agent service:

  1. systemctl daemon-reload
  2. systemctl restart zabbix-agent2

For Zabbix agent2 this completely determines the user that it runs as. No additional modifications are required.