Can't stop kafka servers and zookeeper

14,010

What is the version are you using ? I'm on the 0.10.1.0 and the script works but in any case it's for stopping only the Kafka server and not the Zookeeper as well. The first difference I notice with the script you posted is that mine has :

kill -s TERM $PIDS

that is a fix for this https://issues.apache.org/jira/browse/KAFKA-3384 made to be POSIX compliant.

Share:
14,010
AsmaaM
Author by

AsmaaM

Updated on June 04, 2022

Comments

  • AsmaaM
    AsmaaM almost 2 years

    I have kafka brokers running and I want to stop kafka and zookeeper to bring some modifications and restart everything again (bring log.retention.hours to 4). However the command : Kafka-server-stop doesn't seem to work ! In kafka-server-stop I have this :

    PIDS=$(ps ax | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $1}')
    
    if [ -z "$PIDS" ]; then
      echo "No kafka server to stop"
      exit 1
    else
      kill SIGTERM $PIDS
    fi
    

    I've tried to kill kafka servers processus with "kill -9" but each time it restarts with another PID. How can I restart everything ? Stop kafka and zookeeper to restart again.

    EDIT :

    When I run : ps aux | grep kafka , I get something like this :

    root      6303  2.9 14.6 4861140 1174552 pts/0 Sl   16:26   0:53 /.../kafka-connect-fs-0.2-SNAPSHOT-package/share/java/kafka-c
    root      7710  1.3  2.4 3061164 192612 pts/2  Sl+  16:28   0:23 /.../kafka-connect-fs/c
    root     12008  0.4 11.3 3654604 907448 ?      Sl   Jun02  65:11 /.../kafka-connect-fs-0.2-SNAPSHOT-package/share/java/kafka-c
    root     13838  0.0  0.0 112656   936 pts/1    R+   16:56   0:00 grep --color=auto kafka
    root     26192  0.1  5.0 3062204 401224 ?      Sl   Jun02  25:34 /.../kafka-connect-fs-0.2-SNAPSHOT-package/share/java/kafka