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