#!/bin/bash
ES_VERSION=7.17.5
UBUNTU_URL="https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/apt/pool/main/e/elasticsearch/elasticsearch-${ES_VERSION}-amd64.deb"
RHEL_URL="https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/${ES_VERSION}/elasticsearch-${ES_VERSION}-x86_64.rpm"
LOCAL_IP=`hostname -I|awk '{print $1}'`
. /etc/os-release
color () {
RES_COL=60
MOVE_TO_COL="echo -en \\033[${RES_COL}G"
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_WARNING="echo -en \\033[1;33m"
SETCOLOR_NORMAL="echo -en \E[0m"
echo -n "$1" && $MOVE_TO_COL
echo -n "["
if [ $2 = "success" -o $2 = "0" ] ;then
${SETCOLOR_SUCCESS}
echo -n $" OK "
elif [ $2 = "failure" -o $2 = "1" ] ;then
${SETCOLOR_FAILURE}
echo -n $"FAILED"
else
${SETCOLOR_WARNING}
echo -n $"WARNING"
fi
${SETCOLOR_NORMAL}
echo -n "]"
echo
}
check_mem () {
MEM_TOTAL=`head -n1 /proc/meminfo |awk '{print $2}'`
if [ ${MEM_TOTAL} -lt 1997072 ];then
color '内存低于2G,安装失败!' 1
exit
elif [ ${MEM_TOTAL} -le 2997072 ];then
color '内存不足3G,建议调整内存大小!' 2
else
return
fi
}
install_es() {
if [ $ID = "centos" -o $ID = "rocky" ];then
wget -P /usr/local/src/ $RHEL_URL || { color "下载失败!" 1 ;exit ; }
yum -y install /usr/local/src/${RHEL_URL##*/}
elif [ $ID = "ubuntu" ];then
wget -P /usr/local/src/ $UBUNTU_URL || { color "下载失败!" 1 ;exit ; }
dpkg -i /usr/local/src/${UBUNTU_URL##*/}
else
color "不支持此操作系统!" 1
exit
fi
[ $? -eq 0 ] || { color '安装软件包失败,退出!' 1; exit; }
}
config_es () {
cp /etc/elasticsearch/elasticsearch.yml{,.bak}
cat >> /etc/elasticsearch/elasticsearch.yml <<EOF
node.name: node-1
network.host: 0.0.0.0
discovery.seed_hosts: ["$LOCAL_IP"]
cluster.initial_master_nodes: ["node-1"]
EOF
mkdir -p /etc/systemd/system/elasticsearch.service.d/
cat > /etc/systemd/system/elasticsearch.service.d/override.conf <<EOF
[Service]
LimitMEMLOCK=infinity
EOF
systemctl daemon-reload
systemctl enable elasticsearch.service
}
prepare_es() {
echo "vm.max_map_count = 262144" >> /etc/sysctl.conf
sysctl -p
}
start_es(){
systemctl start elasticsearch || { color "启动失败!" 1;exit 1; }
sleep 3
curl http://127.0.0.1:9200 && color "安装成功" 0 || { color "安装失败!" 1; exit 1; }
echo -e "请访问链接: \E[32;1mhttp://`hostname -I|awk '{print $1}'`:9200/\E[0m"
}
check_mem
install_es
config_es
prepare_es
start_es
2、Elasticsearch单节点安装脚本
原创超人不姓超 博主文章分类:ELK+Filebeat ©著作权
文章标签 Elasticsearch单节点安脚本 文章分类 运维 yyds干货盘点
-
2.Elasticsearch单节点安装脚本
Elasticsearch单节点安装脚本
elasticsearch elastic 安装失败 -
安装Elasticsearch(单节点Linux环境)
1 安装包下载1)Elasticsearch官网: https://www.elastic.co
elasticsearch hadoop root用户 -
redis学习2---单节点安装配置(脚本)
redis学习2---单节点安装配置(脚本)
redis shell -
监控mapGetters取到的数据
智能交通监控系统观后日志 6.24)有幸到某公司参观其智能交通监控系统,因而对智能交通系统有了一点感性的认识。今天花一些时间总结一下。 一、系统组成。 该系统主要用于交通路口车辆监控,是一个典型的智能监控系统。 图1&nb
监控mapGetters取到的数据 前端 数据库 后端 ViewUI