Start and stop the script, because the path is often wrong, resulting in unsuccessful start or stop. This script needs to configure KAFKA_HOME in the /etc/profile file.
Usage: <custom file name> start/stop
Example:
kk.sh start
kk.sh stop
hadoop102 etc. are the host names configured in hosts.
#!/bin/bash
case $1 in
"start"){
for i in hadoop102 hadoop103 hadoop104
do
echo "************$i************"
ssh $i "source /etc/profile;nohup ${KAFKA_HOME}/bin/kafka-server-start.sh -daemon ${KAFKA_HOME}/config/server.properties"
done
};;
"stop"){
for i in hadoop102 hadoop103 hadoop104
do
echo "************$i************"
ssh $i "source /etc/profile;nohup ${KAFKA_HOME}/bin/kafka-server-stop.sh ${KAFKA_HOME}/config/server.properties"
done
};;
esac
Solve the problem of No kafka server to stop when kafka is stopped.
Change the value in kafka-server-stop.sh
PIDS=$(ps ax | grep -i ‘kafka.Kafka’ | grep java | grep -v grep | awk ‘{
print $1}’)
change into
PIDS=$(jps -lm | grep -i ‘kafka.Kafka’ | awk ‘{
print $1}’)
The problem that jps could not be found also appeared during the execution.
Solve the error "bash: jps: command not found"
1. Switch root user
su root
2. Create symbolic link
ln -s jps path link target storage location
My settings are as follows:
ln -s /opt/module/jdk1.8.0_144 /bin/jps /bin/jps
Reference link:
https://blog.csdn.net/weixin_44318830/article/details/104959433
https://blog.csdn.net/KingAnne/article/details/101034794
https://my.oschina.net/u/4342612 /blog/3332480