zoukankan      html  css  js  c++  java
  • zookeeper安装与配置

    【转载请注明作者和原文链接,欢迎讨论,相互学习。】

    一、环境
    1.操作系统:centos 6
    2.3台虚拟机,192.168.1.128,192.168.1.129,192.168.1.130
    3.关闭防火墙

    二、安装与配置步骤
    1.下载zookeeper,如:zookeeper-3.4.6.tar.gz,放到/usr/local目录下,并解压
       cd /usr/local/

       tar zxvf zookeeper-3.4.6.tar.gz 

    2.目录修改为zookeeper
    mv zookeeper-3.4.6 zookeeper

    3.在/usr/local/zookeeper目录下,新建日志目录和日志目录
    mkdir /usr/local/zookeeper/data
    mkdir /usr/local/zookeeper/logs

    4.配置文件修改与配置参数说明
    4.1 配置修改
    将/usr/local/zookeeper/conf下的zoo_sample.cfg重命名为zoo.cfg,配置文件内容如下:
    # 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=/usr/local/zookeeper/data
    dataLogDir=/usr/local/zookeeper/logs
    # the port at which the clients will connect
    clientPort=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
    server.1=192.168.1.128:2888:3888
    server.2=192.168.1.129:2888:3888
    server.3=192.168.1.130:2888:3888

    4.2 配置参数说明
    initLimit:zookeeper集群包含一台leader和多台follower,initLimit表示初始化连接时,follower和leader之间最长的心跳时间。
    syncLimit:follower和leader之间发送消息,请求与应答的最大时间,即5x2000ms=10000ms=10s。
    server.X=A:B:C 其中X是一个数字,表示第几号server,A是IP或者域名,B是该server和集群leader交换信息所用端口号,C是选择leader时所用端口号。

    5.在/usr/local/zookeeper/data目录下,新建文件myid,
    touch /usr/local/zookeeper/data/myid
    对于192.168.1.128,myid文件内容为1,
    对于192.168.1.129,myid文件内容为2,
    对于192.168.1.130,myid文件内容为3

    三、启动与关闭
    启动:/usr/local/zookeeper/bin/zkServer.sh start
    关闭:/usr/local/zookeeper/bin/zkServer.sh stop
    重启:/usr/local/zookeeper/bin/zkServer.sh restart
    查看:/usr/local/zookeeper/bin/zkServer.sh status

  • 相关阅读:
    摩尔定律 四
    为什么要重载new? 四
    JS 完美识别IE FIREFOX CHROME safari
    Chrome的JS调试工具
    JetBrains WebStorm 6注册码(其实版本v4, v5, v6都通用)
    require.js 入门学习
    str_replace、preg_replace、strtr比较
    获取当前IP地址,跳转到对应城市网站。
    mysql大数据高并发处理(转)
    SESSION的安全性(转)
  • 原文地址:https://www.cnblogs.com/eric-lin/p/4953289.html
Copyright © 2011-2022 走看看