安装elasticsearch不能以root启动说明及解决
安装软件及系统版本:Elasticsearch 2.3.1
# uname -a
Linux dbdg 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/redhat-release
CentOS release 6.5 (Final)
java版本
# java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
root用户启动elasticsearch报错如下:
# ./elasticsearch
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.
解决办法:新建普遍用户,把elasticsearch 所在的文件夹拥有者,拥有组都修改为此用户,然后切换至此用户来启动
然后本地测试一下:
# curl -X GET 'https://localhost:9200'
{
"name" : "Melody Guthrie",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.3.1",
"build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
"build_timestamp" : "2016-04-04T12:25:05Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
返回以上结果,说明启动ok了
另外,如果你非要使用root用户来启动运行,也是可以的,修改/bin/elasticsearch文件
vi bin/elasticsearch
在daemonized=`echo $* | egrep -- '(^-d |-d$| -d |--daemonize$|--daemonize )'` 上一行添加如下内容,大约138行:
ES_JAVA_OPTS="-Des.insecure.allow.root=true"
然后保存退出即可
评论