Kafka and zookeeper common commands and knowledge points

zookeeper

Start ZK service: bin/zkServer.sh start
View ZK service status: bin/zkServer.sh status
Stop ZK service: bin/zkServer.sh stop
Restart ZK service: bin/zkServer.sh restart
Connect to server:zkCli.sh -server 192.168.10.11:2181

View node: ls [path]path is the node path
Create node information: create [-s] [-e] path datawhere -s is an ordered node -e Temporary node defaults to a persistent node
View node information: get [path]
delete a node:delete path [dataVersion]

Detailed explanation of the get command:

[zk: 192.168.9.5:2181(CONNECTED) 1] get /kafka
null(节点内容)
cZxid = 0x2(创建的事务id)
ctime = Tue Aug 07 15:07:00 CST 2018(创建时间)
mZxid = 0x2(最后一次修改的事务id)
mtime = Tue Aug 07 15:07:00 CST 2018(修改时间)
pZxid = 0x1c00457(子节点最后一次修改的事物id)
cversion = 222(子节点修改次数)
dataVersion = 0(子节点数据修改次数)
aclVersion = 0
ephemeralOwner = 0x0(如果为临时节点 则为创建该节点的绘画SessingId 持久化节点则显示0x0)
dataLength = 0(数据内容长度)
numChildren = 10(当前节点的下一级节点数量)

kafka

The kafka cluster is divided into two types of machines, one is kafka (cluster), which stores queue data, and the other is zk (cluster), which stores cluster information.
Producers generally connect to the kafka service (sometimes called Broker broker), one-way connection, no need to register in zk.
Consumers generally connect to zk services and register as consumers (see the connection dependency package used for details).

Configuration file path: kafka服务文件夹/config/server.properties
the zookeeper.connectconfiguration item is the zk server connected by kafka (the path can be added later to specify that the cluster information is stored in a certain path).

The path created by kafka in the zk service The address and port information of all kafka servers are stored in
the path , which can be obtained through the get command./brokers/ids/*

To view the kafka version, you can view kafka服务文件夹/libsthe following files, which have similar kafka_2.12-2.0.0.jarfiles.
2.12 represents the Scala language version that implements the Kafka, and the following 2.0.0 represents the Kafka service version. Note that when connecting with java, the jar packages used must be of the same version.

Guess you like

Origin blog.csdn.net/weixin_44927769/article/details/128723009