安装及部署

一. 单机安装、配置

1、下载zookeeper二进制安装包

  • 下载

curl -L -O http://apache.fayea.com/zookeeper/stable/zookeeper-3.4.6.tar.gz
  • 解压

tar zxvf zookeeper-3.4.6.tar.gz

2、设置环境变量

ZOOKEEPER_HOME关键字为添加的配置项

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates. pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$
else
PATH=$:$PATH
fi
esac
} if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi # Path manipulation
if [ "$EUID" = "" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi HOSTNAME=`/bin/hostname >/dev/null`
HISTSIZE=
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt ] && [ "`id -gn`" = "`id -un`" ]; then
umask
else
umask
fi for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done unset i
unset pathmunge JAVA_HOME=/usr/java/jdk1.7.0_51
#zookeeper环境变量设置
ZOOKEEPER_HOME=/usr/local/logdeal/zookeeper-3.4.6
PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$ZOOKEEPER_HOME/lib:
TOMCAT_HOME=/usr/local/tomcat7
CATALINA_HOME=/usr/local/tomcat7
export ZOOKEEPER_HOME
export JAVA_HOME
export PATH
export CLASSPATH
export TOMCAT_HOME
export CATALINA_HOME
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

3、配置

配置文件存放在$ZOOKEEPER_HOME/conf/目录下,将zoo_sample.cfd文件名称改为zoo.cfg, 缺省的配置内容如下:

# The number of milliseconds of each tick
tickTime=
# The number of ticks that the initial
# synchronization phase can take
initLimit=
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
#
# 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=
# Purge task interval in hours
# Set to "" to disable auto purge feature
#autopurge.purgeInterval=
  • 配置说明:

tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。

dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。

dataLogDir: log目录, 同样可以是任意目录. 如果没有设置该参数, 将使用和dataDir相同的设置。

clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。

4、启动Zookeeper

当这些配置项配置好后,你现在就可以启动zookeeper了:

./zkServer.sh start #启动
netstat -tunlp|grep 2181 #查看zookeeper端口
./zkServer.sh stop #停止

二. 集群安装、配置

集群安装与配置暂时省略,下次在作补充。

  • 参考资料:

zookeeper入门(1)在单机上实现ZooKeeper伪机群/伪集群部署

zookeeper单机伪集群配置

Zookeeper 安装和配置

zookeeper原理(转)

最新文章

  1. 基于SAP的中国式数据分析浅谈
  2. BPMN流程图的绘制的注意要点
  3. tomcat bug之部署应用的时候经常会发上startup failed due to previous errors
  4. SQL server 学习笔记1
  5. 关于进程间通信的总结(IPC)
  6. 【转】Tomcat配置文件入门
  7. heritrix 3.2.0 -- 环境搭建
  8. kbhit()
  9. JSON对象添加删除属性
  10. Bond UVA - 11354(LCA应用题)
  11. spring cloud配置注册中心显示服务的ip地址和端口
  12. javap -v没有显示LocalVaribleTable
  13. js获取浏览器屏幕的尺寸
  14. python内置类型:列表,包括 list 和 tuple
  15. Redis 当成数据库在使用和可靠的分布式锁,Redlock 真的可行么?
  16. iOS 自动布局框架 – Masonry 详解
  17. find中的-print0和xargs中-0的奥妙
  18. python学习:数据类型检查
  19. HDU_3486_Interviewe
  20. 小白的Unity5之路(一)

热门文章

  1. 补psp进度(11月4号-9号)
  2. 读javascript高级程序设计10-DOM
  3. Octopus系列之价格计算公式
  4. 使用rpm命令卸载程序
  5. hive的Query和Insert,Group by,Aggregations(聚合)操作
  6. Python 入门指南
  7. 观看github前100开源项目的读后感
  8. Objective C运行时(runtime)技术的几个要点总结
  9. lucene教程简介
  10. postman 添加环境变量 并 读取变量 作为参数 传入,跑整个场景