25

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.

Tombart
  • 30,520
  • 16
  • 123
  • 136
user2916547
  • 1,963
  • 5
  • 17
  • 21

1 Answers1

56

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}
A T
  • 13,008
  • 21
  • 97
  • 158
Tombart
  • 30,520
  • 16
  • 123
  • 136
  • Looking for the same thing, but I would need to start 2 zookeeper instances on one server. How could I alter the script to start a second zookeeper on the same machine? – merlin Aug 19 '15 at 22:56
  • 1
    @merlin I wouldn't recommend starting 2 ZooKeepers on the same machine, if you plan it using for production. ZooKeeper might require dedicated disk if it should be real-time and reliable. If you want it just for testing, using containers (e.g. LXC) might be easy way how to do this. – Tombart Aug 20 '15 at 13:11
  • 1
    Actually I need to take it to production where solr will serve about 50M requests per month. I was planing to install on 2 dedicated bare metall machines with 128GB RAM each. It would be sufficiant to serve read requests if one node goes down. – merlin Aug 20 '15 at 13:27
  • 1
    Btw. you should deploy 2n+1 instances of ZooKeepers in order to have high-availability. You don't need much memory for running ZooKeepers. – Tombart Aug 20 '15 at 16:02
  • Is there a way to run the zookeeper CLI if I install zookeeperd through apt-get? – rhlsthrm Mar 07 '17 at 18:33
  • 4
    @rhlsthrm Sure, it's most likely not on `$PATH`. Have look in `/usr/share/zookeeper/bin/` or search `find / -name zkCli.sh`. – Tombart Mar 08 '17 at 08:40