参考: https://blog.csdn.net/heizistudio/article/details/79568188
- 1.安装zookeeper
zookeeper-3.4.6.tar.gz
tar zxvf zookeeper-3.4.6.tar.gz?
cd zookeeper-3.4.6/src/c
./configure
make
make install
- 2.启动zookeeper服务
cd zookeeper-3.4.6/conf/
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg #修改dataDir=/data/database/zookeeper
mkdir -p /data/database/zookeeper
cd ..
zookeeper-3.4.5-cdh5.0.0]# cd bin/
./zkServer.sh start ?#启动服务
./zkServer.sh status #查看启动状态
如果显示
Mode: standalone
则表示启动成功
如果显示 It is probably not running,原因是没有安装jdk或者没有配置JAVA_HOME路径
- 3.安装zkpython
在https://pypi.python.org/pypi/zkpython/0.4.2 下载,然后解压后安装
如果 import zookeeper就表示成功安装
- 4.python连接和操作zookeeper
输入python进入python界面
>>> import zookeeper
>>> zk=zookeeper.init("localhost:2181")
2018-03-15 13:56:49,486:70665(0x7f0eef010740):ZOO_INFO@log_env@712: Client environment:zookeeper.version=zookeeper C client 3.4.6
2018-03-15 13:56:49,486:70665(0x7f0eef010740):ZOO_INFO@log_env@716: Client environment:host.name=dsk_db90
2018-03-15 13:56:49,486:70665(0x7f0eef010740):ZOO_INFO@log_env@723: Client environment:os.name=Linux
2018-03-15 13:56:49,486:70665(0x7f0eef010740):ZOO_INFO@log_env@724: Client environment:os.arch=3.10.0-514.26.2.el7.x86_64
2018-03-15 13:56:49,486:70665(0x7f0eef010740):ZOO_INFO@log_env@725: Client environment:os.version=#1 SMP Tue Jul 4 15:04:05 UTC 2017
2018-03-15 13:56:49,487:70665(0x7f0eef010740):ZOO_INFO@log_env@733: Client environment:user.name=root
2018-03-15 13:56:49,487:70665(0x7f0eef010740):ZOO_INFO@log_env@741: Client environment:user.home=/root
2018-03-15 13:56:49,487:70665(0x7f0eef010740):ZOO_INFO@log_env@753: Client environment:user.dir=/tmp/zookeeper/version-2
2018-03-15 13:56:49,487:70665(0x7f0eef010740):ZOO_INFO@zookeeper_init@786: Initiating client connection, host=localhost:2181 sessionTimeout=10000 watcher=(nil) sessionId=0 sessionPasswd=<null> context=(nil) flags=0
>>> 2018-03-15 13:56:49,487:70665(0x7f0ee695d700):ZOO_INFO@check_events@1705: initiated connection to server [127.0.0.1:2181]
2018-03-15 13:56:49,494:70665(0x7f0ee695d700):ZOO_INFO@check_events@1752: session establishment complete on server [127.0.0.1:2181], sessionId=0x1622799854c0002, negotiated timeout=10000
>>> name = "dsk_moocdb"
>>> hostip = ?"10.0.7.91"
>>> uptime="uptime"
>>> zookeeper.set(zk,"/" + name + "/" + hostip + "/" + "uptime",uptime)
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
zookeeper.NoNodeException: no node ? ?改报错是多级路径的话,必须一级级的先建立好
>>> zookeeper.create(zk,"/" + name ,hostip,[{"perms":0x1f,"scheme":"world","id":"anyone"}],0)
'/dsk_moocdb'
zookeeper.BadArgumentsException: bad arguments
>>> zookeeper.create(zk,"/" + name + "/" + hostip,hostip,[{"perms":0x1f,"scheme":"world","id":"anyone"}],0)
'/dsk_moocdb/10.0.7.91'
>>> zookeeper.get_children(zk,"/",None)
['dsk_moocdb', 'zookeeper', 'moocmysql', 'zk_for_py1', 'zk_for_py']
>>> zookeeper.get_children(zk,"/dsk_moocdb",None)
['10.0.7.91']
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91",None)
[]
>>> zookeeper.set(zk,"/" + name + "/" + hostip + "/" + "uptime","uptime")
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
zookeeper.NoNodeException: no node
>>> zookeeper.set(zk,"/" + name + "/" + hostip + "/" + "uptime","uptime")
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
zookeeper.NoNodeException: no node
>>> print name
dsk_moocdb
>>> print hostip
10.0.7.91
>>> uptime="uptime"
>>> zookeeper.create(zk,"/" + name + "/" + hostip+"/"+uptime,uptime,[{"perms":0x1f,"scheme":"world","id":"anyone"}],1)
'/dsk_moocdb/10.0.7.91/uptime'
>>> zookeeper.set(zk,"/" + name + "/" + hostip + "/" + "uptime","uptime")
0
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91",None)
['uptime']
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91/uptime",None)
[]
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91/uptime",None)
[]
>>> import os
>>> uptime = os.popen('uptime').read()
>>> zookeeper.set(zk,"/" + name + "/" + hostip + "/" + "uptime",uptime)
0
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91/uptime",None)
[]
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91/uptime") ? ??
[]
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91/uptime")
[]
>>> print uptime?
?12:32:35 up 35 days, 19:33, ?3 users, ?load average: 0.55, 0.72, 0.61
>>> zookeeper.get_children(zk,"/dsk_moocdb/10.0.7.91/uptime")
[]
>>> zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/uptime")
(' 12:32:35 up 35 days, 19:33, ?3 users, ?load average: 0.55, 0.72, 0.61\n', {'pzxid': 42L, 'ctime': 1521088288214L, 'aversion': 0, 'mzxid': 44L, 'numChildren': 0, 'ephemeralOwner': 0L, 'version': 2, 'dataLength': 71, 'mtime': 1521088366971L, 'cversion': 0, 'czxid': 42L})
>>> zookeeper.create(zk,"/" + name + "/" + hostip+"/"+uptime,uptime,[{"perms":0x1f,"scheme":"world","id":"anyone"}],0)
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
zookeeper.BadArgumentsException: bad arguments
>>> disk_full="disk_full"
>>> zookeeper.create(zk,"/" + name + "/" + hostip+"/"+disk_full,disk_full,[{"perms":0x1f,"scheme":"world","id":"anyone"}],1)
>>> zookeeper.create(zk,"/" + name + "/" + hostip+"/"+disk_full,disk_full,[{"perms":0x1f,"scheme":"world","id":"anyone"}],1)
'/dsk_moocdb/10.0.7.91/disk_full'
>>> zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/uptime") ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
(' 12:32:35 up 35 days, 19:33, ?3 users, ?load average: 0.55, 0.72, 0.61\n', {'pzxid': 42L, 'ctime': 1521088288214L, 'aversion': 0, 'mzxid': 44L, 'numChildren': 0, 'ephemeralOwner': 0L, 'version': 2, 'dataLength': 71, 'mtime': 1521088366971L, 'cversion': 0, 'czxid': 42L})
>>> disk_full = os.popen('df -h').read() ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
>>> zookeeper.set(zk,"/" + name + "/" + hostip + "/" + "disk_full",disk_full)
0
>>> zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/uptime") ? ? ? ? ? ? ? ? ? ? ? ??
(' 12:32:35 up 35 days, 19:33, ?3 users, ?load average: 0.55, 0.72, 0.61\n', {'pzxid': 42L, 'ctime': 1521088288214L, 'aversion': 0, 'mzxid': 44L, 'numChildren': 0, 'ephemeralOwner': 0L, 'version': 2, 'dataLength': 71, 'mtime': 1521088366971L, 'cversion': 0, 'czxid': 42L})
>>> zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/disk_full")
('\xe6\x96\x87\xe4\xbb\xb6\xe7\xb3\xbb\xe7\xbb\x9f ? ? ? ?\xe5\xae\xb9\xe9\x87\x8f ?\xe5\xb7\xb2\xe7\x94\xa8 ?\xe5\x8f\xaf\xe7\x94\xa8 \xe5\xb7\xb2\xe7\x94\xa8% \xe6\x8c\x82\xe8\xbd\xbd\xe7\x82\xb9\n/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /\ndevtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev\ntmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm\ntmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run\ntmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup\n/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot\n/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1\n/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2\ntmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0\n/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak\n', {'pzxid': 45L, 'ctime': 1521088621727L, 'aversion': 0, 'mzxid': 46L, 'numChildren': 0, 'ephemeralOwner': 0L, 'version': 1, 'dataLength': 535, 'mtime': 1521088787892L, 'cversion': 0, 'czxid': 45L})
>>> data=zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/uptime")
>>>?
>>> print data[0]
?12:32:35 up 35 days, 19:33, ?3 users, ?load average: 0.55, 0.72, 0.61
>>> print data[1]
{'pzxid': 42L, 'ctime': 1521088288214L, 'aversion': 0, 'mzxid': 44L, 'numChildren': 0, 'ephemeralOwner': 0L, 'version': 2, 'dataLength': 71, 'mtime': 1521088366971L, 'cversion': 0, 'czxid': 42L}
>>> print data[2]
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
IndexError: tuple index out of range
>>> print data[0]
?12:32:35 up 35 days, 19:33, ?3 users, ?load average: 0.55, 0.72, 0.61
>>> data=zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/disk_full")
>>> print data[0]
文件系统 ? ? ? ?容量 ?已用 ?可用 已用% 挂载点
/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /
devtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm
tmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup
/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot
/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1
/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2
tmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0
/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak
>>> data=zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/disk_full")[0]
>>> print data[0]
>> pdata=zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/disk_full")
>>> print data[0]
文件系统 ? ? ? ?容量 ?已用 ?可用 已用% 挂载点
/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /
devtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm
tmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup
/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot
/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1
/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2
tmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0
/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak
>>> data=zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/disk_full")
>>> print data[0]
文件系统 ? ? ? ?容量 ?已用 ?可用 已用% 挂载点
/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /
devtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm
tmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup
/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot
/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1
/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2
tmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0
/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak
>>> data=zookeeper.get(zk,"/dsk_moocdb/10.0.7.91/disk_full")
>>> data1=data[1]
>>> print data1
{'pzxid': 45L, 'ctime': 1521088621727L, 'aversion': 0, 'mzxid': 46L, 'numChildren': 0, 'ephemeralOwner': 0L, 'version': 1, 'dataLength': 535, 'mtime': 1521088787892L, 'cversion': 0, 'czxid': 45L}
>>> print data1[0]
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
KeyError: 0
>>> print data1[pzxid]
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
NameError: name 'pzxid' is not defined
>>> print data1[pzxid]
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
NameError: name 'pzxid' is not defined
>>> print data1[0] ? ?
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
KeyError: 0
>>> print data1[1]
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
KeyError: 1
>>> num=len(data1)
>>> print num
11
>>> print data1[01]
Traceback (most recent call last):
? File "<stdin>", line 1, in <module>
KeyError: 1
>>> print data1['pzxid']
45
>>> print data1['numChildren']
0
>>>?
[root@dsk_db90 ~]# /tools/zookeeper-3.4.6/bin/zkCli.sh -server localhost:2181
Connecting to localhost:2181
2018-03-15 14:00:59,288 [myid:] - INFO ?[main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2018-03-15 14:00:59,294 [myid:] - INFO ?[main:Environment@100] - Client environment:host.name=<NA>
2018-03-15 14:00:59,294 [myid:] - INFO ?[main:Environment@100] - Client environment:java.version=1.8.0_141
2018-03-15 14:00:59,297 [myid:] - INFO ?[main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2018-03-15 14:00:59,298 [myid:] - INFO ?[main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/jre
2018-03-15 14:00:59,298 [myid:] - INFO ?[main:Environment@100] - Client environment:java.class.path=/tools/zookeeper-3.4.6/bin/../build/classes:/tools/zookeeper-3.4.6/bin/../build/lib/*.jar:/tools/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/tools/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/tools/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/tools/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/tools/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/tools/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/tools/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/tools/zookeeper-3.4.6/bin/../conf:
2018-03-15 14:00:59,298 [myid:] - INFO ?[main:Environment@100] - Client environment:java.library.path=/usr/local/lib::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2018-03-15 14:00:59,298 [myid:] - INFO ?[main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2018-03-15 14:00:59,298 [myid:] - INFO ?[main:Environment@100] - Client environment:java.compiler=<NA>
2018-03-15 14:00:59,299 [myid:] - INFO ?[main:Environment@100] - Client environment:os.name=Linux
2018-03-15 14:00:59,299 [myid:] - INFO ?[main:Environment@100] - Client environment:os.arch=amd64
2018-03-15 14:00:59,299 [myid:] - INFO ?[main:Environment@100] - Client environment:os.version=3.10.0-514.26.2.el7.x86_64
2018-03-15 14:00:59,299 [myid:] - INFO ?[main:Environment@100] - Client environment:user.name=root
2018-03-15 14:00:59,299 [myid:] - INFO ?[main:Environment@100] - Client environment:user.home=/root
2018-03-15 14:00:59,299 [myid:] - INFO ?[main:Environment@100] - Client environment:user.dir=/root
2018-03-15 14:00:59,301 [myid:] - INFO ?[main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@5c29bfd
Welcome to ZooKeeper!
2018-03-15 14:00:59,333 [myid:] - INFO ?[main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-03-15 14:00:59,429 [myid:] - INFO ?[main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2018-03-15 14:00:59,436 [myid:] - INFO ?[main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x1622799854c0003, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[dsk_moocdb, zookeeper, moocmysql, zk_for_py1, zk_for_py]
[zk: localhost:2181(CONNECTED) 1] ls /dsk_moocdb
[10.0.7.91]
[zk: localhost:2181(CONNECTED) 2] help
ZooKeeper -server host:port cmd args
? ? ? ? stat path [watch]
? ? ? ? set path data [version]
? ? ? ? ls path [watch]
? ? ? ? delquota [-n|-b] path
? ? ? ? ls2 path [watch]
? ? ? ? setAcl path acl
? ? ? ? setquota -n|-b val path
? ? ? ? history?
? ? ? ? redo cmdno
? ? ? ? printwatches on|off
? ? ? ? delete path [version]
? ? ? ? sync path
? ? ? ? listquota path
? ? ? ? rmr path
? ? ? ? get path [watch]
? ? ? ? create [-s] [-e] path data acl
? ? ? ? addauth scheme auth
? ? ? ? quit?
? ? ? ? getAcl path
? ? ? ? close?
? ? ? ? connect host:port
[zk: localhost:2181(CONNECTED) 3] s2 /dsk_moocdb ? ??
ZooKeeper -server host:port cmd args
? ? ? ? stat path [watch]
? ? ? ? set path data [version]
? ? ? ? ls path [watch]
? ? ? ? delquota [-n|-b] path
? ? ? ? ls2 path [watch]
? ? ? ? setAcl path acl
? ? ? ? setquota -n|-b val path
? ? ? ? history?
? ? ? ? redo cmdno
? ? ? ? printwatches on|off
? ? ? ? delete path [version]
? ? ? ? sync path
? ? ? ? listquota path
? ? ? ? rmr path
? ? ? ? get path [watch]
? ? ? ? create [-s] [-e] path data acl
? ? ? ? addauth scheme auth
? ? ? ? quit?
? ? ? ? getAcl path
? ? ? ? close?
? ? ? ? connect host:port
[zk: localhost:2181(CONNECTED) 4] ls2 /dsk_moocdb
[10.0.7.91]
cZxid = 0x26
ctime = Thu Mar 15 12:27:16 CST 2018
mZxid = 0x26
mtime = Thu Mar 15 12:27:16 CST 2018
pZxid = 0x27
cversion = 1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 9
numChildren = 1
[zk: localhost:2181(CONNECTED) 5] ls2 /dsk_moocdb/10.0.7.91
[disk_full, uptime]
cZxid = 0x27
ctime = Thu Mar 15 12:27:33 CST 2018
mZxid = 0x27
mtime = Thu Mar 15 12:27:33 CST 2018
pZxid = 0x2d
cversion = 2
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 9
numChildren = 2
[zk: localhost:2181(CONNECTED) 6] ls2 /dsk_moocdb/10.0.7.91/disk_full
[]
cZxid = 0x2d
ctime = Thu Mar 15 12:37:01 CST 2018
mZxid = 0x2e
mtime = Thu Mar 15 12:39:47 CST 2018
pZxid = 0x2d
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 535
numChildren = 0
[zk: localhost:2181(CONNECTED) 7] ls2 /dsk_moocdb/10.0.7.91/uptime ??
[]
cZxid = 0x2a
ctime = Thu Mar 15 12:31:28 CST 2018
mZxid = 0x2c
mtime = Thu Mar 15 12:32:46 CST 2018
pZxid = 0x2a
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 71
numChildren = 0
[zk: localhost:2181(CONNECTED) 8] ls2 /dsk_moocdb/10.0.7.91/uptime/
Command failed: java.lang.IllegalArgumentException: Path must not end with / character
[zk: localhost:2181(CONNECTED) 9] ls2 /dsk_moocdb/10.0.7.91/uptime?
[]
cZxid = 0x2a
ctime = Thu Mar 15 12:31:28 CST 2018
mZxid = 0x2c
mtime = Thu Mar 15 12:32:46 CST 2018
pZxid = 0x2a
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 71
numChildren = 0
[zk: localhost:2181(CONNECTED) 10] ls /dsk_moocdb/10.0.7.91/uptime?
[]
[zk: localhost:2181(CONNECTED) 11] ls2 /dsk_moocdb/10.0.7.91/uptime
[]
cZxid = 0x2a
ctime = Thu Mar 15 12:31:28 CST 2018
mZxid = 0x2c
mtime = Thu Mar 15 12:32:46 CST 2018
pZxid = 0x2a
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 71
numChildren = 0
[zk: localhost:2181(CONNECTED) 12] help
ZooKeeper -server host:port cmd args
? ? ? ? stat path [watch]
? ? ? ? set path data [version]
? ? ? ? ls path [watch]
? ? ? ? delquota [-n|-b] path
? ? ? ? ls2 path [watch]
? ? ? ? setAcl path acl
? ? ? ? setquota -n|-b val path
? ? ? ? history?
? ? ? ? redo cmdno
? ? ? ? printwatches on|off
? ? ? ? delete path [version]
? ? ? ? sync path
? ? ? ? listquota path
? ? ? ? rmr path
? ? ? ? get path [watch]
? ? ? ? create [-s] [-e] path data acl
? ? ? ? addauth scheme auth
? ? ? ? quit?
? ? ? ? getAcl path
? ? ? ? close?
? ? ? ? connect host:port
[zk: localhost:2181(CONNECTED) 13] get /dsk_moocdb/10.0.7.91/uptime
?12:32:35 up 35 days, 19:33, ?3 users, ?load average: 0.55, 0.72, 0.61
cZxid = 0x2a
ctime = Thu Mar 15 12:31:28 CST 2018
mZxid = 0x2c
mtime = Thu Mar 15 12:32:46 CST 2018
pZxid = 0x2a
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 71
numChildren = 0
[zk: localhost:2181(CONNECTED) 14] get /dsk_moocdb/10.0.7.91/disk_full
文件系统 ? ? ? ?容量 ?已用 ?可用 已用% 挂载点
/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /
devtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm
tmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup
/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot
/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1
/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2
tmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0
/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak
cZxid = 0x2d
ctime = Thu Mar 15 12:37:01 CST 2018
mZxid = 0x2e
mtime = Thu Mar 15 12:39:47 CST 2018
pZxid = 0x2d
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 535
numChildren = 0
[zk: localhost:2181(CONNECTED) 15] get /dsk_moocdb/10.0.7.91/disk_full.1
Node does not exist: /dsk_moocdb/10.0.7.91/disk_full.1
[zk: localhost:2181(CONNECTED) 16] get /dsk_moocdb/10.0.7.91/disk_full ?
文件系统 ? ? ? ?容量 ?已用 ?可用 已用% 挂载点
/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /
devtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm
tmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup
/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot
/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1
/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2
tmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0
/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak
cZxid = 0x2d
ctime = Thu Mar 15 12:37:01 CST 2018
mZxid = 0x2e
mtime = Thu Mar 15 12:39:47 CST 2018
pZxid = 0x2d
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 535
numChildren = 0
[zk: localhost:2181(CONNECTED) 17] get /dsk_moocdb/10.0.7.91/disk_full[0]
Node does not exist: /dsk_moocdb/10.0.7.91/disk_full[0]
[zk: localhost:2181(CONNECTED) 18] get /dsk_moocdb/10.0.7.91/disk_full[1]
Node does not exist: /dsk_moocdb/10.0.7.91/disk_full[1]
[zk: localhost:2181(CONNECTED) 19] get /dsk_moocdb/10.0.7.91/disk_full ??
文件系统 ? ? ? ?容量 ?已用 ?可用 已用% 挂载点
/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /
devtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm
tmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup
/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot
/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1
/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2
tmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0
/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak
cZxid = 0x2d
ctime = Thu Mar 15 12:37:01 CST 2018
mZxid = 0x2e
mtime = Thu Mar 15 12:39:47 CST 2018
pZxid = 0x2d
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 535
numChildren = 0
[zk: localhost:2181(CONNECTED) 20] get /dsk_moocdb/10.0.7.91/disk_full
文件系统 ? ? ? ?容量 ?已用 ?可用 已用% 挂载点
/dev/sda3 ? ? ? 542G ?6.7G ?535G ? ?2% /
devtmpfs ? ? ? ?126G ? ? 0 ?126G ? ?0% /dev
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /dev/shm
tmpfs ? ? ? ? ? 126G ? 82M ?126G ? ?1% /run
tmpfs ? ? ? ? ? 126G ? ? 0 ?126G ? ?0% /sys/fs/cgroup
/dev/sda1 ? ? ? 497M ?165M ?333M ? 34% /boot
/dev/sdb1 ? ? ? 3.7T ?1.8T ?2.0T ? 48% /sqldata1
/dev/sdd ? ? ? ?3.7T ?1.8T ?2.0T ? 48% /sqldata2
tmpfs ? ? ? ? ? ?26G ? ? 0 ? 26G ? ?0% /run/user/0
/dev/sdc ? ? ? ? 17T ? 12T ?4.4T ? 74% /mysqlbak
cZxid = 0x2d
ctime = Thu Mar 15 12:37:01 CST 2018
mZxid = 0x2e
mtime = Thu Mar 15 12:39:47 CST 2018
pZxid = 0x2d
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 535
numChildren = 0
[zk: localhost:2181(CONNECTED) 21] ls /
[dsk_moocdb, zookeeper, moocmysql, zk_for_py1, zk_for_py]
[zk: localhost:2181(CONNECTED) 22] get /dsk_moocdb ? ? ? ? ? ? ? ? ? ? ??
10.0.7.91
cZxid = 0x26
ctime = Thu Mar 15 12:27:16 CST 2018
mZxid = 0x26
mtime = Thu Mar 15 12:27:16 CST 2018
pZxid = 0x27
cversion = 1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 9
numChildren = 1
[zk: localhost:2181(CONNECTED) 23]?
原文地址:https://www.cnblogs.com/iiiiiher/p/10442946.html
时间: 2024-10-09 10:45:44