zookeeper学习(零)_安装与启动

最近换了新的电脑,终于买了梦寐以求的macbook。最近也换了新的公司,公司技术栈用到了zookeeper.当然自己也要安装学习下。省的渣渣的我,被鄙视就麻烦了。本篇文章只介绍如何安装,先安装上之后,再进行具体学习。

安装

本文使用brew 进行安装,默默说一句,mac的系统是比win好用。没有安装brew和jdk的童鞋请先安装这2个。

  1. 打开终端执行命令
brew install zookeeper
  1. 启动执行
zkServer start
  1. 执行zk连接
zkCli -timeout 5000 -server 127.0.0.1:2181
  1. 简单操作
 [zk: 127.0.0.1:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 1] create /zk_test kevin
Created /zk_test
[zk: 127.0.0.1:2181(CONNECTED) 2] ls /
[zookeeper, zk_test]
[zk: 127.0.0.1:2181(CONNECTED) 3] get zk_test
Command failed: java.lang.IllegalArgumentException: Path must start with / character
[zk: 127.0.0.1:2181(CONNECTED) 4] get /zk_test
kevin
cZxid = 0x7
ctime = Sat Sep 14 21:14:18 CST 2019
mZxid = 0x7
mtime = Sat Sep 14 21:14:18 CST 2019
pZxid = 0x7
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 5
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 5] set /zk_test zookeeper
cZxid = 0x7
ctime = Sat Sep 14 21:14:18 CST 2019
mZxid = 0x8
mtime = Sat Sep 14 21:15:28 CST 2019
pZxid = 0x7
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 9
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 6] get /zk_test
zookeeper
cZxid = 0x7
ctime = Sat Sep 14 21:14:18 CST 2019
mZxid = 0x8
mtime = Sat Sep 14 21:15:28 CST 2019
pZxid = 0x7
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 9
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 7] delete /zk_test
[zk: 127.0.0.1:2181(CONNECTED) 8] ls /
[zookeeper]

5.停止Server

zkServer stop

总结

今天感受了下zookeeper,当然只是简单的安装了一下,体验了一下。我先在也是个菜鸟。对这个也不懂,慢慢学起来。

版权声明:本文为zhenghengbin原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zhenghengbin/p/11520351.html