#!/bin/bash
zkPort=2181
kaPort=9092
kaFile='/usr/local/kafka/config/server.properties'
zkFile='/usr/local/kafka/config/zookeeper.properties'
logsDir='/data/logs'
blue() {
echo -e "\033[34m $1 \033[0m" && sleep 1
}
red() {
echo -e "\033[31m $1 \033[0m" && sleep 1
}
function start_zk() {
zknum=$(ss -tunlp|grep -w ${zkPort}|wc -l)
kanum=$(ss -tunlp|grep -w ${kaPort}|wc -l)
if [ $zknum -eq 0 ] && [ $kanum -eq 0 ];then
nohup zookeeper-server-start.sh ${zkFile} > ${logsDir}/zk-`date +%y%m%d-%H%M`.log 2>&1 &
#tail -f zk-`date +%y%m%d-%H%M`.log
fi
while true; do
zknum=$(ss -tunlp|grep -w ${zkPort}|wc -l)
if [ "$zknum" = "0" ]; then
blue "The zookeeper process is starting, it may take some time, please wait patiently..."
sleep 1
else
r
kafka 启停脚本
最新推荐文章于 2024-01-23 15:59:46 发布