kafka常用命令

config.properties

server.properties

server.1=172.28.92.39:2888:3888

server.2=172.28.92.37:2888:3888

server.3=172.28.92.38:2888:3888

server

start

./bin/zookeeper-server-start.sh -daemon ./config/zookeeper.properties

stop

./bin/kafka-server-start.sh -daemon ./config/server.properties

分区

修改分区

./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --alter --partitions 3 --topic monitor-log

消费

手动消费

./bin/kafka-console-consumer.sh --bootstrap-server 172.28.92.37:9092,172.28.92.38:9092,172.28.92.39:9092  --topic monitorlog --from-beginning

./bin/kafka-console-consumer.sh --zookeeper localhost:2181  --topic log.test

./bin/kafka-console-consumer.sh --bootstrap-server 172.20.61.203:6667,172.20.61.204:6667,172.20.61.205:6667 --topic monitor-log

查看group消费情况

./bin/kafka-consumer-groups.sh --bootstrap-server 172.28.92.39:9092 --describe --group 1

./bin/kafka-consumer-groups.sh --zookeeper 127.0.0.1:2181 --describe --group 1

topic

create

bin/kafka-topics.sh --create --bootstrap-server 172.28.92.37:9092 --replication-factor 1 --partitions 1 --topic monitor-alerts

delete

bin/kafka-topics.sh --bootstrap-server 172.28.92.37:9092 --delete --topic monitorlog

list

./bin/kafka-topics.sh --zookeeper localhost:2181 --list 

describe

./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --describe  --topic monitor-log

delete topic

./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --delete --topic xxxxx

config

查看所有topic的config

./bin/kafka-configs.sh --zookeeper 127.0.0.1:2181 --describe --entity-type topics

查看配置

./bin/kafka-configs.sh --zookeeper localhost:2181 --describe --entity-type topics --entity-name monitor-alerts

设置retention

./bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-type topics --entity-name monitor-alerts  --add-config retention.ms=86400000

DumpLogSegments

~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.log --print-data-log > 00000000000336375351.log
~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.index --print-data-log > 00000000000336375351.index
~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.timeindex --print-data-log > 00000000000336375351.timeindex

consumer

bin/kafka-console-consumer.sh --bootstrap-server 172.28.92.37:9092,172.28.92.38:9092,172.28.92.39:9092 --topic monitor-alerts --from-beginning

offset

bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable  --time -1 --broker-list 172.20.61.203:6667 --partitions 0

转载于:https://www.cnblogs.com/zhouj-happy/p/11375686.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值