kakfa常用命令
命令模拟kafka消费之,筛选特定消息
./kafka-console-consumer.sh --bootstrap-server 172.21.10.43:9092 --topic event_heaven_eye_event_topic_1| grep “xcx_jiafu_home_search_btnClick”
设置kafka 单个topic 保留时长
./kafka-configs.sh --zookeeper localhost:2181 --alter --entity-name event_device_order_topic_test --entity-type topics --add-config retention.ms=36000000
查询某个topic的信息
./kafka-configs.sh --zookeeper 172.21.10.43:2181 --describe --entity-name heaven_eye_buriedpoint --entity-type topics
增加、修改、删除Topic的配置项
sh kafka-configs.sh --alter --zookeeper ****** --entity-type topics --entity-name myTopicHA --add-config retention.bytes=1099511627776
kafka-topics.sh --bootstrap-server ${kafkaAddress} --create --topic ${topicName} --partitions ${partipartions} --replication-factor ${replication}
kafka-topics.sh --bootstrap-server ${kafkaAddress} --topic ${topicName} --describe
kafka-topics.sh --bootstrap-server ${kafkaAddress} --delete–topic ${topicName} --partitions ${partitions} --replication-factor ${replication}
kafka-topics.sh --bootstrap-server ${kafkaAddress} --list
kafka-console-consumer.sh --bootstrap-server ${kafkaAddress} --topic ${topicName} --from-beginning
kafka-consumer-groups.sh --describe --bootstrap-server ${kafkaAddress} --group ${groupName}
a.修改partitions数量
./kafka-topics.sh --zookeeper 172.21.10.43:2181 --topic event_device_order_topic_test --alter --partitions 24
./kafka-topics.sh --alter --zookeeper 172.21.10.43:2181 --topic event_device_order_topic_test --partitions 24
b.创建increase-replication-factor.json in config,配置各分区replication-factor位置
内容格式:
{“version”:1, “partitions”:[
{“topic”:“test-topic-update”,“partition”:0,“replicas”:[5,4]},
{“topic”:“test-topic-update”,“partition”:1,“replicas”:[1,3]},
{“topic”:“test-topic-update”,“partition”:2,“replicas”:[0,2]},
{“topic”:“test-topic-update”,“partition”:3,“replicas”:[3,0]},
{“topic”:“test-topic-update”,“partition”:4,“replicas”:[2,1]},
{“topic”:“test-topic-update”,“partition”:5,“replicas”:[4,5]},
{“topic”:“test-topic-update”,“partition”:6,“replicas”:[5,4]},
{“topic”:“test-topic-update”,“partition”:7,“replicas”:[1,3]},
{“topic”:“test-topic-update”,“partition”:8,“replicas”:[0,2]},
{“topic”:“test-topic-update”,“partition”:9,“replicas”:[3,0]},
{“topic”:“test-topic-update”,“partition”:10,“replicas”:[2,1]},
{“topic”:“test-topic-update”,“partition”:11,“replicas”:[4,5]}]
}
原文链接:https://blog.csdn.net/u010383467/article/details/132604085
c.更新replication-factor
kafka-reassign-partitions.sh --zookeeper 172.21.10.43:2181 --reassignment-json-file config/increase-replication-factor.json --execute
查看kafka 数据 存储占用空间排序:
路径:
/data/kafka_2.12-2.1.1/logs
命令:
du -sh * | sort -rh | less
查看kafka topic 副本情况
./kafka-topics.sh --zookeeper localhost:2181 --describe --topic heaven_eye_event_topic_1