elasticsearch一键启动脚本
时间: 2023-09-30 16:11:19 浏览: 56
以下是elasticsearch一键启动脚本的示例:
#!/bin/bash
# Elasticsearch one-click start script
# Define the Elasticsearch home directory
ES_HOME=/path/to/elasticsearch
# Define the Elasticsearch configuration file
ES_CONFIG_FILE=$ES_HOME/config/elasticsearch.yml
# Define the Elasticsearch log directory
ES_LOG_DIR=$ES_HOME/logs
# Define the Elasticsearch data directory
ES_DATA_DIR=$ES_HOME/data
# Define the Elasticsearch process ID file
ES_PID_FILE=$ES_HOME/elasticsearch.pid
# Check if Elasticsearch is already running
if [ -f $ES_PID_FILE ]; then
echo "Elasticsearch is already running. Exiting."
exit 1
fi
# Start Elasticsearch with the specified configuration file and log directory
$ES_HOME/bin/elasticsearch -d -p $ES_PID_FILE --quiet -Epath.logs=$ES_LOG_DIR -Epath.data=$ES_DATA_DIR -Epath.conf=$ES_CONFIG_FILE
# Check if Elasticsearch started successfully
if [ $? -eq 0 ]; then
echo "Elasticsearch started successfully."
else
echo "Failed to start Elasticsearch."
fi
# Wait for Elasticsearch to start
sleep 10
# Check if Elasticsearch is running
if pgrep -f "$ES_HOME/bin/elasticsearch" > /dev/null; then
echo "Elasticsearch is running."
else
echo "Failed to start Elasticsearch."
fi
这个脚本将启动Elasticsearch,并使用指定的配置文件、日志目录和数据目录。它还检查Elasticsearch是否已经在运行,并等待10秒钟以确保Elasticsearch已经启动。如果Elasticsearch启动成功,则脚本会输出Elasticsearch已经成功启动的消息。