Linux配置elasticsearch开机自启

脚本:

java 复制代码
vi /etc/init.d/elasticsearch

脚本内容: ES_HOME的路径替换为自己的

java 复制代码
#!/bin/bash
#chkconfig: 2345 80 90
#description: elasticsearch
export ES_HOME=/usr/local/elasticsearch-8.8.0
 
case "$1" in
start)
    su es<<!
    cd $ES_HOME
    ./bin/elasticsearch -d -p pid
!
    echo "elasticsearch startup"
    ;;  
stop)
    kill -9 `cat $ES_HOME/pid`
    echo "elasticsearch stopped"
    ;;  
restart)
    kill -9 `cat $ES_HOME/pid`
    echo "elasticsearch stopped"
    su es<<!
    cd $ES_HOME
    ./bin/elasticsearch -d -p pid
!
    echo "elasticsearch startup"
    ;;  
*)
    echo "start|stop|restart"
    ;;  
esac
exit $?

赋权

java 复制代码
chmod 777 /etc/init.d/elasticsearch

注册服务

java 复制代码
chkconfig --add elasticsearch

开机自启

java 复制代码
chkconfig elasticsearch on  
systemctl enable elasticsearch

操作命令

java 复制代码
systemctl start elasticsearch     	 # 【启动服务】
systemctl stop elasticsearch        # 【停止服务】
systemctl restart elasticsearch         # 【重启服务】
相关推荐
chlk12318 小时前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑18 小时前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件19 小时前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号1 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash1 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
Elasticsearch2 天前
如何使用 Agent Builder 排查 Kubernetes Pod 重启和 OOMKilled 事件
elasticsearch
哈基咪怎么可能是AI2 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行2 天前
Linux和window共享文件夹
linux
Elasticsearch3 天前
通用表达式语言 ( CEL ): CEL 输入如何改进 Elastic Agent 集成中的数据收集
elasticsearch
木心月转码ing3 天前
WSL+Cpp开发环境配置
linux