Kafka Command List

Source: Internet
Author: User
Tags json min zookeeper
Kafka based on the 0.8.0 version of the command usage:
See topic Distribution kafka-list-topic.sh
# bin/kafka-list-topic.sh--zookeeper 192.168.197.170:2181,192.168.197.171:2181 (List of all topic partitions)
# bin/kafka-list-topic.sh--zookeeper 192.168.197.170:2181,192.168.197.171:2181--topic Test (view partition of test)


In fact, kafka-list-topic.sh inside a sentence
EXEC $ (dirname $)/kafka-run-class.sh Kafka.admin.ListTopicCommand $@
A package that is actually executed through the kafka-run-class.sh script kafka.admin the following class
# #创建TOPIC Kafka-create-topic.sh
# bin/kafka-create-topic.sh--replica 2--partition 8--topic test--zookeeper 192.168.197.170:2181,192.168.197.171:218 1
Create a topic named Test, 8 partitions to hold data, data backup Total 2 copies

# bin/kafka-create-topic.sh--replica 1--partition 1--topic test2--zookeeper 192.168.197.170:2181,192.168.197.171:21 81
Results topic:test2 partition:0 leader:170 replicas:170 isr:170
# #重新分配分区kafka-reassign-partitions.sh
This command can be partitioned to the desired--broker-list.
# bin/kafka-reassign-partitions.sh--topics-to-move-json-file topics-to-move.json--broker-list "171"--zookeeper 192.168.197.170:2181,192.168.197.171:2181--execute
Cat Topic-to-move.json
{"Topics":
[{"topic": "Test2"}],
"Version": 1
}
# #为Topic增加 Number of partition kafka-add-partitions.sh
#bin/kafka-add-partitions.sh--topic Test--partition 2--zookeeper 192.168.197.170:2181,192.168.197.171:2181 (for topic Test adds 2 partitions)

# #控制台接收消息
#bin/kafka-console-consumer.sh--zookeeper 192.168.197.170:2181,192.168.197.171:2181--from-beginning--topic test
# #控制台发送消息
# bin/kafka-console-producer.sh--broker-list 192.168.197.170:9092,192.168.197.171:9092--topic test
# #手动均衡topic, kafka-preferred-replica-election.sh
# bin/kafka-preferred-replica-election.sh--zookeeper 192.168.197.170:2181,192.168.197.171:2181-- Path-to-json-file Preferred-click.json

Cat Preferred-click.json
{
"Partitions":
[
{"topic": "click", "Partition": 0},
{"topic": "click", "Partition": 1},
{"topic": "click", "Partition": 2},
{"topic": "click", "Partition": 3},
{"topic": "click", "Partition": 4},
{"topic": "click", "Partition": 5},
{"topic": "click", "Partition": 6},
{"topic": "click", "Partition": 7},
{"topic": "Play", "Partition": 0},
{"topic": "Play", "Partition": 1},
{"topic": "Play", "Partition": 2},
{"topic": "Play", "Partition": 3},
{"topic": "Play", "Partition": 4},
{"topic": "Play", "Partition": 5},
{"topic": "Play", "Partition": 6},
{"topic": "Play", "Partition": 7}

]
}

# #删除topic, use caution, only delete the metadata in zookeeper, the message file must be deleted manually
# bin/kafka-run-class.sh Kafka.admin.DeleteTopicCommand--topic test666--zookeeper 192.168.197.170:2181, 192.168.197.171:2181

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.