- 一 在/etc/init.d目录下新建文件elasticsearch
#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
export JAVA_HOME=/usr/java/jdk1.8.0_221
export JAVA_BIN=/usr/java/jdk1.8.0_221/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
case "$1" in
start)
su elastic<<!
cd /usr/local/elasticsearch
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
stop)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
;;
restart)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
su elastic<<!
cd /usr/local/elasticsearch
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?
su elastic :因为elasticsearch不支持root直接启动 所以使用新创建的用户 elastic
- 二 保存退出,赋予执行权限
chmod +x elasticsearch
- 三 添加到开机启动任务
chkconfig --add elasticsearch
- 4、添加和删除服务并设置启动方式(chkconfig具体使用另行百度)
chkconfig --add elasticsearch
chkconfig --del elasticsearch
- 5、启动和关闭服务
service elasticsearch start
service elasticsearch stop
service elasticsearch restart
- 6、设置服务的启动方式
chkconfig elasticsearch on
chkconfig elasticsearch off
问题: 启动后发现自动停止.
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
说是最大虚拟内存区域vm.max_map_count [65530]太低,至少增加[262144]
然后可以执行以下指令
sysctl -w vm.max_map_count=262144
文章评论