/home/kafka/config/kafka_client_producer_jaas.conf 文件为对应集群的鉴权配置文件,例如
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule \
required username="dev-user" password="devuser@123";
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
1.查看topic列表
非鉴权
/home/kafka/bin/kafka-topics.sh --bootstrap-server 172.xx.xx.xxx:9092 --list
鉴权
/home/kafka/bin/kafka-topics.sh --bootstrap-server 172.xx.xx.xxx:9092 --list --command-config /home/kafka/config/kafka_client_producer_jaas.conf
2.查看某个topic分区副本等信息
非鉴权
/home/kafka/bin/kafka-topics.sh --bootstrap-server 172.xx.xx.xxx:9092 --describe
鉴权
/home/kafka/bin/kafka-topics.sh --bootstrap-server 172.xx.xx.xxx:9092 --describe --command-config /home/kafka/config/kafka_client_producer_jaas.conf
3.查看消费者组信息
非鉴权
/home/kafka/bin/kafka-consumer-groups.sh --bootstrap-server 172.xx.xx.xxx:9092 --list
鉴权
/home/kafka/bin/kafka-consumer-groups.sh --bootstrap-server 172.xx.xx.xxx:9092 --list --command-config /home/kafka/config/kafka_client_producer_jaas.conf
4.查看某个消费者组消费情况
非鉴权
/home/kafka/bin/kafka-consumer-groups.sh --bootstrap-server 172.xx.xx.xxx:9092 --describe --group 消费者组名称
鉴权
/home/kafka/bin/kafka-consumer-groups.sh --bootstrap-server 172.xx.xx.xxx:9092 --describe --group 消费者组名称 --command-config /home/kafka/config/kafka_client_producer_jaas.conf
5.获取某个topic消息数量
非鉴权
/home/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 172.xx.xx.xxx:9092 --topic b00_bi_mdb_slave
鉴权
/home/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 172.xx.xx.xxx:9092 --topic b00_bi_mdb_slave --command-config /home/kafka/config/kafka_client_producer_jaas.conf
6.控制台消费某个topic信息
非鉴权
/home/kafka/bin/kafka-console-consumer.sh --bootstrap-server 172.xx.xx.xxx:9092 --topic canal_iot_topic
鉴权
/home/kafka/bin/kafka-console-consumer.sh --bootstrap-server 172.xx.xx.xxx:9092 --topic canal_iot_topic --consumer.config /home/kafka/config/kafka_client_producer_jaas.conf