目录
前言:
zookeeper动态扩/缩容的reconfig命令旨在不需要重启zookeeper中任何一个节点的情况下,对整个zookeeper集群进行动态扩/缩容。
zookeeper客户端支持的命令:
[zk: localhost:2181(CONNECTED) 5] help
ZooKeeper -server host:port -client-configuration properties-file cmd args
addWatch [-m mode] path # optional mode is one of [PERSISTENT, PERSISTENT_RECURSIVE] - default is PERSISTENT_RECURSIVE
addauth scheme auth
close
# 查看配置
config [-c] [-w] [-s]
connect host:port
create [-s] [-e] [-c] [-t ttl] path [data] [acl]
delete [-v version] path
deleteall path [-b batch size]
delquota [-n|-b|-N|-B] path
get [-s] [-w] path
getAcl [-s] path
getAllChildrenNumber path
getEphemerals path
history
listquota path
ls [-s] [-w] [-R] path
printwatches on|off
quit
# 动态配置
reconfig [-s] [-v version] [[-file path] | [-members serverID=host:port1:port2;port3[,...]*]] | [-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*]
redo cmdno
removewatches path [-c|-d|-a] [-l]
set [-s] [-v version] path data
setAcl [-s] [-v version] [-R] path acl
setquota -n|-b|-N|-B val path
stat [-w] path
sync path
version
whoami
在实际验证中发现一些细节问题,先记录如下:
1、如果整个zk集群只有一个zk节点(即serverId只有它本身),这时默认运行的是单机模式,如果需要运行在集群模式下,需要加入standaloneEnabled=false的配置。
2、使用zkCli客户端提供的reconfig命令,需要修改/zookeper/config节点,普通账号对该节点上的数据只有ACL中的查看权限,有如下两种方法可以解决:
①关闭ACL,配置文件加入 skipACL=yes
②生成超级管理员账号: