Zookeeper install on CentOS 7

Good concise article here on devopscube for installing zookeeper cluster. I’ve added some of my own bits:

Firewall

Disable firewalld or allow ports 2181 3888 2888

Install Java

yum install java-1.8.0-openjdk

User

Create a zookeeper user

groupadd zookeeper
useradd -g zookeeper -d /opt/zookeeper -s /sbin/nologin zookeeper

Install Zookeeper

Download ZooKeeper from the Apache:

wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

mv zookeeper-3.4.10.tar.gz /opt
cd /opt
tar xzf zookeeper-3.4.10.tar.gz
ln -s zookeeper-3.4.10 ./zookeeper
cd zookeeper

mkdir data

Set the permissions:

chown -R zookeeper:zookeeper /opt/zookeeper/*
vi /opt/zookeeper/conf/zoo.cfg

Add the following:

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/zookeeper/data
clientPort=2181
server.1=192.168.187.75:2888:3888
server.2=192.168.187.77:2888:3888
server.3=192.168.187.78:2888:3888

Test the service:

/opt/zookeeper/bin/zkServer.sh start

Ctrl-c out of that and lets create a systemd unit file for the service.

Systemd

vi /usr/lib/systemd/system/zookeeper.service

Add the following:

[Unit]
Description=Zookeeper Service

[Service]
Type=simple
WorkingDirectory=/opt/zookeeper/
PIDFile=/opt/zookeeper/data/zookeeper_server.pid
SyslogIdentifier=zookeeper
User=zookeeper
Group=zookeeper
ExecStart=/opt/zookeeper/bin/zkServer.sh start
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
Restart=always
TimeoutSec=20
SuccessExitStatus=130 143
Restart=on-failure

[Install]
WantedBy=multi-user.target

Next

systemctl daemon-reload
systemctl enable zookeeper.service
systemctl start zookeeper.service

Test

Running the following will give a client interface to the zookeeper service:

/opt/zookeeper/bin/zkCli.sh

There are some examples here but you can create and get info as shown below:

To check which nodes are followers and which is the leader try issuing the following commands to each node:

echo srvr | nc localhost 2181

There is excellent information on monitoring Zookeeper here (from ServerDenisty) and a Nagios check here.

Troubleshooting

  • Reset the user permissions on the /opt/zookeeper directory recursively
  • Switch off firewalld and/or check a telnet connect to port 2181 on each node
  • Try switching to the zookeeper user (su – zookeeper -s /bin/bash) and run the zkServer.sh start command

 

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>