Zookeeper

Материал из Home Wiki
Перейти к навигации Перейти к поиску

Категория:Работа

Настройка

  1. Разворачиваем zookeper в /opt
  2. Создаем /var/zookeeper
  3. Создаем /opt/zookeeper<Version>/conf/zoo.cfg из zoo_sample.cfg.
    Добавляем в него server.X и ID, меяем dataDir на /var/zookeeper
  4. В log4j.properties меняем zookeeper.log.dir=/var/log и zookeeper.tracelog.dir=/var/log (пока не понял как применить log4j)
  5. создаем файл /var/zookeeper/myid с номером X
  6. в файле zkEnv.sh правим переменную ZOO_LOG_DIR="/var/log" чтобы логи писались в /var/log, а не в директории запуска zkServer.sh
  7. запускаем /opt/zookeeper<Version>/bin/zkServer.sh start

zoo.cfg

Пример настройки с 3 серверами

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/var/zookeeper
# the port at which the clients will connect
###
### clientPort изменен для теста
### Порт по умолчанию 2181
###
clientPort=2183
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=1
###
### Добавлено для создания кластера
### server.1 - тут 1 это номер в файле myid
###  ip должен соответствовать тому серверу на котором запускается
###  т.к. делается listen server.1.ip (тут это 192.168.1.8) на протах 2889 и 3889
server.1=192.168.1.8:2889:3889
server.2=192.168.1.7:2889:3889
server.3=192.168.1.6:2889:3889

Сервис в CentOS

Добавляем в zkServer.sh

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: Zookeeper

и добавить после ZOOBINDIR="$(cd "${ZOOBIN}"; pwd)"

# UPDATE PATHS - это можно сделать в zkEnv.sh
ZOOBIN=/opt/zookeeper-3.4.12/bin
ZOOBINDIR=/opt/zookeeper-3.4.12/bin


cd /etc/init.d
ln -s /opt/zookeeper-3.4.12/bin/zkServer.sh  /etc/init.d/zookeeper  
chkconfig --add zookeeper
service zookeeper start