kafka.sh
port=9092 # 根据端口号去查询对应的PID pid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{print $1}'); # 杀掉对应的进程 如果PID不存在,即该端口没有开启,则不执行 if [ -n "$pid" ]; then kill -9 $pid; fi port=9093 # 根据端口号去查询对应的PID pid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{print $1}'); # 杀掉对应的进程 如果PID不存在,即该端口没有开启,则不执行 if [ -n "$pid" ]; then kill -9 $pid; fi port=9094 # 根据端口号去查询对应的PID pid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{print $1}'); # 杀掉对应的进程 如果PID不存在,即该端口没有开启,则不执行 if [ -n "$pid" ]; then kill -9 $pid; fi nohup /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server_1.properties > /tmp/kafka1.log 2>&1 & nohup /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server_2.properties > /tmp/kafka2.log 2>&1 & nohup /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server_3.properties > /tmp/kafka3.log 2>&1 &
zookeeper.sh
/usr/local/zookeeper/bin/zkServer.sh restart /usr/local/zookeeper/conf/zoo1.cfg /usr/local/zookeeper/bin/zkServer.sh restart /usr/local/zookeeper/conf/zoo2.cfg /usr/local/zookeeper/bin/zkServer.sh restart /usr/local/zookeeper/conf/zoo3.cfg /usr/local/zookeeper/bin/zkServer.sh status /usr/local/zookeeper/conf/zoo1.cfg /usr/local/zookeeper/bin/zkServer.sh status /usr/local/zookeeper/conf/zoo2.cfg /usr/local/zookeeper/bin/zkServer.sh status /usr/local/zookeeper/conf/zoo3.cfg