kafka 操作
来源:互联网 发布:苏州远洋数据有限公司 编辑:程序博客网 时间:2024/06/05 15:29
1. Disabling automatically create topic
auto.create.topics.enable=false
2. Add topic
bin/kafka-topics.sh --zookeeper zk_host:port/chroot --create --topic my_topic_name --partitions 10 --replication-factor 2 --configretention.bytes=1073741824 --config retention.ms=2073600000
3. Modify topics
(1) add partition
bin/kafka-topics.sh --zookeeper zk_host:port/chroot --alter --topic my_topic_name --partitions 20
(2) add(update) config
bin/kafka-topics.sh --zookeeper zk_host:port/chroot --alter --topic my_topic_name --config retention.bytes=2147483648
(3) remove a config
bin/kafka-topics.sh --zookeeper zk_host:port/chroot --alter --topic my_topic_name --delete-config retention.ms
(4) delete topic
bin/kafka-topics.sh --zookeeper zk_host:port/chroot --delete --topic my_topic_name
delete.topic.enable=true
4. Graceful shutdown
controlled.shutdown.enable=true
5. Balancing leadership
bin/kafka-preferred-replica-election.sh --zookeeper zk_host:port/chroot
auto.leader.rebalance.enable=true
6. Checking consumer position
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper zk_host:port/chroot --group groupname
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper zk_host:port/chroot --group groupname --topic topicname
7. Expanding your cluster
(1) Automatically migrating data to new machines
vim topics-to-move.json
{"topics": [{"topic": "yurun"}], "version":1}
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topics-to-move.json --broker-list "0,1" --generate
vim expand-cluster-reassignment.json
{"version":1,"partitions":[{"topic":"yurun","partition":8,"replicas":[0,1]},{"topic":"yurun","partition":7,"replicas":[1,0]},{"topic":"yurun","partition":1,"replicas":[1,0]},{"topic":"yurun","partition":0,"replicas":[0,1]},{"topic":"yurun","partition":5,"replicas":[1,0]},{"topic":"yurun","partition":4,"replicas":[0,1]},{"topic":"yurun","partition":2,"replicas":[0,1]},{"topic":"yurun","partition":3,"replicas":[1,0]},{"topic":"yurun","partition":6,"replicas":[0,1]},{"topic":"yurun","partition":9,"replicas":[1,0]}]}
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment.json --execute
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment.json --verify
(2) Custom partition assignment and migration
vim custom-reassignment.json
{"version":1,"partitions":[{"topic":"yurun","partition":0,"replicas":[2,3]},{"topic":"yurun","partition":1,"replicas":[2,3]}]}
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file custom-reassignment.json --execute
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file custom-reassignment.json --verify
8. Decommissioning brokers
use 7
9. Increasing replication factor
use 7
0 0
- kafka 操作
- 使用spring-kafka操作kafka
- kafka系列-kafka常用操作
- kafka 操作中
- kafka集群操作指南
- Kafka的JAVA操作
- kafka基本操作
- kafka一些基本操作
- Kafka简单部署操作
- python 操作kafka
- kafka常用操作
- Kafka集群操作指南
- Kafka入门操作
- Kafka基本操作
- kafka基本操作
- Kafka基础操作命令
- Kafka的Topic操作
- kafka 常用操作
- iOS中的代理和Block
- Remove Duplicates from Sorted ListII
- 关于vim go环境的配置问题
- ie浏览器不使用代理设置
- Android Studio:正确引入so文件的方法
- kafka 操作
- js中this理解
- Android性能优化 浅析
- 设计模式【工厂模式】【单例模式】【装饰者模式】
- 使用OpenCV计算图像的轮廓矩的代码!
- java 代码加载顺序
- 磁卡会因手机长时间接触而消磁吗?
- DescriptionResourcePathLocationType ArtifactTransferException: Could not transfer artifact
- uboot.2015.07移植之驱动DM9000(8)