zoukankan      html  css  js  c++  java
  • Centos8.2安装Elasticsearch-7.11.1

    1. 下载elasticsearch

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.1-linux-x86_64.tar.gz
    tar -xzvf elasticsearch-7.11.1-linux-x86_64.tar.gz
    cd elasticsearch-7.11.1
    ./bin/elasticsearch

    2.下载kibana(配套UI)

    curl -L -O https://artifacts.elastic.co/downloads/kibana/kibana-7.11.1-linux-x86_64.tar.gz
    tar xzvf kibana-7.11.1-linux-x86_64.tar.gz
    cd kibana-7.11.1-linux-x86_64/
    ./bin/kibana

    都是开箱即用,建议手动移动目录到/usr/local/下

    3.启动elasticsearch

       3.1 创建专用用户组和用户,root无法启动

    groupadd es
    useradd esuser -g es
    passwd esuser

      3.2更改文件夹及内部文件的所属用户及组

    chown -R esuser:es /usr/local/elasticsearch-7.11.1

      3.3 切换用户 到esuser

    su esuser

      3.4 elasticsearch 配置

    vim /usr/local/elasticsearch-7.11.1/config/elasticsearch.yml

    添加两行,注意:冒号后面要带一个空格

    network.host: 0.0.0.0

    cluster.initial_master_nodes: ["node-1"]

      3.5 设置elasticsearch用户拥有的内存权限,至少需要262144

    su root
    vim /etc/sysctl.conf

     末尾添加一行:
     vm.max_map_count=262144

    #立即生效
    /sbin/sysctl -p

     3.6 jvm内存调小一些

    vim /usr/local/elasticsearch-7.11.1/config/jvm.options

    新增两行,将内存调整至512m

      -Xms512m
      -Xmx512m

    3.7 自定义管理脚本

    #!/bin/bash
    
    export ES_HOME=/usr/local/elasticsearch-7.11.1
    case $1 in
            start)
                    su esuser<<!        
                    cd $ES_HOME
                    ./bin/elasticsearch -d -p pid
                    exit
    !
                    echo "elasticsearch is started"
                    ;;
            stop)
                    pid=`cat $ES_HOME/pid`
                    kill -9 $pid
                    echo "elasticsearch is stopped"
                    ;;
            restart)
                    pid=`cat $ES_HOME/pid`
                    kill -9 $pid
                    echo "elasticsearch is stopped"
                    sleep 1
                    su esuser<<!    
                    cd $ES_HOME
                    ./bin/elasticsearch -d -p pid
                    exit
    !
                    echo "elasticsearch is started"
            ;;
        *)
            echo "start|stop|restart"
            ;;  
    esac
    exit 0
    #赋予执行权限
    chmod +x elasticsearch

     命令:

    #启动
    /etc/init.d/elasticsearch start
    #停止
    /etc/init.d/elasticsearch stop
    #重启
    /etc/init.d/elasticsearch restart

     4.安装ik分词器

    cd /usr/local/elasticsearch-7.11.1/plugins

      4.1 新建一个ik目录

      4.2 下载与ES版本对于的分词器压缩包,下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases

      4.3 解压压缩包到ik目录

      4.4 重启ES

     5.ElasticSearch设置用户名密码访问

    vim /usr/local/elasticsearch-7.11.1/config/elasticsearch.yml

     添加如下:

    http.cors.enabled: true
    http.cors.allow-origin: "*"
    http.cors.allow-headers: Authorization
    xpack.security.enabled: true
    xpack.license.self_generated.type: basic
    xpack.security.transport.ssl.enabled: true
     

    作者: jamesbing
    提示: 欢迎转载,但是必须保留本文的署名 jamesbing (包含链接)
  • 相关阅读:
    (转)交换两个变量的值,不使用第三个变量的四种法方
    Java权威编码规范
    Git的安装和设置
    ActiveMQ简单入门
    JMS术语
    求助 WPF ListViewItem样式问题
    初步探讨WPF的ListView控件(涉及模板、查找子控件)
    圆角button
    用Inno Setup来解决.NetFramework安装问题
    [!!!!!]Inno Setup教程-常见问题解答
  • 原文地址:https://www.cnblogs.com/gaobing/p/14419310.html
Copyright © 2011-2022 走看看