Home > Back-end >  Kafka common commands
Kafka common commands

Time:01-06

1, kafka monitoring message:
Export JMX_PORT=9945 (non-hold port)
/opt/kafka_2. 12-2.4.0/bin/kafka - the console - consumer. Sh
./kafka - the console - consumer. Sh -- -- the bootstrap - server kafka - SVC 0:9-093, 093, kafka - SVC - 1:9 kafka - SVC - 2:9 093 - topic T_iMC_5_Trap

2, see the topic of health status:
Bin/kafka - switchable viewer. Sh -- -- zookeeper zk - 81 1:21 - go - topic T_iMC_5_Trap
./kafka - switchable viewer. Sh -- -- the bootstrap - server kafka - SVC - 0:9 093, 093, kafka - SVC - 1:9 kafka - SVC - 2:9 093 - go - topic T_iMC_5_Trap

3, add partition
Export JMX_PORT=9998
./kafka - switchable viewer. Sh - alter - zookeeper zk - 1:2181 - topic T_iMC_5_Trap - partitions 15

4, to see all the topic
/root @ env221 ~ # kubectl exec - it f97778b6 kafka - 0-65 - frh27/bin/bash
Defaulting container name to kafka - 0.
Use 'kubectl describe pod/f97778b6 - frh27 kafka - 0-65 - n service - software' to see all of the containers in thi
Bash - 4.4 # export JMX_PORT=9997
Bash - 4.4 # CD/opt/kafka
Bash - 4.4 # bin/kafka - switchable viewer. Sh - zookeeper zk - 21, 81 -- a list

4, restart kakfa and clean up the historical data
/root @ master1 ~ # kubectl scale deployment kafka - 0 - replicas=0
Deployment. Extensions/kafka - 0 scaled
/root @ master1 ~ # kubectl scale deployment - replicas kafka - 1=0
Scaled deployment. Extensions/kafka - 1
/root @ master1 ~ # kubectl scale deployment kafka - 2 - replicas=0
Deployment. Extensions/kafka - 2 scaled

/root @ master1 ~ # kubectl delete pod kafka - 0-6494 bbfb5f - CDRMF f44957 kafka - 1-8697 - t8prh f455 kafka - 2-785897 - t8rrz - force - grace - period=0
Warning: the Immediate deletion does not wait for confirmation that the running resource has had been terminated. The resource may continue to run on the cluster indefinitely.
The Error from the server (NotFound) : the pods "kafka - 0-6494 bbfb5f - CDRMF" not found
The Error from the server (NotFound) : the pods "f44957 kafka - 1-8697 - t8prh" not found
The Error from the server (NotFound) : the pods "kafka - 2-785897 f455 - t8rrz" not found
/root @ master1 ~ # kubectl get pod -o wide | grep kafka
/root @ master1 ~ # CD/var/lib/ssdata/kafka
[root @ master1 kafka] # ls
Broker0 broker1 broker2
[root @ master1 kafka] # rm - rf *
[root @ master1 kafka] # kubectl scale deployment kafka - 0 - replicas=1
Deployment. Extensions/kafka - 0 scaled
[root @ master1 kafka] # kubectl scale deployment - replicas kafka - 1=1
[root @ master1 kafka] # kubectl scale deployment kafka - 2 - replicas=1
Deployment. Extensions/kafka - 2 scaled

5, check the group under the offset information
./kafka - consumer groups. Sh -- -- the bootstrap - server kafka - SVC 0:9-093, 093, kafka - SVC - 1:9 kafka - SVC - 2:9 093 - go - group Kafka_Alarm

6, kafka message to the specified topic:
Bash - 4.4 #./kafka - the console - producer. Sh - broker - list kafka - SVC 0:9-093, 093, kafka - SVC - 1:9 kafka - SVC - 2:9 093 - topic T_iMC_5_Trap
{" nGenericID ": 4," nSpecificID ": 0," nTrapVersion ": 0," strEnterpriseID ":" 1.3.6.1.4.1.2011.1.2.1.12 ", "strTrapIP" : "10.66.60.13", "vbInfo" : null}

{" nGenericID ": 4," nSpecificID ": 0," nTrapVersion ": 0," strEnterpriseID ":" 1.3.6.1.4.1.2011.1.2.1.12 ", "strTrapIP" : "10.66.60.13", "vbInfo" : null} for the input message



  • Related