zoukankan      html  css  js  c++  java
  • Linux(CentOS)下安装Elasticsearch5.0.0

    一.ES5.0解压安装到Windows之后(可能)需要进行的设置:

    1.如果不设置,直接运行elasticsearch.bat 文件 ,会报错:

    2.解决方式 调节 conf/jvm.options 配置文件

    这里采取调小ES占用的内存:    默认配置如下图,初始化和最大内存大小为2G

    调节为1g

    之后再运行bin/elasticsearch.bat文件就可以正常启动了.

    二.ES5.0 解压安装到Linux之后需要进行一些设置才能正常使用.

    之前一直是在Linux上使用的ES的1.4版本,在Linux上解压就能用,今天尝试使用ES的5.0.0版本.

    1.遇到第一个问题:java.lang.RuntimeException: can not run elasticsearch as root  以及解决方式

    如果使用Linux的root用户 对ES5.0 解压运行 会报如下错误:java.lang.RuntimeException: can not run elasticsearch as root      错误是说运行ES不能以root用户的身份

    ES5之后就不允许用root用户启动了,如果是ES5.0以下的版本可以参考此解决方式:http://blog.csdn.net/u010317005/article/details/52205825

    [2017-11-16T23:06:39,263][ERROR][o.e.b.Bootstrap          ] Exception
    java.lang.RuntimeException: can not run elasticsearch as root
            at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:96) ~[elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:155) ~[elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286) [elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:112) [elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103) [elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) [elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96) [elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.cli.Command.main(Command.java:62) [elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) [elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73) [elasticsearch-5.0.0.jar:5.0.0]
    [2017-11-16T23:06:39,328][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
    org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
            at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:116) ~[elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103) ~[elasticsearch-5.0.0.jar:5.0.0]

    这是出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑,建议创建一个单独的用户用来运行ElasticSearch.

    创建elsearch用户组及elsearch用户

    groupadd elsearch
    useradd elsearch -g elsearch -p elasticsearch

     更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch

    chown -R elsearch:elsearch  elasticsearch-5.0.0

     切换到elsearch用户再启动(有可能还是会报错,可能的报错以及解决方式见下文)

    su elsearch #切换账户
    cd elasticsearch/bin #进入你的elasticsearch目录下的bin目录
    ./elasticsearch

    2.遇到的第二个问题:unable to install syscall filter

    [2017-11-16T23:17:07,043][WARN ][o.e.b.JNANatives         ] unable to install syscall filter:
    java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
            at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]
            at org.elasticsearch.bootstrap.JNANatives.trySeccomp(JNANatives.java:215) [elasticsearch-5.0.0.jar:5.0.0]
    

     报了一大串错误,其实就是一个警告信息.   使用新的Linux版本就不会出现此问题了.  不用理会....

    3.遇到的第三个问题: node validation exception     bootstrap checks failed

    [2017-11-16T23:20:30,812][ERROR][o.e.b.Bootstrap          ] [m2M7ykG] node validation exception
    bootstrap checks failed
    max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
    max number of threads [1024] for user [elsearch] likely too low, increase to at least [2048]
    max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
    [2017-11-16T23:20:30,815][INFO ][o.e.n.Node               ] [m2M7ykG] stopping ...
    [2017-11-16T23:20:30,852][INFO ][o.e.n.Node               ] [m2M7ykG] stopped
    [2017-11-16T23:20:30,852][INFO ][o.e.n.Node               ] [m2M7ykG] closing ...
    [2017-11-16T23:20:30,886][INFO ][o.e.n.Node               ] [m2M7ykG] closed

    解决方式:

    第一步: 切换到root用户,编辑limits.conf 添加类似如下内容  vi /etc/security/limits.conf 

    添加如下内容: (soft nproc和hard nproc也可以设置成65536)

    * soft nofile 65536

    * hard nofile 131072

    * soft nproc 2048

    * hard nproc 4096

    以上几个参数的解释

    ① soft nproc:可打开的文件描述符的最大数(软限制)

    ② hard nproc:可打开的文件描述符的最大数(硬限制)

    ③ soft nofile:单个用户可用的最大进程数量(软限制)

    ④ hard nofile:单个用户可用的最大进程数量(硬限制)

    第二步:   使用命令 vim /etc/security/limits.d/90-nproc.conf 将下图中红框所示位置的值从 1024 改成 2048 

    第三步    使用命令 vim /etc/sysctl.conf 在最后添加一行数据如下: vm.max_map_count=262144

     

    第四步: 修改完后,执行如下命令 sysctl -p

    这个命令也必须使用root用户,

     

    使用非root用户报错:

    4.做了以上修改之后在Linux启动应该可以正常启动.但是如果在通过别的机器来访问启动机器所在的ES的Web页面,会发现访问不到.需要做如下配置:

    我们需要编辑其中的 elasticsearch.yml 这一文件,使用命令 vim elasticsearch.yml

    修改network.host和discovery.zen.ping.unicast.hosts的IP,改成当前ip地址(通过 ifconfig 命令查看)。如果不修改,则只能本地访问(localhost或127.0.0.1)

     

     以上修改就可以远程访问该ES的Web服务.

    5.ES的后台启动命令  和 检查ES的启动进程

    ElasticSearch后台启动命令

    ./elasticsearch -d

    查看后台命令是否启动成功

    ps aux|grep elasticsearch
    elsearch  3119  4.6  3.2 3535488 250876 pts/1  Sl   16:50   0:09 /opt/java/jdk1.7.0_75/bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/home/py-project/elasticsearc-2.4.0 -cp /home/py-project/elasticsearch-2.4.0/lib/elasticsearch-2.4.0.jar:/home/py-project/elasticsearch-2.4.0/lib/* org.elasticsearch.bootstrap.Elasticsearch start -d
    elsearch  3254  0.0  0.0 110224   916 pts/1    S+   16:54   0:00 grep --color=auto elasticsearch
  • 相关阅读:
    斯皮尔曼+假设检验
    53. Maximum Subarray
    工具网站
    Win10 不稳定经常死机 -蓝屏-电脑-电脑 系统启动后 键盘等一会才有反应
    MFC 代码无错却无法运行
    为什么喝酒不能吃头孢
    基于靶机的SQL注入的探测
    SQlMap注入的基本原理
    burp suite 简单靶机验证码绕过【前台|后台验证】自娱自乐系列
    burp suite 基于自娱自乐的靶机简单密码爆破
  • 原文地址:https://www.cnblogs.com/DreamDrive/p/7853162.html
Copyright © 2011-2022 走看看