Best way to start Zookeeper automatically on Ubuntu Server 14.04?
Asked Answered
K

1

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.

Kermie answered 12/3, 2015 at 17:56 Comment(0)
H
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}
Heaveho answered 30/3, 2015 at 10:28 Comment(6)
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?Bimanous
@Bimanous 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.Heaveho
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.Bimanous
Btw. you should deploy 2n+1 instances of ZooKeepers in order to have high-availability. You don't need much memory for running ZooKeepers.Heaveho
Is there a way to run the zookeeper CLI if I install zookeeperd through apt-get?Sike
@Sike Sure, it's most likely not on $PATH. Have look in /usr/share/zookeeper/bin/ or search find / -name zkCli.sh.Heaveho

© 2022 - 2024 — McMap. All rights reserved.