开机启动服务(ActiveMQ,ElasticSearch,Zookeeper)
将所有需要启动的服务都写到同一个文件中,并设置为开机启动项
编辑 /opt/startup_all.sh
<pre>
! /bin/sh
chkconfig:2345 80 90
description:start all service
RETVAL=0
start(){
sudo -iu meihaohui /opt/apache-activemq-5.14.5/bin/activemq start
sudo -iu meihaohui /opt/zookeeper-3.4.9/bin/zkServer.sh start
sudo -iu meihaohui /opt/elasticsearch-5.4.0/bin/elasticsearch -d
RETVAL=0
}
stop(){
sudo -iu meihaohui /opt/apache-activemq-5.14.5/bin/activemq stop
sudo -iu meihaohui /opt/zookeeper-3.4.9/bin/zkServer.sh stop
kill elastisearch
echo "please kill the elastic search service by yourself!"
RETVAL=0
}
restart(){
stop
sudo -iu meihaohui /opt/apache-activemq-5.14.5/bin/activemq start
sudo -iu meihaohui /opt/zookeeper-3.4.9/bin/zkServer.sh start
RETVAL=0
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
RETVAL=3
esac
exit $RETVAL
</pre>
创建链接到etc/init.d目录下
设置开机项
<pre>
ln -s /opt/startup_all.sh /etc/init.d/allservice
cd /etc/init.d
chkconfig --add allservice
</pre>
对于测试服务器来说为了方便调试,简单粗暴的配置,把不需要的服务都关闭掉了:
<pre>
chkconfig --level 2345 crond off
chkconfig --level 2345 iptables off
</pre>
find: 路径必须在表达式之前
执行命令 find . -depth 1 -iname ".jar" 时报错
提示了这个错误,以为是路径的位置问题,实际是被这个提示误导了
将-depth 改为maxdepth 即可