注:本文出自博主 Chloneda:個人博客 | 博客園 | Github | Gitee | 知乎
本文源鏈接:https://www.cnblogs.com/chloneda/p/es-shell.html
構建Elasticsearch啟動腳本 start_es.sh。
#!/bin/bash
export ES_HOME=xxx
su elastic -c "sh ${ES_HOME}/bin/elasticsearch -d -p ${ES_HOME}/pid"
參數說明:
- su:登錄用戶。
- elastic:部署Elasticsearch用戶,避免root用戶而無法啟動。
- c:c參數后跟具體命令。
- d:Elasticsearch作為守護線程后台啟動。
- p:指定線程ID文件,需要新建。
構建Elasticsearch停止腳本 stop_es.sh。
#!/bin/bash
export ES_HOME=xxx
kill `cat ${ES_HOME}/pid`