zoukankan      html  css  js  c++  java
  • zookeeper

    下载安装

    wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz

    解压:

    tar -zxvf zookeeper-3.4.13.tar.gz

    把名字改短一些

    mv zookeeper-3.4.13 /usr/local/apps/zookeeper

    配置环境变量:

    vi /etc/profile
    在配置文件中添加:
    export ZOOKEEPER_HOME=/usr/local/apps/zookeeper
    export PATH=$PATH:$ZOOKEEPER_HOME/bin

    复制一份zoo_sample.cfg并改名为zoo.cfg  

    cp zoo_sample.cfg zoo.cfg

     vi 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=/usr/local/apps/tmp/zkData
    # 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
    

    启动zookeeper

    zkServer.sh start
    

    运行客户端

    zkCli.sh

    help查看命令

    	stat path [watch]
    	set path data [version]
    	ls path [watch]
    	delquota [-n|-b] path
    	ls2 path [watch]
    	setAcl path acl
    	setquota -n|-b val path
    	history 
    	redo cmdno
    	printwatches on|off
    	delete path [version]
    	sync path
    	listquota path
    	rmr path
    	get path [watch]
    	create [-s] [-e] path data acl
    	addauth scheme auth
    	quit 
    	getAcl path
    	close 
    	connect host:port
    

    查看节点:ls / 

    [zk: localhost:2181(CONNECTED) 0] ls /
    [cluster, brokers, zookeeper, dubbo, admin,config]

    创建节点:create /test

    [zk: localhost:2181(CONNECTED) 3] create /test "aaa"     
    [zk: localhost:2181(CONNECTED) 4] ls /
    [cluster, brokers, zookeeper, dubbo, admin,config,test]
    [zk: localhost:2181(CONNECTED) 5] 

    删除节点:delete /test 

    [zk: localhost:2181(CONNECTED) 8] delete /test
    [zk: localhost:2181(CONNECTED) 9] ls /
    [cluster, brokers, zookeeper, dubbo, admin,config]
    [zk: localhost:2181(CONNECTED) 10] 
    

    获取节点数据 get /dubbo

    [zk: localhost:2181(CONNECTED) 10] get /dubbo
    192.168.23.1
    cZxid = 0xa
    ctime = Tue Sep 25 20:42:48 CST 2018
    mZxid = 0xa
    mtime = Tue Sep 25 20:42:48 CST 2018
    pZxid = 0x15
    cversion = 2
    dataVersion = 0
    aclVersion = 0
    ephemeralOwner = 0x0
    dataLength = 12
    numChildren = 2
    [zk: localhost:2181(CONNECTED) 11] 
    

      

  • 相关阅读:
    [Solution] DI原理解析及Castle、Unity框架使用
    [Solution] AOP原理解析及Castle、Autofac、Unity框架使用
    [C#] CSharp 基本语法
    [Architect] Abp 框架原理解析(5) UnitOfWork
    [Code] C#与js的正则表达式
    [SQL] SQL SERVER基础语法
    [Tool] PowerDesigner
    [JS] javascript基础语法
    SharedPreferences 的另一种场景的用法
    Eclipse 工程迁移到 Android Studio
  • 原文地址:https://www.cnblogs.com/lysongbo/p/9709248.html
Copyright © 2011-2022 走看看