es集群一键安装、启动、停止脚本

本文提供了一键安装、启动和停止Elasticsearch集群的脚本介绍,帮助用户便捷地管理ES集群。
摘要由CSDN通过智能技术生成

 es集群一键安装脚本

#!/bin/bash
#配置ES的安装目录 修改的地方1 脚本可以自己创建
currentTime=$(date '+%Y-%m-%d %H:%M:%S')
echo -e "请输入es的安装目录,不存在脚本自动创建,最后一个/不要写 /bigdata/install"
read esinstallpath

#创建ES安装的目录
if [ ! -d $esinstallpath ]; then
   mkdir -p $esinstallpath
fi 
if [ ! -d $esinstallpath ]; then
  echo "创建目录$esinstallpath失败!请检查目录是否有权限"
  exit
fi

#解压tar包
currentdir=$(cd $(dirname $0); pwd)
ls | grep 'elasticsearch-.*[gz]$'
if [ $? -ne 0 ]; then
   #当前目录没有es的压缩包
   echo "在$currentdir下没有发现elasticsearch-*.tar.gz,请自行上传!"
   exit
else
   #解压
   tar -zxvf $currentdir/$(ls | grep 'elasticsearch-.*[gz]$') -C $esinstallpath
fi

esbanben=`ls $esinstallpath| grep 'elasticsearch-.*'`

#PATH设置
#末行插入
echo "">>~/.bash_profile
echo "#ES $currentTime">>~/.bash_profile
echo "export ES_HOME=$esinstallpath/$esbanben">>~/.bash_profile
echo 'exp
以下是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已经成功启动的消息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值