zookeeper在Linux客戶端操作命令大全
一、基本操作介紹
命令基本語法 | 功能描述 |
help | 顯示所有操作命令 |
ls path | 使用 ls 命令來檢視當前znode的子節點 -w 監聽子節點變化 -s 附加次級資訊 |
create | 普通建立 -s 含有序列 -e 臨時(重啟或者超時消失) |
get path | 獲得節點的值 -w 監聽節點內容變化 -s 附加次級資訊 |
set | 設定節點的具體值 |
stat | 檢視節點狀態 |
delete | 刪除節點 |
deleteall | 遞迴刪除節點 |
二、操作演示
1)啟動客戶端
bin/zkCli.sh
2)顯示所有操作命令
[zk: localhost:2181(CONNECTED) 1] help
3)檢視當前znode中所包含的內容
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
4)檢視當前節點詳細資料
[zk: localhost:2181(CONNECTED) 1] ls2 /
[zookeeper]
cZxid = 0x0
ctime = Thu Jan 01 08:00:00 CST 1970
mZxid = 0x0
mtime = Thu Jan 01 08:00:00 CST 1970
pZxid = 0x0
cversion = -1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 1
5)分別建立2個普通節點
[zk: localhost:2181(CONNECTED) 3] create /sanguo "jinlian"
Created /sanguo
[zk: localhost:2181(CONNECTED) 4] create /sanguo/shuguo "liubei"
Created /sanguo/shuguo
6)獲得節點的值
[zk: localhost:2181(CONNECTED) 5] get /sanguo
jinlian
cZxid = 0x100000003
ctime = Wed Aug 29 00:03:23 CST 2018
mZxid = 0x100000003
mtime = Wed Aug 29 00:03:23 CST 2018
pZxid = 0x100000004
cversion = 1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 1
[zk: localhost:2181(CONNECTED) 6]
[zk: localhost:2181(CONNECTED) 6] get /sanguo/shuguo
liubei
cZxid = 0x100000004
ctime = Wed Aug 29 00:04:35 CST 2018
mZxid = 0x100000004
mtime = Wed Aug 29 00:04:35 CST 2018
pZxid = 0x100000004
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
7)建立短暫節點
[zk: localhost:2181(CONNECTED) 7] create -e /sanguo/wuguo "zhouyu"
Created /sanguo/wuguo
(1)在當前客戶端是能檢視到的
[zk: localhost:2181(CONNECTED) 3] ls /sanguo
[wuguo, shuguo]
(2)退出當前客戶端然後再重啟客戶端
[zk: localhost:2181(CONNECTED) 12] quit
bin/zkCli.sh
(3)再次檢視根目錄下短暫節點已經刪除
[zk: localhost:2181(CONNECTED) 0] ls /sanguo
[shuguo]
8)建立帶序號的節點
(1)先建立一個普通的根節點/sanguo/weiguo
[zk: localhost:2181(CONNECTED) 1] create /sanguo/weiguo "caocao"
Created /sanguo/weiguo
(2)建立帶序號的節點
[zk: localhost:2181(CONNECTED) 2] create -s /sanguo/weiguo/xiaoqiao "jinlian"
Created /sanguo/weiguo/xiaoqiao0000000000
[zk: localhost:2181(CONNECTED) 3] create -s /sanguo/weiguo/daqiao "jinlian"
Created /sanguo/weiguo/daqiao0000000001
[zk: localhost:2181(CONNECTED) 4] create -s /sanguo/weiguo/diaocan "jinlian"
Created /sanguo/weiguo/diaocan0000000002
如果原來沒有序號節點,序號從0開始依次遞增。如果原節點下已有2個節點,則再排序時從2開始,以此類推。
9)修改節點資料值
[zk: localhost:2181(CONNECTED) 6] set /sanguo/weiguo "simayi"
10)節點的值變化監聽
(1)在hadoop104主機上註冊監聽/sanguo節點資料變化
[zk: localhost:2181(CONNECTED) 26] [zk: localhost:2181(CONNECTED) 8] get /sanguo watch
(2)在hadoop103主機上修改/sanguo節點的資料
[zk: localhost:2181(CONNECTED) 1] set /sanguo "xisi"
(3)觀察hadoop104主機收到資料變化的監聽
WATCHER::
WatchedEvent state:SyncConnected type:NodeDataChanged path:/sanguo
11)節點的子節點變化監聽(路徑變化)
(1)在hadoop104主機上註冊監聽/sanguo節點的子節點變化
[zk: localhost:2181(CONNECTED) 1] ls /sanguo watch
[aa0000000001, server101]
(2)在hadoop103主機/sanguo節點上建立子節點
[zk: localhost:2181(CONNECTED) 2] create /sanguo/jin "simayi"
Created /sanguo/jin
(3)觀察hadoop104主機收到子節點變化的監聽
WATCHER::
WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/sanguo
12)刪除節點
[zk: localhost:2181(CONNECTED) 4] delete /sanguo/jin
13)遞迴刪除節點
[zk: localhost:2181(CONNECTED) 15] rmr /sanguo/shuguo
14)檢視節點狀態
[zk: localhost:2181(CONNECTED) 17] stat /sanguo
cZxid = 0x100000003
ctime = Wed Aug 29 00:03:23 CST 2018
mZxid = 0x100000011
mtime = Wed Aug 29 00:21:23 CST 2018
pZxid = 0x100000014
cversion = 9
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 4
numChildren = 1
相關文章
- ZooKeeper客戶端CRUD命令客戶端
- Zookeeper--客戶端基礎命令客戶端
- 【zookeeper之七】Zookeeper客戶端客戶端
- Zookeeper 客戶端 API客戶端API
- ElasticSearch-命令列客戶端操作Elasticsearch命令列客戶端
- Zookeeper Java 客戶端搭建Java客戶端
- Zookeeper--Java客戶端Java客戶端
- 【Zookeeper】zookeeper客戶端KeeperErrorCode = ConnectionLoss客戶端Error
- zookeeper的Java客戶端APIJava客戶端API
- cvs客戶端大全(轉)客戶端
- Zookeeper C客戶端庫編譯客戶端編譯
- zookeeper 開源客戶端ZkClient使用客戶端client
- zookeeper 開源客戶端Curator使用客戶端
- ZooKeeper服務發現客戶端客戶端
- Linux命令操作大全Linux
- 在指令碼中呼叫cassandra客戶端命令指令碼客戶端
- 聊一聊 Zookeeper 客戶端之 Curator客戶端
- Zookeeper客戶端使用與叢集原理客戶端
- zookeeper Java客戶端API的使用方法Java客戶端API
- ZooKeeper客戶端事件序列化處理客戶端事件
- Elasticsearch的PHP客戶端操作ElasticsearchPHP客戶端
- Linux 平臺安裝SQLServer客戶端操作指南LinuxSQLServer客戶端
- Zookeeper之Curator(1)客戶端基本的建立,刪除,更新,查詢操作api客戶端API
- iscsi linux客戶端Linux客戶端
- Zookeeper之Zookeeper底層客戶端架構實現原理(轉載)客戶端架構
- VNC客戶端是Windows,VNC客戶端是Windows如何進行操作VNC客戶端Windows
- Zookeeper的基本命令大全
- 《samba搭建win客戶端和linux客戶端的區別》Samba客戶端Linux
- 命令列客戶端MySQL如何使用命令列客戶端MySql
- Clickhouse-客戶端查詢命令客戶端
- ZooKeeper服務發現客戶端--重連認證客戶端
- ElasticSearch客戶端簡單操作例項Elasticsearch客戶端
- Redis介紹 && Java客戶端操作RedisRedisJava客戶端
- InfluxDB 客戶端基礎操作2UX客戶端
- Irssi:命令列下的IRC客戶端命令列客戶端
- PostgreSQL學習手冊(客戶端命令)SQL客戶端
- PostgreSQL - psql(客戶端互動命令)SQL客戶端
- redis:常用客戶端命令(redis-cli)Redis客戶端