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

  • 相关阅读:
    UVA 10600 ACM Contest and Blackout(次小生成树)
    UVA 10369
    UVA Live 6437 Power Plant 最小生成树
    UVA 1151 Buy or Build MST(最小生成树)
    UVA 1395 Slim Span 最小生成树
    POJ 1679 The Unique MST 次小生成树
    POJ 1789 Truck History 最小生成树
    POJ 1258 Agri-Net 最小生成树
    ubuntu 用法
    ubuntu 搭建ftp服务器,可以通过浏览器访问,filezilla上传文件等功能
  • 原文地址:https://www.cnblogs.com/eric-lin/p/4953289.html
Copyright © 2011-2022 走看看