这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

8 使用root权限运行agent

5.0.0 版本开始 官方软件包 中Zabbix agent的systemd服务文件已更新为明确包含 User and Group 的指令. 两者均设置为 zabbix

这意味着通过 zabbix_agentd.conf 配置文件中指定用户运行Zabbix Agent的功能会被绕过,Zabbix agent将使用systemd服务文件中指定的用户运行服务。

若要修改Zabbix Agent服务运行的用户,请创建新的文件/etc/systemd/system/zabbix-agent.service.d/override.conf 并包含以下内容:

[Service]
       User=root
       Group=root

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

systemctl daemon-reload
       systemctl restart zabbix-agent

对于Zabbix agent2,这完全取决于它运行的用户角色。

对于旧 agent ,指定服务运行的用户功能需要在 zabbix_agentd.conf 文件中进行配置。因此要以root用户身份运行zabbix agent,您仍需编辑配置文件并指定 User=rootAllowRoot=1 选项。

Zabbix agent

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

systemctl edit zabbix-agent

Then, add the following content:

[Service]
       User=root
       Group=root

Reload daemons and restart the zabbix-agent service:

systemctl daemon-reload
       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:

systemctl edit zabbix-agent2

Then, add the following content:

[Service]
       User=root
       Group=root

Reload daemons and restart the zabbix-agent service:

systemctl daemon-reload
       systemctl restart zabbix-agent2

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