zoukankan      html  css  js  c++  java
  • ElasticSearch Root身份运行

    https://blog.csdn.net/lahand/article/details/78954112

    如果以root身份运行将会出现以下问题,这个错误,是因为使用root用户启动elasticsearch,elasticsearch是不允许使用root用户启动的

    [root@iZbp1epx1ncetamddfjnxwZ bin]# ./elasticsearch
    [2018-01-02T17:42:42,296][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:125) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.1.1.jar:6.1.1]
    Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:322) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.1.1.jar:6.1.1]
    ... 6 more

    ES5之后[解决方法1],[解决办法2],已经不能用了,请使用[解决办法3],[解决办法4]

    解决方法1:

    在执行elasticSearch时加上参数-Des.insecure.allow.root=true,完整命令如下

    [plain] view plain copy
     
     
     
    1. ./elasticsearch -Des.insecure.allow.root=true  

    解决办法2:

    用vim打开elasicsearch执行文件,在变量ES_JAVA_OPTS使用前添加以下命令

    [plain] view plain copy
     
     
     
    1. ES_JAVA_OPTS="-Des.insecure.allow.root=true"  

    如下图所示,这个方法的好处是以后不用添加参数就能以root身份执行了

    解决办法3:

    我们需要添加用户。

    adduser ***   //添加用户

    passwd ***  //给用户赋值

    添加完用户之后:

    用root用户执行 : chown -R 文件夹名 用户名

    将这几个压缩包所在的文件夹及解压完的文件夹权限给你新建的用户。之后再使用新用户启动就OK了。

    参考:https://www.cnblogs.com/yidiandhappy/p/7737003.html,http://blog.csdn.net/u010317005/article/details/52205825

    解决办法4:

    • 如果是用root账号启动,会报以下错误

      Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root. at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Refer to the log for complete error details.
    • 这是出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑, 
      建议创建一个单独的用户用来运行ElasticSearch

    • 创建elsearch用户组及elsearch用户

      1.  
        groupadd elsearch
      2.  
        useradd elsearch -g elsearch -p elasticsearch
    • 更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch

      1.  
        cd /opt
      2.  
        chown -R elsearch:elsearch elasticsearch
    • 切换到elsearch用户再启动

      1.  
        su elsearch cd elasticsearch/bin
      2.  
        ./elasticsearch
    • 启动后打印信息如下

      1.  
        [2015-12-30 10:15:44,876][WARN ][bootstrap ] unable to install syscall filter: prctl(PR_GET_NO_NEW_PRIVS): Invalid argument
      2.  
        [2015-12-30 10:15:45,175][INFO ][node ] [Grim Hunter] version[2.1.1], pid[26383], build[40e2c53/2015-12-15T13:05:55Z]
      3.  
        [2015-12-30 10:15:45,176][INFO ][node ] [Grim Hunter] initializing ...
      4.  
        [2015-12-30 10:15:45,243][INFO ][plugins ] [Grim Hunter] loaded [], sites []
      5.  
        [2015-12-30 10:15:45,272][INFO ][env ] [Grim Hunter] using [1] data paths, mounts [[/ (/dev/mapper/vg_yong-lv_root)]], net usable_space [33.3gb], net total_space [49gb], spins? [no], types [ext4]
      6.  
        [2015-12-30 10:15:47,318][INFO ][node ] [Grim Hunter] initialized
      7.  
        [2015-12-30 10:15:47,318][INFO ][node ] [Grim Hunter] starting ...
      8.  
        [2015-12-30 10:15:47,388][INFO ][discovery ] [Grim Hunter] elasticsearch/fnXUCLOQQBiC1aR7hhB82Q
      9.  
        [2015-12-30 10:15:50,442][INFO ][cluster.service ] [Grim Hunter] new_master {Grim Hunter}{fnXUCLOQQBiC1aR7hhB82Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
      10.  
        [2015-12-30 10:15:50,491][INFO ][node ] [Grim Hunter] started
      11.  
        [2015-12-30 10:15:50,526][INFO ][gateway ] [Grim Hunter] recovered [0] indices into cluster_state
    ElasticSearch后端启动命令
    ./elasticsearch -d
  • 相关阅读:
    SVN Windows环境搭建,简洁演示
    SVN-linux配置
    链接文本在a标签内标签里也可以用driver.find_element_by_link_text
    selenium python自动化简明演示
    关键字中mysql数据库查询条件带中文无结果解决办法
    python 最短路径
    python 难度分割
    c语言实现一个高铁乘客管理系统
    Linux(Ubuntu)系统安装图文教程
    字符串排序
  • 原文地址:https://www.cnblogs.com/linus-tan/p/10275506.html
Copyright © 2011-2022 走看看