[ZBX-18243] zabbix-agent2.service fails to start on Centos 7 Created: 2020 Aug 12 Updated: 2024 Apr 10 Resolved: 2020 Sep 13 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Packages (C) |
Affects Version/s: | 5.0.2 |
Fix Version/s: | 5.0.4rc1, 5.2.0alpha3, 5.2 (plan) |
Type: | Problem report | Priority: | Trivial |
Reporter: | tni | Assignee: | Jurijs Klopovskis |
Resolution: | Fixed | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Centos 7 |
Team: | |
Sprint: | Sprint 67 (Aug 2020), Sprint 68 (Sep 2020) |
Story Points: | 0.125 |
Description |
Steps to reproduce:
Result: zabbix_agent2: 2020/08/12 11:24:25.287696 cannot initialize logger: open /var/log/zabbix/zabbix_agent2.log: permission denied
zabbix_agent2 fails to start because the zabbix user does not have access right to the log file Expected: with the correct access permission/ownership workaround: fix the ownership manually: chown zabbix /var/log/zabbix/zabbix_agent2.log |
Comments |
Comment by tni [ 2020 Aug 13 ] |
I found out that this happens because the log file /var/log/zabbix/zabbix_agent2.log is not created by the rpm package at all. When the zabbix_agent2 is run manually before the service was started the log file gets created with the owner rights of the user running zabbix_agent2. |
Comment by Jurijs Klopovskis [ 2020 Aug 14 ] |
Tested on clean CentOS 7 machine. Works fine out the box. cat /var/log/messages | grep agent Aug 14 09:15:24 centos7 yum[1126]: Installed: zabbix-agent2-5.0.2-1.el7.x86_64 Aug 14 09:15:57 centos7 zabbix_agent2: Starting Zabbix Agent 2 [Zabbix server]. (5.0.2) Aug 14 09:15:57 centos7 zabbix_agent2: Press Ctrl+C to exit. The package creates /var/log/zabbix/ directory with 755 permissions owned by user zabbix that agent runs as. The agent then creates the log file there. [root@centos7 ~]# ls -lah /var/log/zabbix/ total 12K drwxr-xr-x. 2 zabbix zabbix 4.0K Aug 14 09:15 . drwxr-xr-x. 7 root root 4.0K Aug 14 09:15 .. -rw-r--r--. 1 zabbix zabbix 2.7K Aug 14 09:15 zabbix_agent2.log What are your permissions on /var/log/zabbix/ ? |
Comment by tni [ 2020 Aug 14 ] |
As I said in my previous comment this happens when the agent is run manually, for example to test the configuration by user root, before the service was started the first time. Then the zabbix_agent2.log gets created with owner root:root and the service later can not access it, resulting in the error. Also in my case the Zabbix Agent 2 service was not started by the package installer. My log file of the installation:
[root@igms07 ~]# cat /var/log/messages | grep agent
Aug 12 09:26:51 igms07 yum[22461]: Installed: zabbix-agent2-5.0.2-1.el7.x86_64
I had to enable and start the service manually: systemctl enable zabbix-agent2.service systemctl start zabbix-agent2.service
My permissions on /var/log/zabbix/ look like this
ls -lah /var/log/zabbix/
total 28K
drwxr-xr-x. 2 zabbix zabbix 31 Aug 12 10:14 .
drwxr-xr-x. 14 root root 4.0K Aug 14 08:56 ..
-rw-r--r--. 1 zabbix root 20K Aug 14 08:57 zabbix_agent2.log
I adjusted the owner to zabbix manually
|
Comment by Jurijs Klopovskis [ 2020 Aug 14 ] |
OK. I see your point. Adding zabbix_agent2.log file to the package is an improvement.
It shouldn't have. CentOS is not Debian |
Comment by tni [ 2020 Aug 14 ] |
Thank you very much for your quick response to this minor issue! |
Comment by Jurijs Klopovskis [ 2020 Aug 28 ] |
Fixed in pre 5.0.4 & 5.2.0alpha2 |