ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

CentOS7.9-ES7 部署,开机自启

2022-02-19 19:04:22  阅读:274  来源: 互联网

标签:ES7 7.11 CentOS7.9 自启 elasticsearch usr local es logs


CentOS7.9-ES7 部署

  1. 下载 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.2-linux-x86_64.tar.gz

  2. 解压

    tar -zxvf elasticsearch-7.11.2-linux-x86_64.tar.gz
    
  3. 移动目录

    mv elasticsearch-7.11.2 /usr/local/
    
  4. 修改es相关配置文件(重点配置)

    # vim config/elasticsearch.yml
    # 集群名
    cluster.name: es-cluster
    # 节点名
    node.name: node-master
    # 数据存放位置
    path.data: /usr/local/elasticsearch-7.11.2/data
    # 日志存放位置
    path.logs: /usr/local/elasticsearch-7.11.2/logs
    # bind 地址,0 表示任意
    network.host: 0.0.0.0
    # 默认初始 master 节点
    cluster.initial_master_nodes: ["node-master"]
    
  5. 修改 jvm 相关配置

    # 重点配置堆内存大小, 本人为虚拟机只给 512m,请结合实际情况调优
    -Xms512m
    -Xmx512m
    
  6. 因为 es 不允许使用 root, 所以添加 es 用户

    useradd esuser
    chown -R esuser:esuser /usr/local/elasticsearch-7.11.2/
    
  7. 运行时可能出现以下错误

    ERROR: [2] bootstrap checks failed
    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
    [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    ERROR: Elasticsearch did not exit normally - check the logs at /usr/local/elasticsearch-7.11.2/logs/es-cluster.log
    
  8. 修改限制

    vim /etc/security/limits.conf
    # 输入如下参数
    * soft nofile 65536
    * hard nofile 131072
    * soft nproc 2048
    * hard nproc 4096
    
  9. 修改系统设置

    vim /etc/sysctl.conf
    vm.max_map_count=262145
    
    sysctl -p
    
  10. 配置开机自启

    vim /etc/init.d/elasticsearch
    
    #!/bin/bash
    #chkconfig: 345 63 37
    #description: elasticsearch
    #processname: elasticsearch-7.11.2
    
    export ES_HOME=/usr/local/elasticsearch-7.11.2
    
    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 777 elasticsearch
    chkconfig --add elasticsearch
    chkconfig elasticsearch on
    

标签:ES7,7.11,CentOS7.9,自启,elasticsearch,usr,local,es,logs
来源: https://www.cnblogs.com/thomas-fan/p/15913350.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有