zoukankan      html  css  js  c++  java
  • elasticsearch安装

    安装jdk环境,自行百度

    安装elasticsearch

    下载 https://www.elastic.co/cn/downloads/elasticsearch

    我目前使用的版本,包含分词插件

    链接: https://pan.baidu.com/s/1gJX20Gy3TbgCNvxNl8jbLA 提取码: 36cd 

    将下载的 tar.gz包放到linux的opt目录下

    解压

    tar -zxvf elasticsearch-****.tar.gz 

    因为elasticsearch不能使用root运行

    创建user用户

    adduser user

    将目录的权限给user

    chown -R user:user /opt/elasticsearch-7.4.2

    创建存数据和日志的目录,我放在home下面

    mkdir /home/elasticsearch

    将目录所有者改为user

    chown -R user:user /home/elasticsearch

    切换到user用户

    su user

    创建数据目录和日志目录

    mkdir //home/elasticsearch/datanode/data

    mkdir //home/elasticsearch/datanode/logs

    修改配置文件

    cd /opt/elasticsearch-7.4.2/config

    vi elasticsearch.yml

    配置修改成如下

    # ---------------------------------- Cluster -----------------------------------
    #
    # Use a descriptive name for your cluster:
    #
    cluster.name: abner  //打开设定es群集名称
    #
    # ------------------------------------ Node ------------------------------------
    #
    # Use a descriptive name for the node:
    #
    node.name: node-1      //es当前节点名称,用于区分不同节点
    #
    # Add custom attributes to the node:
    #
    #node.attr.rack: r1
    #
    # ----------------------------------- Paths ------------------------------------
    #
    # Path to directory where to store the data (separate multiple locations by comma):
    #
    path.data: /home/elasticsearch/datanode/data    //修改数据目录,此目录为自定义,需要在root用户下创建,且属主属组更改为ela
    #
    # Path to log files:
    #
    path.logs: /home/elasticsearch/datanode/logs  //日志目录位置,需自己创建,方式同上
                                      //yum安装则系统自定义,在软件版本或者系统升级时会被删除,所以建议修改
    #
    # ----------------------------------- Memory -----------------------------------
    #
    # Lock the memory on startup:
    #
    bootstrap.memory_lock: true  //elasticsearch官网建议生产环境需要设置bootstrap.memory_lock: true
    #
    # Make sure that the heap size is set to about half the memory available
    # on the system and that the owner of the process is allowed to use this
    # limit.
    #
    # Elasticsearch performs poorly when the system is swapping the memory.
    #
    # ---------------------------------- Network -----------------------------------
    #
    # Set the bind address to a specific IP (IPv4 or IPv6):
    #
    network.host: 0.0.0.0  //监听访问地址为任意网段
    #
    # Set a custom port for HTTP:
    #
    http.port: 9200  //服务监听端口
    #

    准备工作完成,启动

    cd /opt/elasticsearch-7.4.2/bin
    ./elasticsearch    后面可以跟上-d后台执行

    如果报错

    1错,当发现ERROR: [1] bootstrap checks failed错误时

    vim /etc/sysctl.conf

    vm.max_map_count = 655360 //添加

    执行命令使配置生效

    sysctl -p 

    2错,max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

    修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效

    *  soft    nofile          65536
    *  hard    nofile          65536

    3错,ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked

    root权限编辑

     vi /etc/security/limits.conf

    * soft memlock unlimited

    * hard memlock unlimited

    vi /etc/sysctl.conf

    vm.swappiness=0

    配置生效 

    sysctl -p

    重新登录或重启服务器方可生效

    4错,availableProcessors is already set to [4], rejecting [4]

    在main加上

    System.setProperty("es.set.netty.runtime.available.processors", "false");

     查看是否运行成功

    netstat -ntap | grep 9200

    开放 9200端口

    firewall-cmd --zone=public --add-port=9200-9400/tcp --permanent

    firewall-cmd --reload

  • 相关阅读:
    Ubuntu 12.04 root账户开启及密码重设
    Notepad++ 开启「切分窗口」同时检视、比对两份文件
    第11章 Java异常与异常处理
    第10章 Java类的三大特性之一:多态
    第9章 Java类的三大特性之一:继承
    第8章 Java类的三大特性之一:封装
    第7章 类和对象
    java 经典程序 100 例
    第6章 Java类中的方法
    第5章 Java数组
  • 原文地址:https://www.cnblogs.com/suruozhong/p/11856042.html
Copyright © 2011-2022 走看看