Ambari开机自启脚本startHDP:
#!/bin/bash
# Name:
# DESC: start HDP instance
# Path:
# chkconfig: 2345 55 25
host=$(hostname)
_STARTHDP(){
curl -s -i -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Start all
services","operation_level":{"level":"CLUSTER","cluster_name":"ULTIWILL_HDP"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' http://hdp05.ultiwill.com:8080/api/v1/clusters/ULTIWILL_HDP/services}
AMBARI_RUNNING=`jps|grep AmbariServer`
if [ -n "${AMBARI_RUNNING}" ];then
time=$( date '+%Y-%m-%d %H:%M:%S')
echo "$@ $host $time HDP " >> /root/powerOn.log
_STARTHDP >> /root/powerOn.log
else
sleep 60
time=$( date '+%Y-%m-%d %H:%M:%S')
echo "$@ sleep $host $time HDP " >> /root/powerOn.log
_STARTHDP >> /root/powerOn.log
fi
Elasticsearch开机自启脚本startES:
#!/bin/bash
#
# chkconfig: 2345 55 25
# description:start ES instance
host=$(hostname)
time=$( date '+%Y-%m-%d %H:%M:%S')
echo "$@ $host $time elasticsearch-6.1.0" >> /root/powerOn.log
su - elastic -c '/usr/local/elasticsearch-6.1.0/bin/elasticsearch -d'
time=$( date '+%Y-%m-%d %H:%M:%S')
echo "$@ $host $time cerebro " >> /root/powerOn.log
su - elastic -c "nohup /usr/local/cerebro-0.7.2/bin/cerebro >/dev/null &"
time=$( date '+%Y-%m-%d %H:%M:%S')
echo "$@ $host $time kibana" >> /root/powerOn.log
su - elastic -c "nohup /usr/local/kibana-6.1.0-linux-x86_64/bin/kibana >/dev/null &"
time=$( date '+%Y-%m-%d %H:%M:%S')
echo "$@ $host $time kafka-manager" >> /root/powerOn.log
num=$(netstat -ntlp |grep 9997 |wc -l)
RUNNING_FILE=/usr/local/kafka-manager-1.3.3.7/RUNNING_PID
if [[ $num -eq 0 ]];then
if [ -f $RUNNING_FILE ];then
rm $RUNNING_FILE
fi
nohup /usr/local/kafka-manager-1.3.3.7/bin/kafka-manager -Dconfig.file=/usr/local/kafka-manager-1.3.3.7/conf/application.conf -Dhttp.port=9997 > /dev/null 2>&1 &
fi
springboot项目定时任务启动:
#*/5 * * * * root /opt/workspace/libra-service-1.1.0/sbin/startLibra.sh
#!/bin/bash
export PROJECT_HOME=$(dirname "$(cd "$(dirname "$0")"; pwd -P)")
ps=$(jps | grep 'libra-service')
if [ -z "${ps}" ];then
su - ultiwill -c "sh ${PROJECT_HOME}/sbin/stop.sh "
su - ultiwill -c "sh ${PROJECT_HOME}/sbin/start.sh "
fi
exit 0