最近換了新的電腦,終於買了求之不得的macbook。最近也換了新的公司,公司技術棧用到了zookeeper.固然本身也要安裝學習下。省的渣渣的我,被鄙視就麻煩了。本篇文章只介紹如何安裝,先安裝上以後,再進行具體學習。java
本文使用brew
進行安裝,默默說一句,mac的系統是比win好用。沒有安裝brew和jdk的童鞋請先安裝這2個。session
一、 打開終端執行命令學習
brew install zookeeper
二、 啓動執行code
zkServer start
三、 執行zk鏈接server
zkCli -timeout 5000 -server 127.0.0.1:2181
四、 簡單操做get
[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]
五、參數意義:macbook
cZxid:節點建立時的zxid ctime:節點建立時間 mZxid:節點最近一次更新時的zxid mtime:節點最近一次更新的時間 cversion:子節點數據更新次數 dataVersion:本節點數據更新次數 aclVersion:節點ACL(受權信息)的更新次數 ephemeralOwner:若是該節點爲臨時節點,ephemeralOwner值表示與該節點綁定的session id. 若是該節點不是臨時節點,ephemeralOwner值爲0 dataLength:節點數據長度,本例中爲hello world的長度 numChildren:子節點個數
6.中止Serverit
zkServer stop
今天感覺了下zookeeper,固然只是簡單的安裝了一下,體驗了一下。我如今也是個菜鳥。對這個也不懂,慢慢學起來。io