1. Download and extract Zookeeper packages.
$cd /opt
# wget http://www.eu.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
# tar zxvf zookeeper-3.4.9.tar.gz
# cp zookeeper-3.4.9/conf/zoo_sample.cfg zookeeper-3.4.9/conf/zoo.cfg
2. Create a data directory.
# mkdir /var/zookeeper
3. Edit thedataDirproperty in the zookeeper configuration file.
# vim /opt/zookeeper-3.4.9/conf/zoo.cfg
...
dataDir=/var/zookeeper
...
4. config supervisor
# vim /etc/suppervisor/conf.d/zookeeper.conf
[program:zookeeper]
command=/opt/zookeeper-3.4.9/bin/zkServer.sh start-foreground
autostart=true
autorestart=true
startsecs=1
startretries=999
redirect_stderr=false
stdout_logfile=/var/log/zookeeper-out
stdout_logfile_maxbytes=10MBs
tdout_logfile_backups=10
stdout_events_enabled=true
stderr_logfile=/var/log/zookeeper-err
stderr_logfile_maxbytes=100MB
stderr_logfile_backups=10
stderr_events_enabled=true
5. Start Zookeeper.
# service supervisors start
Starting supervisord:[OK]
6. Check Zookeeper status.
$sudo supervisorctlzookeeper
RUNNING pid 24765, uptime 0:00:06
7. Check if Zookeeper service is running.
$netstat -ntlp | grep 2181
tcp 0 0 :::2181 :::*LISTEN 2132/java