• elasticsearch集群部署


    1.elasticsearch部署机器列表

    
    192.168.10.1
    192.168.10.2
    192.168.10.3
    
    

    2.下载elasticsearch安装包

    
    下载地址 :https://elasticsearch.cn/download/
    
    本次安装下载的是7.6tar包
    
    本次安装包是自己下载下来进行配置后的最终安装文件,可以直接使用
    链接: https://pan.baidu.com/s/1syFE_YK9XLXKOw-QT0hoPw 提取码: y86f 复制这段内容后打开百度网盘手机App,操作更方便哦
    

    3.添加 /etc/hosts

    
    ##elastic
    192.168.10.1 sz-core-k-dyy-6 elasticsearch01
    192.168.10.2 sz-core-k-dyy-5 elasticsearch02
    192.168.10.3 sz-core-k-dyy-7 elasticsearch03
    
    

    4.elasticsearch集群节点安装jdk

    5.配置安装

    将https://pan.baidu.com/s/1syFE_YK9XLXKOw-QT0hoPw文件下载下来后放在集群各节点/opt路径下
    执行以下脚本,3个master节点,6个数据节点

    192.168.10.1
    
    sh es_install.sh a 192.168.10.1 master
    sh es_install.sh b 192.168.10.1 data
    sh es_install.sh c 192.168.10.1 data
    
    192.168.10.2
    sh es_install.sh a 192.168.10.2 master
    sh es_install.sh b 192.168.10.2 data
    sh es_install.sh c 192.168.10.2 data
    
    192.168.10.3
    sh es_install.sh a 192.168.10.3 master
    sh es_install.sh b 192.168.10.3 data
    sh es_install.sh c 192.168.10.3 data
    
    

    es_install.sh 脚本内容如下,执行前根据自己实际目录进行修改

    #!/bin/bash
    #wget -P /tmp/ http://192.168.10.3:8080/es_install.sh
    #"输入三个参数 1: a/b/c 2: elasticsearch14 3: master/data"
    if [ -f /opt/elasticsearch76.tar.gz ];then
        echo "已有elasticsearch76.tar.gz文件"
    else
        echo "拉取es文件夹========================="
    #    wget -P /opt/ http://192.168.10.3:8080/elasticsearch76.gz
    fi
    
    
    
    function es_a(){
    esip=$1
    setmaster=$2
    node_a=`cat /etc/hosts |grep ${esip} |awk -F ' ' '{print $3}'`
    esips=`cat /etc/hosts |grep ${esip} |awk -F ' ' '{print $1}'`
    echo "${node_a}"
    cd /opt/
    tar -zxvf elasticsearch76.tar.gz
    rename -v elasticsearch76 elasticsearch76-a elasticsearch76
    
    chown -R elasticsearch:elasticsearch elasticsearch76-a
    
    sed -i 's/ip/'"${esips}"'/g' /opt/elasticsearch76-a/config/elasticsearch.yml
    sed -i 's/node.name: node01-a/node.name: '"${node_a}"'-a/g' /opt/elasticsearch76-a/config/elasticsearch.yml
    sed -i 's/node01/'"${node_a}"'/g' /opt/elasticsearch76-a/config/elasticsearch.yml
    sed -i 's/data-a/data-a/g' /opt/elasticsearch76-a/config/elasticsearch.yml
    
    if [ "${setmaster}" == "data" ];then
        sed -i 's/node.master: true/node.master: false/g' /opt/elasticsearch76-a/config/elasticsearch.yml
        sed -i 's/node.data: false/node.data: true/g' /opt/elasticsearch76-a/config/elasticsearch.yml
    fi
    
    if [ -d /data/esdata/data-a ];then
        echo "已有/data/esdata/data-a路径"
    else
        mkdir -p /data/esdata/data-a
        chown -R elasticsearch:elasticsearch /data/esdata
    fi
    
    if [ -d /data/eslogs/data-a ];then
        echo "已有/data/eslogs/data-a路径"
    else
        mkdir -p /data/eslogs/data-a
        chown -R elasticsearch:elasticsearch /data/eslogs
    fi
    }
    
    
    function es_b(){
    esip=$1
    setmaster=$2
    node_a=`cat /etc/hosts |grep ${esip} |awk -F ' ' '{print $3}'`
    esips=`cat /etc/hosts |grep ${esip} |awk -F ' ' '{print $1}'`
    echo "${node_a}"
    cd /opt/
    tar -zxvf elasticsearch76.tar.gz
    rename -v elasticsearch76 elasticsearch76-b elasticsearch76
    
    chown -R elasticsearch:elasticsearch elasticsearch76-b
    
    sed -i 's/ip/'"${esips}"'/g' /opt/elasticsearch76-b/config/elasticsearch.yml
    sed -i 's/node.name: node01-a/node.name: '"${node_a}"'-b/g' /opt/elasticsearch76-b/config/elasticsearch.yml
    sed -i 's/node01/'"${node_a}"'/g' /opt/elasticsearch76-b/config/elasticsearch.yml
    sed -i 's/data-a/data-b/g' /opt/elasticsearch76-b/config/elasticsearch.yml
    sed -i 's/http.port: 9200/http.port: 9201/g' /opt/elasticsearch76-b/config/elasticsearch.yml
    sed -i 's/transport.port: 9300/transport.port: 9301/g' /opt/elasticsearch76-b/config/elasticsearch.yml
    
    
    if [ "${setmaster}" == "data" ];then
        sed -i 's/node.master: true/node.master: false/g' /opt/elasticsearch76-b/config/elasticsearch.yml
        sed -i 's/node.data: false/node.data: true/g' /opt/elasticsearch76-b/config/elasticsearch.yml
    fi
    
    if [ -d /data/esdata/data-b ];then
        echo "已有/data/esdata/data-b路径"
    else
        mkdir -p /data/esdata/data-b
        chown -R elasticsearch:elasticsearch /data/esdata
    fi
    
    if [ -d /data/eslogs/data-b ];then
        echo "已有/data/eslogs/data-b路径"
    else
        mkdir -p /data/eslogs/data-b
        chown -R elasticsearch:elasticsearch /data/eslogs
    fi
    }
    
    
    function es_c(){
    esip=$1
    setmaster=$2
    node_a=`cat /etc/hosts |grep ${esip} |awk -F ' ' '{print $3}'`
    esips=`cat /etc/hosts |grep ${esip} |awk -F ' ' '{print $1}'`
    echo "${node_a}"
    cd /opt/
    tar -zxvf elasticsearch76.tar.gz
    rename -v elasticsearch76 elasticsearch76-c elasticsearch76
    
    chown -R elasticsearch:elasticsearch elasticsearch76-c
    
    sed -i 's/ip/'"${esips}"'/g' /opt/elasticsearch76-c/config/elasticsearch.yml
    sed -i 's/node.name: node01-a/node.name: '"${node_a}"'-c/g' /opt/elasticsearch76-c/config/elasticsearch.yml
    sed -i 's/node01/'"${node_a}"'/g' /opt/elasticsearch76-c/config/elasticsearch.yml
    sed -i 's/data-a/data-c/g' /opt/elasticsearch76-c/config/elasticsearch.yml
    sed -i 's/http.port: 9200/http.port: 9202/g' /opt/elasticsearch76-c/config/elasticsearch.yml
    sed -i 's/transport.port: 9300/transport.port: 9302/g' /opt/elasticsearch76-c/config/elasticsearch.yml
    
    if [ "${setmaster}" == "data" ];then
        sed -i 's/node.master: true/node.master: false/g' /opt/elasticsearch76-c/config/elasticsearch.yml
        sed -i 's/node.data: false/node.data: true/g' /opt/elasticsearch76-c/config/elasticsearch.yml
    fi
    
    if [ -d /data/esdata/data-c ];then
        echo "已有/data/esdata/data-c路径"
    else
        mkdir -p /data/esdata/data-c
        chown -R elasticsearch:elasticsearch /data/esdata
    fi
    
    if [ -d /data/eslogs/data-c ];then
        echo "已有/data/eslogs/data-c路径"
    else
        mkdir -p /data/eslogs/data-c
        chown -R elasticsearch:elasticsearch /data/eslogs
    fi
    }
    
    
    
    if [ "$1" == "a" ] && [ "$2" != "" ] && [ "$3" != "" ];then
        ip=$2
        bool=$3
        es_a ${ip} ${bool}
    elif [ "$1" == "b" ] && [ "$2" != "" ] && [ "$3" != "" ];then
        ip=$2
        bool=$3
        es_b ${ip} ${bool}
    elif [ "$1" == "c" ] && [ "$2" != "" ] && [ "$3" != "" ];then
        ip=$2
        bool=$3
        es_c ${ip} ${bool}
    else
        echo "输入三个参数 1: a/b/c 2: ip 3: master/data"
        exit
    fi
    
    
    

    6.启动命令

    必须切到elasticsearch用户下进行启动,先启动master节点之后在启动数据节点。

    
    su - elasticsearch
    
    cd /opt/elasticsearch76-a/bin/
    
    ./elasticsearch -d
    
    

    如果启动报错[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    则需要调整vm.max_map_count的值

    vim /etc/sysctl.conf
    
    vm.max_map_count=262144
    
    sysctl -p
    

    7.验证命令

    curl -s "http://192.168.10.1:9202/_cluster/health?pretty"
    
  • 相关阅读:
    NSPredicate
    label 下划线加自动换行
    【搬运】快速增加文档注释
    NSSortDescriptor 数组排序
    【搬运】打开模拟器沙盒目录
    NSTimer 详解
    Android打开外部DB文件
    图片压缩与缓存
    StartService与BindService
    Android发送通知栏通知
  • 原文地址:https://www.cnblogs.com/whiteY/p/16671663.html
Copyright © 2020-2023  润新知