zoukankan      html  css  js  c++  java
  • 一、window下zookeeper独立部署

    zookeeper是一个分布式协调应用,用于管理大型主机。通俗地说,分布式应用相对于单体应用存在着很多要处理的问题,而这些问题通常是不太好处理的。比如,典型的一致性问题,而zookeeper可以很简单的实现解决一致性问题。我们可以将zookeeper理解为“解决分布式应用常见问题的应用”。

    zookeeper可以解决如:发布订阅、负载均衡、命名服务、分布式通知与协调、集群管理与master选举、分布式锁、分布式队列等。

    一、环境准备

    zookeeper是由Java语言编写的,所以运行zookeeper需要Java环境的支持。

    windows下JDK开发环境请参考:http://www.runoob.com/java/java-environment-setup.html#win-install

    二、下载

    下载二进制包,下载地址:http://mirrors.shu.edu.cn/apache/zookeeper/zookeeper-3.4.13/

    三、配置

    解压二进制包:zookeeper-3.4.13.tar.gz

    将zookeeper-3.4.13conf目录下的文件zoo_sample.cfg拷贝一份,改名为zoo.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=C:\Users\admin\Desktop\software\zk\data
    dataLogDir=C:\Users\admin\Desktop\software\zk\log
    # 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

    添加修改数据目录dataDir、日志目录dataLogDir

    四、启动测试

    进入bin目录zookeeper-3.4.13in

    双击执行服务端启动命令:zkServer.cmd

    双击执行客户端启动命令:zkCli.cmd

    如果要连接远程的话:

    zkCli.cmd -server localhost:2181 // windows
    zkCli.sh -server localhost:2181 // Linux

    使用ls命令查看根节点下的节点

    [zk: localhost:2181(CONNECTED) 0] ls /
    [zookeeper]

    只有一个zookeeper节点

    使用create命令创建一个节点,添加数据

    [zk: localhost:2181(CONNECTED) 1] create /user lay
    Created /user

    再ls查看一次

    [zk: localhost:2181(CONNECTED) 2] ls /
    [zookeeper, user]

    我们发现新增了一个user节点

    查看user节点

    [zk: localhost:2181(CONNECTED) 3] get /user
    lay
    cZxid = 0x1b
    ctime = Wed Sep 12 11:06:27 CST 2018
    mZxid = 0x1b
    mtime = Wed Sep 12 11:06:27 CST 2018
    pZxid = 0x1b
    cversion = 0
    dataVersion = 0
    aclVersion = 0
    ephemeralOwner = 0x0
    dataLength = 3
    numChildren = 0

    我们看到了数据lay,以及一些元数据

     如果你要删除节点可以使用命令

    delete /路径

    但是如果该路径存在节点或者数据时无法删除的,这时候你可以使用递归删除命令

    rmr /路径
  • 相关阅读:
    在c++代码中执行bat文件 【转】
    华为交换机限速配置命令2016
    zabbix报错listener failed: zbx_tcp_listen() fatal error: unable to serve on any address
    shell脚本中执行mysql 语句,去除warning using a password on the command line interface can be insecure信息
    zabbix_get :command not found 解决办法
    CentOS7 升级到7.4
    jumpserver v0.5.0 创建用户和管理机器
    zabbix触发的多条件判断表达式
    nginx 配置一个文件下载服务
    ECS 实例网络带宽
  • 原文地址:https://www.cnblogs.com/lay2017/p/9633625.html
Copyright © 2011-2022 走看看