Ad Widget

Collapse

RHEL7 systemd Unit File Not Working (zabbix-server.service)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonchines
    Junior Member
    • Nov 2016
    • 2

    #1

    RHEL7 systemd Unit File Not Working (zabbix-server.service)

    All,

    I have recently transitioned my customer from a Zabbix appliance to a more enterprise-normal server setup. I am new to RHEL7 (but not Linux or Zabbix, in general) and am having some troubles getting the systemd unit file for Zabbix to work (at least, work as expected).

    OS: RHEL 7.2
    DB: Oracle 11g2
    Zabbix: 3.2.1

    Code:
    ./configure --prefix=/opt/zabbix --enable-server --enable-agent --enable-java --enable-ipv6 --with-oracle=yes --with-net-snmp --with-libcurl --with-libxml2 --with-ssh2 --with-iconv
    As it stands, now, if I start zabbix_server from directly from the command line, the server starts up and everything is fine. We are collecting ~151 points/second across ~85 hosts (give or take) at the moment. My issue seems only with the systemd service file. I could set this up as scripts in /etc/init.d (old way) but would like to try to use the new tool (systemd). I have written a systemd unit file and deployed it as well as I know how. When I try to run it, though, zabbix_server does not start. I'm hoping someone here can point me in the right direction.

    Process:
    Code:
    vi zabbix-server.service
    cp zabbix-server.service /etc/systemd/system
    cd /etc/systemd/system
    systemctl enable zabbix-server.service [Seemingly successful]
    systemctl daemon-reload [Not needed but done for posterity]
    systemctl start zabbix-server [Seemingly successful]
    systemctl status zabbix-server [Output below]
    ps -ef | grep zabbix_server [Nothing listed]
    Unit File (I have tried Type=forking and Type=oneshot):
    Code:
    [Unit]
    Description=Zabbix Server
    After=syslog.target network.target
    
    [Service]
    Type=forking
    ExecStart=/opt/zabbix/sbin/zabbix_server
    ExecReload=/opt/zabbix/sbin/zabbix_server -R config_cache_reload
    RemainAfterExit=yes
    PIDFile=/tmp/zabbix_server.pid
    
    [Install]
    WantedBy=multi-user.target
    Status output:
    Code:
    ● zabbix-server.service - Zabbix Server
       Loaded: loaded (/etc/systemd/system/zabbix-server.service; enabled; vendor preset: disabled)
       Active: active (exited) since Mon 2016-11-14 11:30:52 EST; 24s ago
     Main PID: 75122 (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/zabbix-server.service
    
    Nov 14 11:30:52 HRAOAP15XHDC02 systemd[1]: Starting Zabbix Server...
    Nov 14 11:30:52 HRAOAP15XHDC02 systemd[1]: Started Zabbix Server.
    Again, note, if I issue /opt/zabbix/sbin/zabbix_server from the command line, all is well and the server service starts up with all pollers, etc.

    Does anyone have a working set of RHEL/CentOS7 unit files (zabbix-server, zabbix-java, and zabbix-agentd)? I have created all three but not had much luck in getting them to work.

    Thanks, Jon
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    Please check the log file of the Zabbix server.
    Some problems when using Oracle is due to insufficient environment variable setting.

    Comment

    • jonchines
      Junior Member
      • Nov 2016
      • 2

      #3
      Missing Environment Setting

      Atsushi,

      Thank you. While this is my first foray into unit file creation and I didn't even know that the "Service/Environment" directive existed, I feel a bit foolish for not having caught this in the logs. In several instances, the systemctl start returned errorcode 0 so I didn't look in the logs (silly me) but this morning I re-added the service (in hopes of getting meaningful log data) and got an errorcode 1 with, as you predicted, a note that the DB could not be connected.

      For any others that may have this problem in the future, here is the working unit file:
      Code:
      [Unit]
      Description=Zabbix Server
      After=syslog.target network.target
      
      [Service]
      Environment=ORACLE_BASE=/path/to/oracle_base
      Environment=ORACLE_HOME=/path/to/oracle_home
      Type=oneshot
      ExecStart=/path/to/zabbix_server
      ExecReload=/path/to/zabbix_server -R config_cache_reload
      RemainAfterExit=yes
      PIDFile=/path/to/zabbix_server.pid
      
      [Install]
      WantedBy=multi-user.target
      Thanks, Jon

      Comment


      • ejordanp
        ejordanp commented
        Editing a comment
        Great, i passed much days for search by this solution, thanks by your contribution. Problem resolved.
    Working...