Zookeeper

作者: a9104fed92a0 | 来源:发表于2018-09-21 18:36 被阅读0次

    安装

    下载
    ZK官网
    解压
    tar -xvf zookeeper-3.4.10.tar.gz
    启动zk

    mv zookeeper-3.4.12 zk
    cd zk/
    cd conf/
    cp zoo_sample.cfg zoo.cfg
    cd ../bin
    sh zkServer.sh start
    

    简单测试

    ./zkCli.sh create /han_node 192.168.1.1 #创建节点
    ./zkCli.sh ls / #查看目录下的所有节点
    ./zkCli.sh get /han_node #获取当前节点的值
    

    zkCli的指令集

    ZooKeeper -server host:port cmd args
        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
    

    集群配置

    编辑三台机器的conf/zoo.cfg

    server.1=centos01:2888:3888
    server.2=centos02:2888:3888
    server.3=centos03:2888:3888
    maxClientCnxns=60
    

    设置机器id,编辑dataDir=/tmp/zookeeper指定目录下的myid文件,设置id(1~256)

    启动服务器
    zkServer.sh start
    查看服务器状态
    zkServer.sh status
    输出,集群启动成功
    [root@centos02 bin]# ./zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /home/vagrant/soft/zk/bin/../conf/zoo.cfg
    Mode: leader

    参考
    https://www.cnblogs.com/jxwch/p/6433310.html
    https://blog.csdn.net/liusanchun/article/details/78597644
    https://blog.csdn.net/scujinxiang/article/details/79206667

    相关文章

      网友评论

          本文标题:Zookeeper

          本文链接:https://www.haomeiwen.com/subject/qiiciftx.html