博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zookeeper安装及部署
阅读量:7282 次
发布时间:2019-06-30

本文共 3829 字,大约阅读时间需要 12 分钟。

安装及部署

一. 单机安装、配置

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:$1            else                PATH=$1:$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 manipulationif [ "$EUID" = "0" ]; then    pathmunge /sbin    pathmunge /usr/sbin    pathmunge /usr/local/sbinelse    pathmunge /usr/local/sbin after    pathmunge /usr/sbin after    pathmunge /sbin afterfiHOSTNAME=`/bin/hostname 2>/dev/null`HISTSIZE=1000if [ "$HISTCONTROL" = "ignorespace" ] ; then    export HISTCONTROL=ignorebothelse    export HISTCONTROL=ignoredupsfiexport 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 200# You could check uidgid reservation validity in# /usr/share/doc/setup-*/uidgid fileif [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then    umask 002else    umask 022fifor i in /etc/profile.d/*.sh ; do    if [ -r "$i" ]; then        if [ "${-#*i}" != "$-" ]; then            . "$i"        else            . "$i" >/dev/null 2>&1        fi    fidoneunset iunset pathmungeJAVA_HOME=/usr/java/jdk1.7.0_51#zookeeper环境变量设置ZOOKEEPER_HOME=/usr/local/logdeal/zookeeper-3.4.6PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$ZOOKEEPER_HOME/lib:TOMCAT_HOME=/usr/local/tomcat7CATALINA_HOME=/usr/local/tomcat7export ZOOKEEPER_HOMEexport JAVA_HOMEexport PATHexport CLASSPATHexport TOMCAT_HOMEexport CATALINA_HOMEexport 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 ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# 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 connectclientPort=2181# 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
  • 配置说明:

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 #停止

二. 集群安装、配置

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

  • 参考资料:

转载于:https://www.cnblogs.com/wangyangliuping/p/5546506.html

你可能感兴趣的文章
C#中byte类型转换为double类型
查看>>
有意思的网站
查看>>
max3232
查看>>
linux读写ntfs
查看>>
x264 编码器选项分析 (x264 Codec Strong and Weak Points) 1
查看>>
lintcode:带环链表
查看>>
10最好的开放源移动工具的工作场所
查看>>
【转载】为什么不建议<=3G的情况下使用CMS GC
查看>>
CentOS中基于不同版本安装重复包的解决方案
查看>>
vim:查看当前的配置文件名称和地址
查看>>
javaweb学习总结二十二(servlet开发中常见的问题汇总)
查看>>
Nginx 做系统的前端反向proxy
查看>>
Win8 Metro(C#)数字图像处理--2.49Zhang二值图像细化算法
查看>>
嵌入 Office ,doc|docx|xls|xlsx|ppt|pptx|pdf|等
查看>>
Cut Down QtWebkit Library
查看>>
在Windows下Hunchentoot的启动
查看>>
网新恒天2013年校园招聘笔试
查看>>
推荐五星级C语言学习网站
查看>>
windows 下的命令行工具。。
查看>>
使用自定义的BaseAdapter实现LIstView的展示
查看>>