opt_dir=/home/opt if [ ! -d "$opt_dir" ]; then mkdir "$opt_dir" fi
echo "--------安装elasticsearch-------" if [ ! -d "$elk_dir" ]; then mkdir "$elk_dir" fi es_mkdir_cmd="mkdir ${elk_dir}" es_config="${elk_dir}/elasticsearch-7.9.1/config/" tar -zxf elasticsearch-7.9.1-linux-x86_64.tar.gz -C $elk_dir adduser="adduser elkusr" chownes="chown elkusr:elkusr -R ${elk_dir}/elasticsearch-7.9.1" $adduser $chownes
sed -i "s/-Xms2g/-Xms${es_jvm}/g" ${es_config}jvm.options sed -i "s/-Xmx2g/-Xmx${es_jvm}/g" ${es_config}jvm.options echo "vm.max_map_count=655360" >> /etc/sysctl.conf sysctl -p #该设置需要重启方可生效,解决max file descriptors [4096] for elasticsearch process is too low的问题 echo "* soft nofile 65536" >> /etc/security/limits.conf echo "* hard nofile 131072" >> /etc/security/limits.conf echo "* soft nproc 2048" >> /etc/security/limits.conf echo "* hard nproc 4096" >> /etc/security/limits.conf #解决max number of threads [1024] for user [es] is too low, increase to at least [2048] thread_conf=$(find /etc/security/limits.d/*.conf | head -n 1) echo " * soft nproc 4096" >> ${thread_conf} echo " * hard nproc 4096" >> ${thread_conf} echo "--------elasticsearch安装成功-------" exit 0