Common Kafka Commands
The following is a summary of common command lines in Kafka:
1. View the details of the
topic./kafka-topics.sh -zookeeper 127.0.0.1:60301 -describe -topic test
2. Add a copy
to the topic./kafka-reassign-partitions .sh -zookeeper 127.0.0.1:2181 -reassignment-json-file json/partitions-to-move.json -execute
3. Create topic
./kafka-topics.sh --create --zookeeper localhost:2181 --replication- factor 1 --partitions 1 --topic testKJ1
4. Add partition to topic
./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --alter --partitions 20 --topic testKJ1 5.
kafka producer client command./
kafka-console-producer.sh --broker-list localhost:9092 --topic testKJ1
6. kafka consumer client command
./kafka-console-consumer.sh -zookeeper localhost:2181 --from-beginning --topic testKJ1
7, kafka service
start./kafka-server-start.sh -daemon ../config/server.properties
8, next Line broker
./kafka-run-class.sh kafka.admin.ShutdownBroker --zookeeper 127.0.0.1:2181 --broker #brokerId# --num.retries 3 --retry.interval.ms 60
shutdown broker
9. Delete topic Kill the command if you can't delete it (turn off kafka and clear the data directly)
./kafka-run-class.sh kafka.admin.DeleteTopicCommand --topic testKJ1 --zookeeper 127.0.0.1:2181
./kafka-topics.sh -- zookeeper localhost:2181 --delete --topic testKJ1
topic delete
(1) delete the topic related files in the log directory
(2) delete the data in zookeeper
Log zookeeper client:
cd $
ZOOKEEPER_HOME bin/zkCli.sh
Delete ls /config/topics/topicname and ls /brokers/topics/topicname
The above two steps will be completely deleted
. 10. Check the offset consumed in the consumer group.
./kafka-run-class.sh kafka.tools.ConsumerOffsetChecker -- zookeeper localhost:2181 --group test --topic testKJ1
kafka common commands (transfer)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326463332&siteId=291194637
Ranking