Best way to start Zookeeper automatically on Ubuntu Server 14.04?

user2916547 picture user2916547 · Mar 12, 2015 · Viewed 20.7k times · Source

I have installed Zookeeper using sudo apt-get install zookeeper on an Ubuntu server 14.04. I am having trouble understanding how to configure Zookeeper to start automatically, on boot. Also, I can manually start it successfully only with root priviledges.

I have looked at the documentation from the official page and it seems the solution is to make sure the zkServer.sh or something similar is run at start-up. I have been searching on how to execute scripts on start-up on Ubuntu, and found a few approaches: using Upstart, using System V, Cron jobs and even found a Python utility a kind soul shared for watching processes and restarting them when they crash. Given I am a beginner in Linux programming and spent way too much time working on Windows (where this kind of situation it's pretty straight forward to solve!), all seem a bit complicated and not sure which one is the best?

Any help will be much appreciated. Thank you.

Answer

Tombart picture Tombart · Mar 30, 2015

There's a separate package providing ZooKeeper init scripts:

apt-get install zookeeperd

Which will automatically start ZooKeeper. You can manage it with:

service zookeeper # {start|stop|status|restart|force-reload}