Best way to start Zookeeper automatically on Ubuntu Server 14.04?

21,917

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}
Share:
21,917

Related videos on Youtube

user2916547
Author by

user2916547

Updated on February 15, 2020

Comments

  • user2916547
    user2916547 about 4 years

    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.

  • merlin
    merlin over 8 years
    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?
  • Tombart
    Tombart over 8 years
    @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.
  • merlin
    merlin over 8 years
    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.
  • Tombart
    Tombart over 8 years
    Btw. you should deploy 2n+1 instances of ZooKeepers in order to have high-availability. You don't need much memory for running ZooKeepers.
  • rhlsthrm
    rhlsthrm about 7 years
    Is there a way to run the zookeeper CLI if I install zookeeperd through apt-get?
  • Tombart
    Tombart about 7 years
    @rhlsthrm Sure, it's most likely not on $PATH. Have look in /usr/share/zookeeper/bin/ or search find / -name zkCli.sh.