Kafka启动:(根据自身路径更改)
/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
Zookeeper启动:(根据自身路径更改)
/usr/local/zookeeper/bin/zkServer.sh start
进入客户端的命令:{zookeeper目录}/bin/zkCli.sh
/usr/local/zookeeper/bin/zkCli.sh
以下是几个zookeeper客户端用的命令,不只kafka,其他任何注册到zookeeper的服务都可以使用这些命令。
1、ls
ls会显示该节点下的子节点信息
比如:ls /
[zk: localhost:2181(CONNECTED) 1] ls /
[dubbo, log_dir_event_notification, isr_change_notification, zookeeper, admin, consumers, cluster, config, latest_producer_id_block, controller, brokers, controller_epoch]
#显示zookeeper根目录下的子节点,其中kafka的broker在zookeeper根目录注册了brokers节点
比如:ls /brokers/topics/lockcar_loction/partitions
[zk: localhost:2181(CONNECTED) 2] ls /brokers/topics/lockcar_loction/partitions
[1, 0]
#显示lockcar_loction这个topic下的partitions的子节点
2、get
get命令会显示该节点的节点数据内容和属性信息
比如:get /brokers/topics/lockcar_loction
[zk: localhost:2181(CONNECTED) 2] get /brokers/topics/lockcar_loction
{"version":1,"partitions":{"1":[1],"0":[3]}}
cZxid = 0x5000000cf
ctime = Wed Apr 08 09:12:12 CST 2020
mZxid = 0x5000000cf
mtime = Wed Apr 08 09:12:12 CST 2020
pZxid = 0x5000000d2
cversion = 1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 44
numChildren = 1
#显示lockcar_loction这个topic的节点数据内容和属性信息。
#第一行大括号里面就是节点的数据内容,创建topic时候的定义的topic级别配置会被记录在这里
3、ls2
ls2命令会显示该节点的子节点信息和属性信息
比如:ls2 /brokers/topics/lockcar_loction
[zk: localhost:2181(CONNECTED) 4] ls2 /brokers/topics/lockcar_loction
[partitions]
cZxid = 0x5000000cf
ctime = Wed Apr 08 09:12:12 CST 2020
mZxid = 0x5000000cf
mtime = Wed Apr 08 09:12:12 CST 2020
pZxid = 0x5000000d2
cversion = 1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 44
numChildren = 1
#显示lockcar_loction这个topic的子节点和属性信息。
#第一行中括号里的是子节点。
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
评论