• Centos7 中安装Elasticsearch


    1.下载安装包

    1.1 下载elasticsearch 7.13.3

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.13.3-linux-x86_64.tar.gz

    1.2 解压文件

    tar -zxf elasticsearch-7.13.3-linux-x86_64.tar.gz

    1.3 将解压文件移动至所要存储的文件目录下

    mv elasticsearch-7.13.3 /data/elasticsearch

    2.创建普通用户

    为了安全问题,es不允许root用户直接运行,新建用户

    2.1添加用户

    #添加用户
    adduser es
    #添加密码
    passwd es
    1234567890
    

    2.2 将解压后的es目录给es用户授权

    chown -R es:es /data/elasticsearch

    2.3 在es用户下创建elasticsearch的数据和日志目录

    mkdir elasticsearch
    cd elasticsearch
    mkdir  data
    mkdir logs
    

    3. 修改eleasticsearch.yml文件

    3.1 进入到es的config目录下

    cd /data/elasticsearch/config/

    3.2 修改yml文件

    vi elasticsearch.yml
    
    # 集群名
    cluster.name: my-es
    # 节点名
    node.name: node-2
    # 是否有资格主节点
    node.master: true
    # 是否存储数据
    node.data: true
    # 最大集群节点数
    node.max_local_storage_nodes: 5
    # ip地址
    network.host: 0.0.0.0
    # es的httpo的端口
    http.port: 9200
    # 内部节点之间沟通端口
    transport.tcp.port: 9700
    # 节点发现
    discovery.zen.ping.unicast.hosts: ["192.168.12.46:9700", "192.168.12.3:9700", "192.168.12.2:9700", "192.168.12.45:9700", "192.168.12.47:9700"]
    # 初始化新的集群是需要此配置来选举新的master
    # cluster.initial_master_nodes: ["node-1","node-2","node-3","node-4","node-5"]
    cluster.initial_master_nodes: node-1
    # es保存数据及日志的路径
    path.data: /home/es/elasticsearch/data
    path.logs: /home/es/elasticsearch/logs
    

    4. 修改配置文件

    新创建的es用户最大可创建的文件数太小,最大虚拟内存太小,切换到root用户,进行一下配置

    4.1 切换到root用户 并 进行limits.conf文件配置

    # 切换root用户
    su
    
    # 配置最小文件数
    vi /etc/security/limits.conf
    
    # 文件末尾增加下面内容
    es soft nofile 65535
    es hard nofile 65537
    

    4.2 进行20-文件配置

    vi /etc/security/limits.d/20-nproc.conf
    
    # 文件末尾增加下面内容,最多可创建的文件数
    es soft nofile 65536
    es hard nofile 65536
    
    # * 代表Linux所有用户名称
    * hard nproc 4096
    

    4.3 进行sysctl.conf配置

    vi /etc/sysctl.conf
    
    # 文件末尾增加下面内容
    vm.max_map_count=655360
    
    # 保存文件后,重新加载,输入命令
    sysctl -p
    

    5.设置ES的JVM占用内存参数

    启动之前,设置ES的JVM占用内存参数,防止内存不足错误

    vi /data/elasticsearch/config/jvm.options
     
    # 改为最小内存4g,最大内存4g
    ################################################################
    ##
    ## The heap size is automatically configured by Elasticsearch
    ## based on the available memory in your system and the roles
    ## each node is configured to fulfill. If specifying heap is
    ## required, it should be done through a file in jvm.options.d,
    ## and the min and max should be set to the same value. For
    ## example, to set the heap to 4 GB, create a new file in the
    ## jvm.options.d directory containing these lines:
    ##
    -Xms4g
    -Xmx4g
    ##
    ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
    ## for more information
    ##
    ################################################################
    

    __EOF__

  • 本文作者: deadmau5
  • 本文链接: https://www.cnblogs.com/Deadmau5/p/16367185.html
  • 关于博主: 评论和私信会在第一时间回复。或者直接私信我。
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
  • 声援博主: 如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。
  • 相关阅读:
    【日常训练】207. 课程表
    3D 生成重建008-zero123让扩散模型了解空间信息zero-shot 单图生3d
    Redo subscriber operation REGISTER for DEFAULT_GROUP@@xxx # failed.
    高压放大器在静电喷涂技术中的应用
    基于Java旅游管理系统设计实现(源码+lw+部署文档+讲解等)
    powershell中的常用软件打开命令
    CSAPP-第二章学习笔记
    Flutter 高级教程之如何开发iOS Widget小组件展示SQLite本地数据库数据(教程含完整源码)
    操作系统闲谈01——IO多路复用
    手把手教小白制作情侣天气推送号 【只需四步】
  • 原文地址:https://www.cnblogs.com/Deadmau5/p/16367185.html