Skip to content

Instantly share code, notes, and snippets.

@martinhynar
Created June 2, 2017 10:56
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save martinhynar/286dee76f4a5f3881f0ebcf711fea52f to your computer and use it in GitHub Desktop.
Save martinhynar/286dee76f4a5f3881f0ebcf711fea52f to your computer and use it in GitHub Desktop.
ZooKeeper SystemD Service Unit File
[Unit]
Description=ZooKeeper Service
Documentation=http://zookeeper.apache.org
Requires=network.target
After=network.target
[Service]
Type=forking
User=zookeeper
Group=zookeeper
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zookeeper.conf
ExecStop=/opt/zookeeper/bin/zkServer.sh stop /opt/zookeeper/conf/zookeeper.conf
ExecReload=/opt/zookeeper/bin/zkServer.sh restart /opt/zookeeper/conf/zookeeper.conf
WorkingDirectory=/var/lib/zookeeper
[Install]
WantedBy=default.target
@h4m24
Copy link

h4m24 commented Nov 8, 2018

this is just reusing the shell script

@BrickXu
Copy link

BrickXu commented May 5, 2019

ExecStart=/opt/zookeeper/bin/zkServer.sh start-foreground /opt/zookeeper/conf/zookeeper.conf

@nsoft
Copy link

nsoft commented May 8, 2019

ExecStart=/opt/zookeeper/bin/zkServer.sh start-foreground /opt/zookeeper/conf/zookeeper.conf

How does that help, and does it play nice with restart?

@tldzyx
Copy link

tldzyx commented Apr 13, 2020

Usage: /usr/zookeeper/default/bin/zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|restart|status|print-cmd}

ExecStart=/opt/zookeeper/bin/zkServer.sh --config /etc/opt/zookeeper start-foreground
ExecStop=/opt/zookeeper/bin/zkServer.sh --config /etc/opt/zookeeper stop
ExecReload=/opt/zookeeper/bin/zkServer.sh --config /etc/opt/zookeeper restart
WorkingDirectory=/var/lib/zookeeper

@Folcky
Copy link

Folcky commented May 8, 2020

Is it a good idea to add ROLLINGFILE log level here?
log4j.properies is ignored always https://issues.apache.org/jira/browse/ZOOKEEPER-2170

@Nurlan199206
Copy link

mine working config file

[Unit]
Description=Zookeeper Daemon
Documentation=http://zookeeper.apache.org
Requires=network.target
After=network.target

[Service]    
Type=forking
WorkingDirectory=/opt/zookeeper
User=root
Group=root
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop /opt/zookeeper/conf/zoo.cfg
ExecReload=/opt/zookeeper/bin/zkServer.sh restart /opt/zookeeper/conf/zoo.cfg
TimeoutSec=30
Restart=on-failure

[Install]
WantedBy=default.target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment