zookeeper命令行操作
進(jìn)入命令行
運行 zkCli.sh –server <ip>進(jìn)入命令行工具。
[root@zk1 bin]# zkCli.sh -server ? <不加ip地址,連接本地zookeeper>
Error: no argument found for option -server
Connecting to localhost:2181
[zk: localhost:2181(CONNECTED) 0]?
[root@zk1 bin]# zkCli.sh -server zk2 ?< 加ip地址,連接相應(yīng)的zookeeper>
Connecting to zk2
[zk: zk2(CONNECTED) 0]?
HELP
輸入help查看幫助
[zk: localhost:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
? ? ? ? stat path [watch]
? ? ? ? set path data [version]
? ? ? ? ls path [watch]
? ? ? ? delquota [-n|-b] path
? ? ? ? ls2 path [watch] ?---詳情版ls
? ? ? ? setAcl path acl
? ? ? ? setquota -n|-b val path
? ? ? ? history?
? ? ? ? redo cmdno
? ? ? ? printwatches on|off
? ? ? ? delete path [version]
? ? ? ? sync path
? ? ? ? listquota path
? ? ? ? get path [watch]
? ? ? ? create [-s] [-e] path data acl
? ? ? ? addauth scheme auth
? ? ? ? quit?
? ? ? ? getAcl path
? ? ? ? close?
? ? ? ? connect host:port
操作
zookeeper的節(jié)點符合常規(guī)的文件系統(tǒng)規(guī)范。
ls?
[zk: localhost:2181(CONNECTED) 3] ls /
[zookeeper]
create?
[zk: localhost:2181(CONNECTED) 6] create /testapp1 1111
Created /testapp1
默認(rèn)節(jié)點類型是:PERSISTENT
[zk: localhost:2181(CONNECTED) 7] ls /
[testapp1, zookeeper]
[zk: localhost:2181(CONNECTED) 8] create -s /testapp1 1111
Created /testapp10000000009
[zk: localhost:2181(CONNECTED) 9] ls /
[testapp1, zookeeper, testapp10000000009]
[zk: localhost:2181(CONNECTED) 10]?
進(jìn)入zk2,zk3 使用ls 命令可以看到zk1的內(nèi)容已經(jīng)同步了。
create?EPHEMERAL類型
[zk: localhost:2181(CONNECTED) 4] create -e /app1eeee eeee
Created /app1eeee
[zk: localhost:2181(CONNECTED) 5] ls /
[testapp1, zookeeper, app1eeee, testapp10000000009]
quit退出
在其他節(jié)點 ls / 發(fā)現(xiàn)app1eeee沒了,退出后就刪了
[zk: localhost:2181(CONNECTED) 2] create -e /app1eeeee/app2eee eeee
Ephemerals cannot have children: /app1eeeee/app2eee
get
[zk: localhost:2181(CONNECTED) 1] get /testapp1
1111 ?<存進(jìn)去的內(nèi)容>
cZxid = 0x300000007
ctime = Sun Nov 13 20:57:06 CST 2016
mZxid = 0x300000007
mtime = Sun Nov 13 20:57:06 CST 2016
pZxid = 0x300000007
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 4
numChildren = 0
set
[zk: localhost:2181(CONNECTED) 2] set /testapp1 2222
cZxid = 0x300000007
ctime = Sun Nov 13 20:57:06 CST 2016
mZxid = 0x30000000a
mtime = Sun Nov 13 21:05:26 CST 2016
pZxid = 0x300000007
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 4
numChildren = 0
-------------
更多的Java,Angular,Android,大數(shù)據(jù),J2EE,Python,數(shù)據(jù)庫,Linux,Java架構(gòu)師,:
http://www.cnblogs.com/zengmiaogen/p/7083694.html
總結(jié)
以上是生活随笔為你收集整理的zookeeper命令行操作的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 01电话拨号器
- 下一篇: 华为手机应用鸿蒙os,华为手机内置应用逐