首页 > 代码库 > 解决linux下root运行Elasticsearch异常

解决linux下root运行Elasticsearch异常

在CentOS 6.5 上运行Elasticsearch 2.3,异常如下:

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:270)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

技术分享
异常描述为不能以root权限运行Elasticsearch.解决办法是运行时加上参数:

bin/elasticsearch -Des.insecure.allow.root=true

或者修改bin/elasticsearch,加上ES_JAVA_OPTS属性:

ES_JAVA_OPTS="-Des.insecure.allow.root=true"

保存之后重启Elasticsearch。

<script type="text/javascript"> $(function () { $(‘pre.prettyprint code‘).each(function () { var lines = $(this).text().split(‘\n‘).length; var $numbering = $(‘
    ‘).addClass(‘pre-numbering‘).hide(); $(this).addClass(‘has-numbering‘).parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($(‘
  • ‘).text(i)); }; $numbering.fadeIn(1700); }); }); </script>

    解决linux下root运行Elasticsearch异常