启动zookeeper服务

  1. #!/bin/bash
  2. case $1 in
  3. "start"){
  4. for i in taizhou101 taizhou102 taizhou103
  5. do
  6. echo "------------- $i -------------"
  7. ssh $i "/opt/apps/zookeeper/bin/zkServer.sh start"
  8. done
  9. };;
  10. "stop"){
  11. for i in taizhou101 taizhou102 taizhou103
  12. do
  13. echo "------------- $i -------------"
  14. ssh $i "/opt/apps/zookeeper/bin/zkServer.sh stop"
  15. done
  16. };;
  17. "status"){
  18. for i in taizhou101 taizhou102 taizhou103
  19. do
  20. echo "------------- $i -------------"
  21. ssh $i "/opt/apps/zookeeper/bin/zkServer.sh status"
  22. done
  23. };;
  24. esac

启动Flume

  1. #!/bin/bash
  2. FLUME_HOME=/opt/apps/flume
  3. case $1 in
  4. "stop"){
  5. echo " --------停止 $2 agent-------"
  6. ps -ef | grep agent-$2 | grep -v grep |awk '{print $2}' | xargs -n1 kill -9
  7. }
  8. ;;
  9. "restart"){
  10. echo " --------停止 $2 agent-------"
  11. ps -ef | grep agent-$2 | grep -v grep |awk '{print $2}' | xargs -n1 kill -9
  12. echo " --------开始 $2 agent-------"
  13. nohup $FLUME_HOME/bin/flume-ng agent --name agent-$2 --conf-file $FLUME_HOME/conf/vehicle/$2.conf -Dflume.taizhou.logger=INFO >$FLUME_HOME/logs/$2.log 2>&1 &
  14. }
  15. ;;
  16. "startAll"){
  17. for file_name in tz-vehicle-alarm tz-vehicle-drivemotor tz-vehicle-extreme tz-vehicle-location tz-vehicle-realtime tz-vehicle-subsystemtemperature tz-vehicle-subsystemvoltage tz-vehicle-vehicle
  18. do
  19. echo " --------开始 $file_name agent-------"
  20. nohup $FLUME_HOME/bin/flume-ng agent --name agent-${file_name} --conf-file $FLUME_HOME/conf/vehicle/${file_name}.conf -Dflume.taizhou.logger=INFO >$FLUME_HOME/logs/${file_name}.log 2>&1 &
  21. done
  22. }
  23. ;;
  24. "stopAll"){
  25. for file_name in tz-vehicle-alarm tz-vehicle-drivemotor tz-vehicle-extreme tz-vehicle-location tz-vehicle-realtime tz-vehicle-subsystemtemperature tz-vehicle-subsystemvoltage tz-vehicle-vehicle
  26. do
  27. echo " --------关闭 $file_name agent-------"
  28. ps -ef | grep agent-$file_name | grep -v grep |awk '{print $2}' | xargs -n1 kill -9
  29. done
  30. }
  31. ;;
  32. "status"){
  33. ps -ef|grep agent-$2|grep -v grep |awk '{print $2}'
  34. }
  35. ;;
  36. "statusAll"){
  37. echo "process PID n"
  38. i=1
  39. for file_name in tz-vehicle-alarm tz-vehicle-drivemotor tz-vehicle-extreme tz-vehicle-location tz-vehicle-realtime tz-vehicle-subsystemtemperature tz-vehicle-subsystemvoltage tz-vehicle-vehicle
  40. do
  41. cmd=` ps -ef|grep agent-$file_name|grep -v grep |awk '{print $2}'`
  42. echo "${file_name} $cmd $i"
  43. i=$[$i+1]
  44. done
  45. }
  46. ;;
  47. *)
  48. echo Invalid Args!
  49. echo 'Usage:stop tz-vehicle-alarm |restart tz-vehicle-alarm | status tz-vehicle-alarm | startAll | stopAll| statusAll'
  50. ;;
  51. esac

启动kafka集群

  1. #! /bin/bash
  2. case $1 in
  3. "start"){
  4. for i in taizhou101 taizhou102 taizhou103
  5. do
  6. echo " --------启动 $i Kafka-------"
  7. ssh $i "/opt/apps/kafka/bin/kafka-server-start.sh -daemon /opt/apps/kafka/config/server.properties "
  8. done
  9. };;
  10. "stop"){
  11. for i in taizhou101 taizhou102 taizhou103
  12. do
  13. echo " --------停止 $i Kafka-------"
  14. ssh $i "/opt/apps/kafka/bin/kafka-server-stop.sh stop"
  15. done
  16. };;
  17. esac