Zookeeper on OpenSuSE


In the marathon tutorial, I gave a five second install for setting up zookeeper and that works for basic testing, but let’s go a little more in depth and set up a service.

This isn’t going to be too long of a post, but it’ll clean some things up. A lot of the stuff is the same so let’s just get right to it. A Copy and Paste solution is below.

Much like before, we’re going to download the tarball:


wget http://apache.cs.utah.edu/zookeeper/stable/zookeeper-3.4.10.tar.gz

This time, we’re going to extract it into /opt/:


tar -xf zookeeper* -C /opt
ln -sv /opt/zookeeper-3.4.10 /opt/zookeeper #Keep everything clean

With that done, we’ll modify out default config file to use a “proper” directory:


cd /opt/zookeeper/conf
sed 's|dataDir=.*|dataDir=/var/zookeeper|' < zoo_sample.cfg > zoo.cfg
mkdir -p /var/zookeeper

In the above, we just say store everything in /var/zookeeper. If you don’t know sed or don’t feel comfortable, then just make the changes using your favorite editor.

Now, we’ll create the user:

useradd -s /bin/false -U zookeeper
chown -R zookeeper: /opt/zookeeper* /var/zookeeper

For safety and security, we’re going to make sure that zookeeper can’t login and is limited to its own group.

Finally! Time to write the startup script. I’ll be targeting systemd. If you’re using SysV init, then just add something in /etc/rc.local to start it up.

File: /etc/systemd/system/zookeeper.service

[Unit]
Description=Apache ZooKeeper is an effort to develop and maintain an open-source server which enables highly reliable distributed coordination.

[Service]
User=zookeeper
WorkingDirectory=/opt/zookeeper/
ExecStart=/opt/zookeeper/bin/zkServer.sh start
ExecStop=/opt/zookeeper/bin/zkServer.sh stop

[Install]
WantedBy=multi-user.target

When that is done, tell it to go on boot and enable it:


systemctl enable zookeeper
systemctl start zookeeper

Here is the copy and paste. As root:


wget http://apache.cs.utah.edu/zookeeper/stable/zookeeper-3.4.10.tar.gz
tar -xf zookeeper-3.4.10.tar.gz -C /opt
ln -sv /opt/zookeeper-3.4.10 /opt/zookeeper
cd /opt/zookeeper/conf
sed 's|dataDir=.*|dataDir=/var/zookeeper|' < zoo_sample.cfg > zoo.cfg
mkdir -p /var/zookeeper
useradd -s /bin/false -U zookeeper
chown -R zookeeper: /opt/zookeeper* /var/zookeeper
cat > /etc/systemd/system/zookeeper.service <<EOF
[Unit]
Description=Apache ZooKeeper is an effort to develop and maintain an open-source server which enables highly reliable distributed coordination.

[Service]
User=zookeeper
WorkingDirectory=/opt/zookeeper/
ExecStart=/opt/zookeeper/bin/zkServer.sh start
ExecStop=/opt/zookeeper/bin/zkServer.sh stop

[Install]
WantedBy=multi-user.target
EOF
systemctl enable zookeeper
systemctl start zookeeper

This entry was posted in Computer Science and tagged , , , . Bookmark the permalink.

Notice: compact(): Undefined variable: limits in /srv/www/vhosts/blog.ceneblock.com/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /srv/www/vhosts/blog.ceneblock.com/wp-includes/class-wp-comment-query.php on line 853

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.