Zookeeper--安装及命令

Zookeeper--单机模式安装 及命令

下载地址: http://zookeeper.apache.org/releases.html

tar -zxvf zookeeper-3.4.10.tar.gz

mv zookeeper-3.4.10 /Users/LG/tools/zookeeper-3.4.10

cd /Users/LG/tools/zookeeper-3.4.10

conf目录下新建配置文件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.
dataDir=../tmp/zookeeper

# the port at which the clients will connect
clientPort=2181

---

然后cd bin

./zkServer.sh start    #启动zk服务

./zkCli.sh    #进入zk命令工具

./zkServer.sh stop #关闭zk服务

zkCli.sh基本命令列表:

help 查看帮助

ls 查看子节点,如 ls /;   ls /mynode;  ls /znodes/node1

create 创建节点, 如 create /mynode mydate

get 获取数据, 如 get /mynode

set 更新数据, 如 set /mynode update1

stat 查看详细,如 stat /

delete 删除节点,  如 delete /mynode

quit 退出命令工具

close 关闭zk服务

Zookeeper四字母组合命令:

在ZK启动后,使用nc命令或telnet命令可以向ZK发送指令,如 echo ruok | nc localhost 2181 ,zk会返回 imok 表示zk正常运行

其他命令:

end

原文地址:https://www.cnblogs.com/luangeng/p/7385085.html