zoukankan      html  css  js  c++  java
  • linux 安装elasticsearch步骤以及入的坑

    最近在做一些微服务的项目要求在站内搜索,所以选择使用的elasticsearch,话不多说上安装步骤:

    一、首先去官网下载linux tar.gz版本 我这里是5.6.8版本网址如下   

    https://www.elastic.co/cn/downloads/past-releases/elasticsearch-5-6-8

    # 创建用户名为 es 的用户
    useradd es
    # 设置 es 用户的密码
    passwd es
    
    # 创建 es 的 data 和 logs 目录
    mkdir elasticsearch-5.6.8/data
    mkdir elasticsearch-5.6.8/logs 
    #解压
    tar -zxvf /elasticsearch-5.6.8.tar.gz
    # 将 /usr/local/elasticsearch/elasticsearch-5.6.8 的拥有者设置为 es
    chown -R es:es /usr/local/elasticsearch/elasticsearch-5.6.8
    #编辑配置文件config/elasticsearch.yml 添加如下两句
    network.host: 0.0.0.0
    http.port: 9200

    以为在5.0以后版本el不支持root用户启动 所以要切换到刚刚创建的用户 es下面

    su es
    #将目录切换到目录bin目录 前台启动 是否报错 
    ./elasticsearch 

    如果启动中遇到下面问题

    [2018-01-28T23:51:35,180][INFO ][o.e.t.TransportService   ] [qR5cyzh] publish_address {172.19.26.110:9300}, bound_addresses {172.19.26.110:9300}
    [2018-01-28T23:51:35,204][INFO ][o.e.b.BootstrapChecks    ] [qR5cyzh] bound or publishing to a non-loopback address, enforcing bootstrap checks
    ERROR: [2] bootstrap checks failed
    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
    [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    第一个可以max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

    如下解决 原因是因为操作系统vm.max_map_count参数设置太小导致的,至于设置多大的数值,我这里就直接参照报错信息的建议直接设置为262144

    解决方案一:

    #切换到root用户下,执行以下命令:
    sysctl -w vm.max_map_count=262144
    #检查配置是否生效
    [root@localhost elasticsearch-6.1.2]# sysctl -a | grep "vm.max_map_count"
    vm.max_map_count = 262144
    [root@localhost elasticsearch-6.1.2]# 

    解决方案二

    #切换到root用户,备份原有配置
    [root@localhost elasticsearch-6.1.2]# cd /etc
    [root@localhost etc]# cp sysctl.conf sysctl.conf.bak
    
    #编辑sysctl.conf,增加如下内容
    [root@localhost etc]# vim sysctl.conf
    
    # elasticsearch config start
    vm.max_map_count=262144
    # elasticsearch config end

    如果正常输出262144,则说明修改成功,然后再次启动elasticsearch,输出如下:

    ERROR: [1] bootstrap checks failed
    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

    这个时候发现只有一个错了

    报错max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]是因为操作系统安全检测配置影响的,我们需要切换到root用户下做如下配置:

    先做一个配置备份

    [root@localhost elasticsearch-6.1.2]# cd /etc/security/
    [root@localhost security]# cp limits.conf limits.conf.bak

    然后编辑limits.conf增加如下配置:

    # elasticsearch config start
    * soft nofile 65536
    * hard nofile 131072
    * soft nproc 2048
    * hard nproc 4096
    # elasticsearch config end
    

    执行启动命令 ./bin/elasticsearch ,会发现指定IP已经配置好了,也正常启动。

    ip:9200访问结果如下:

    {
      "name" : "OYJ_I0B",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "U5JHdDL8SECLAr2qVHZXbw",
      "version" : {
        "number" : "5.6.8",
        "build_hash" : "688ecce",
        "build_date" : "2018-02-16T16:46:30.010Z",
        "build_snapshot" : false,
        "lucene_version" : "6.6.1"
      },
      "tagline" : "You Know, for Search"
    }

    说明可以启动成功  我们可以放心的后台 启动 

    ./elasticsearch  -d

    安装的时候就是遇到这些

    ps 如遇一下问题

    java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed

    错误描述:

      ElasticSearch集群启动错误,错误的原因是:因为Centos6不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动解决:修改elasticsearch.yml

    问题解决:

    在所有节点的elasticsearch.yml配置文件中加入:

      bootstrap.memory_lock: false

      bootstrap.system_call_filter: false

    elasticsearch启动过程中被自动killed

     
    elasticsearch无法正常启动,启动过程中被自动killed
    配置完elassearch后,发现elassearch无法和hadoop集群同时启动,已启动hadoop集群elassearch就会自动被killed,在启动elassearch时刚一开始就会被killed掉

    [admin@bigdata111 elasticsearch-6.1.1]$ bin/elasticsearch 
    Killed
     
    查看日志也没有错误。
    后来发现是内存不够了,由于ES是运行在JVM上,JVM本身除了分配的heap内存以外,还会用到一些堆外(off heap)内存。 在小内存的机器上跑ES,如果heap划分过多,累加上堆外内存后,总的JVM使用内存量可能超过物理内存限制。 如果swap又是关闭的情况下,就会被操作系统oom killer杀掉。
    修改ES中config目录下的jvm.options文件
    vim jvm.options

    -Xms1g
    -Xmx1g
    改为
    -Xms512m
    -Xmx512m
    就启动成功了

    完美解决

  • 相关阅读:
    my read travel
    OS + CentOS 7 / centos 7 / config / configuration / rescue / rc.local / yum
    my soft / win soft
    如何撰写发明专利申请文件
    专利局审查员如何审专利
    国际专利分类表(2016版)
    手把手教你写专利申请书/如何申请专利
    Packets switched through Linux bridge have very high packet delay variation and latency?
    当心僵尸:过时Linux内核的安全风险
    飞漫魏永明:从MiniGUI看嵌入式十年得与失
  • 原文地址:https://www.cnblogs.com/blackCatFish/p/11796447.html
Copyright © 2011-2022 走看看