flume常用命令

olivee 3年前 ⋅ 1140 阅读

1. topic相关命令

1.1. 查看topic列表

./kafka-topics.sh --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --list

1.2. 创建topic

./kafka-topics.sh --create --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --partitions 3 --replication-factor 3 --topic test-1

./kafka-topics.sh --create --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --partitions 3 --replication-factor 3 --topic test33

1.3. 查看topic详情

./kafka-topics.sh  --describe --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092  --topic bigdata-TLD-list
./kafka-topics.sh  --describe --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092  --topic bigdata-BD-detail
  • 测试:
./kafka-topics.sh  --describe --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092  --topic test-1
Topic: test-1   PartitionCount: 3       ReplicationFactor: 3    Configs: segment.bytes=1073741824,max.message.bytes=10485760
        Topic: test-1   Partition: 0    Leader: 105     Replicas: 105,106,104   Isr: 105,106,104
        Topic: test-1   Partition: 1    Leader: 106     Replicas: 106,104,105   Isr: 106,104,105
        Topic: test-1   Partition: 2    Leader: 104     Replicas: 104,105,106   Isr: 104,105,106

1.4 查看 topic 的 offset

/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --topic bigdata-TLD-list
./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --topic bigdata-BD-detail
  • 比如看到的结果
./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --topic test-1
test-1:0:24
test-1:1:25
test-1:2:25

2. consumer相关命令

2.1. 查看consumer列表

./kafka-consumer-groups.sh --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --list

2.2 查看consumer的offset

./kafka-consumer-groups.sh --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --describe  --group testg-1

比如看到的信息:

./kafka-consumer-groups.sh --bootstrap-server aostarhd04:9092,aostarhd05:9092,aostarhd06:9092 --describe  --group custom.bdata.001
GROUP            TOPIC                PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                     HOST            CLIENT-ID
custom.bdata.001 bdata-JGPT-cdzxq     0          -               251414          -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-JGPT-cdzlb     0          -               12              -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-WLYC-cslb      0          -               11              -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-XQCAPP-zqcdzdd 0          -               85056           -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-XQCAPP-zqcdzlb 0          -               0               -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-WLYC-cclb      0          -               460             -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-Baidumap-cdzxq 0          -               3755513         -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-XQCAPP-zqcdzxq 0          -               23553           -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-WLYC-cclx      0          -               11              -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1
custom.bdata.001 bdata-BaiduAPI-cdzlb 0          -               28424           -               consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1

2.3 查看consumer的members

主要看结果中的HOST列

./kafka-consumer-groups.sh --bootstrap-server aostarhd04:9092,aostarhd05:9092,aostarhd06:9092 --describe  --group custom.bdata.001 --members
GROUP            CONSUMER-ID                                     HOST            CLIENT-ID       #PARTITIONS
custom.bdata.001 consumer-1-5f90ea81-9bd4-4907-bedf-0afa4567a6e1 /192.168.3.187  consumer-1      10
custom.bdata.001 consumer-1-a2018f14-d091-4129-9b00-025b6e9e2852 /192.168.11.100 consumer-1      0

2.4 删除consumer group

./kafka-consumer-groups.sh --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --delete --group testg-1

3. 测试

3.1 生产数据

./kafka-console-producer.sh --broker-list aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --topic test-1

3.2 消费数据

./kafka-console-consumer.sh --bootstrap-server aostarhd01:9092,aostarhd02:9092,aostarhd03:9092 --group testg-1 --topic test-1 --from-beginning