2017-04-19 138 views
0

我正在使用elasticsearch的Django項目。Django版本是1.9.2,python版本是2.7。我在Docker容器中部署項目,通常以root用戶身份運行進程。鏡像成功構建,除彈性搜索外,一切正常。我得到如何在Docker中以root用戶身份運行Elasticsearch 5.2.1

[email protected]:~/arches# elasticsearch-5.2.1/bin/elasticsearch 
[2017-04-19T07:37:13,347][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-5.2.1.jar:5.2.1] 
     at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.2.1.jar:5.2.1] 
Caused by: java.lang.RuntimeException: can not run elasticsearch as root 
     at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:203) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.1.jar:5.2.1] 
     at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.1.jar:5.2.1] 
     ... 6 more 

嘗試啓動ElasticSearch時出錯,似乎沒有辦法解決它。 ElasticSearch無法以超級用戶身份運行的原因是什麼?碼頭集裝箱內部的東西是孤立的,根過程被認爲是安全的。

+0

如果Elasticsearch需要一個非root用戶,則需要啓動Eloasticsearch – user2915097

回答

0

不建議以root身份運行elasticsearch。對於臨時解決方案,您可以通過啓用屬性es.insecure.allow.root來運行,如下所示。

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

請參閱此鏈接前添加非特權用戶喜歡unpriv,並使用你的Dockerfile用戶unpriv'指令。它解釋了爲什麼以root身份運行彈性搜索是不安全的。 https://discuss.elastic.co/t/why-is-it-elasticsearch-is-not-allowed-to-run-as-root/60413/2 – Neeraj

+0

不適用於此。 –

+0

你能告訴我們碼頭文件嗎? – Neeraj

相關問題