zoukankan      html  css  js  c++  java
  • zookeeper学习相关

    一:安装

        1:下载 zookeeper 安装包,解压;

        2:修改配置文件。

              a:将文件目录下的z oo_sample.cfg 文件复制一份到该目录,并且改名为 zoo.cfg;

              b:修改zoo.cfg的文件内容。打开文件,修改  dataDir 属性的值,修改为本机存在的目录;

    # 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=/tmp/zookeeper
    dataDir=D:/zookeperSpace
    # 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

    3,启动 zookeeper的服务。对应的启动文件---zkServer.cmd;

    4,启动zookeeper的客户端。对应的启动文件--zkCli.cmd;

    二。zookeeper简单使用

    1,创建节点

      命令格式: create /node_1

     

    说明:

    a:创建临时节点: create -e /node_2  "555";

    b:创建有序节点:create -s /node_2 "555"

    可以用于生成主键

    2,查询节点

    get /node_1

    3.更新节点

    命令格式:set /node_1  123  

    说明:

    命令格式:set  /node_1  "value "version (可选)

    set 命令后,节点的version字段会增加;

    set 时,如果version和当前节点的version不一致,则不能set成功。可以通过version,查看该节点被修改的次数,也可以通过该属性,查看别人是否修改了节点;

    4,删除节点

    命令格式:delete  /node_1 version 

    说明:

    a:该节点没有子节点,则删除成功;

    b:version 字段设置同  set;

    c:如果要全部删除节点,则使用 rmr  /节点名称

    d:节点 /zookeeper不能删除;

    5,列出目录下的节点

    命令格式:ls /节点路径  

    说明:节点路径必须以"/"开始;

  • 相关阅读:
    MySQL简概
    IO模型
    协程
    multiprocessing模块
    Python线程的常见的lock
    111-使用post的方式传值(最简示例)
    110-使用正则匹配的方式从url获值
    109-get方式获取url传值
    108-使用表格,不依赖于后台而输入内容
    107-创建第一个动态模板
  • 原文地址:https://www.cnblogs.com/li-zhan/p/9401423.html
Copyright © 2011-2022 走看看