栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 云计算 > 云平台

ElasticSearch 7.X系列之:Shell自动安装配置Elasticseach,设置开机自启动

云平台 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ElasticSearch 7.X系列之:Shell自动安装配置Elasticseach,设置开机自启动

#获取内存信息
echo  -e "33[36m ---Start getting memory information... 33[0m"
mem_info=$(free -m | awk '/Mem/ {printf "%.0fn",$2/1024/2 }')
if [ -z "$mem_info" ];then
    echo "      Did not get the memory info,aborting"
        exit 1
else
    if [ "$mem_info"  -ge 31 ];then
        $mem_info = 31
    fi
    echo "      Memory information acquistion completed!"
fi
#检查资源限制配置文件
echo -e "33[36m ---Modify the resource limit profile:/etc/security/limits.conf... 33[0m"
limits_conf=$(grep nofile /etc/security/limits.conf | grep -v "^#")
if [ -z "$limits_conf" ];then
    echo "* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096"  >> /etc/security/limits.conf
    echo "      resource limit profile:/etc/security/limits.conf modified!"
#else
   #资源配置文件之前修改过
   # echo "资源限制配置文件/etc/security/limits.conf之前已经修改完成,本次退出修改。"
fi
#检查系统控制文件
echo  -e "33[36m ---Modify system control file:/etc/sysctl.conf... 33[0m"
sysctl_conf1=$(grep "vm.max_map_count" /etc/sysctl.conf)
sysctl_conf2=$(grep "vm.rmem_default" /etc/sysctl.conf)
if [ -z "$sysctl_conf1" ];then
    echo "vm.max_map_count=655360" >> /etc/sysctl.conf
    sysctl -p    >>  /dev/null
        echo "      System control file:/etc/sysctl.conf modified!"
fi
if [ -z "$sysctl_conf2" ];then
    echo "net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216" >> /etc/sysctl.conf
    sysctl -p    >>  /dev/null
        echo "      System control file:/etc/sysctl.conf modified!"
fi
#修改elasticsearch配置文件
echo -e  "33[36m ---Modify elasticsearch configuration file... 33[0m"
jvm_info=$(grep "^-Xms" $log_path/elasticsearch/config/jvm.options)
jvm_mem=$(echo ${jvm_info:4:1})
if [ "$jvm_mem" != "$mem_info" ];then
    sed -i 's/-Xms1g/-Xms'"$mem_info"'g/' $log_path/elasticsearch/config/jvm.options
    sed -i 's/-Xmx1g/-Xmx'"$mem_info"'g/' $log_path/elasticsearch/config/jvm.options
        echo "      jvm.options configuration file modified!"
fi
#检查是否有esuser普通用户
echo -e "33[36m ---Useradd: esuser 33[0m"
es_proc=$(ps -aux | grep elasticsearch | grep -v grep | wc -l)
if [ $es_proc == 0 ];then
    user=$(grep -w esuser /etc/passwd | awk -F":" '{print $1}')
    if [ "$user" == "" ];then
        groupadd esuser
        useradd -g esuser esuser
    fi
fi
#添加elasticsearch到开机自启动
echo -e  "33[36m ---Add es boot--- 33[0m"
chkconfig esstart
if [  $? -ne 0 ] || [ -z "$(grep -e $log_path /etc/init.d/esstart)"  ];then
    echo "#!/bin/sh
#chkconfig: 2345 80 90
#description:auto_run
su - esuser< /etc/init.d/esstart
    chmod +x /etc/init.d/esstart
    chkconfig --add /etc/init.d/esstart
    echo "      Es boot compeleted!"
fi
#安装jdk
path=$(dirname `pwd`)"/tools"
cd $path
#rpm_array=find . -name ".*rpm"|sed '1d'
rpm_array=$(find . -name "*.rpm")
for i in $rpm_array
do
        #rpm -ivh $i
        rpm -ivh jre-8u211-linux-x64.rpm
done
echo -e "33[31m in:" $path " All rpm has benn installed! 33[0m"

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/895746.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号