---
title: "Elasticsearch启动、停止脚本"
author: "kfcman"
date: "2020-07-04T15:00:19Z"
tags: []
categories: ["开源软件"]
slug: "elasticsearch"
draft: false
lastmod: "2020-07-04T15:00:19Z"
id: 2515457
url: "https://kfcman.iteye.com/blog/2515457"
---

构建Elasticsearch启动脚本 start\_es.sh。

1. #!/bin/bash
2. export ES\_HOME=xxx
3. 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。

1. #!/bin/bash
2. export ES\_HOME=xxx
3. kill \`cat ${ES\_HOME}/pid\`

 

转载于:https://www.cnblogs.com/chloneda/p/es-shell.html