2017-10-20 91 views
8

從SonarQube 6.5升級到6.6後,獲取彈性搜索「無法以root身份運行」錯誤。沒有其他改變。從SonarQube 6.5升級到6.6後,獲取彈性搜索「無法以root身份運行」錯誤。沒有其他變化

CentOS版本6.8(決賽) 的Java(TM)SE運行時環境(建1.8.0_101-B13)

java.lang.RuntimeException: can not run elasticsearch as root 
     at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) [elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) [elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) [elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) [elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.6.2.jar:5.6.2] 
2017.10.20 11:59:14 WARN es[][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:136) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.2.jar:5.6.2] 
Caused by: java.lang.RuntimeException: can not run elasticsearch as root 
     at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.2.jar:5.6.2] 
     at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.2.jar:5.6.2] 
     ... 6 more 
+1

檢查運行該軟件的用戶。參見[this](https://discuss.elastic.co/t/why-is-it-elasticsearch-is-not-allowed-to-run-as-root/60413/6)文章。 –

回答

13

我也遇到這個問題,運行SonarQube,如根,在CentOS 7,不碼頭裏面。正如前面的評論中提到的那樣,問題來自SonarQube升級ElasticSearch,而新版本不再允許自己以root身份運行。

在我的環境中,修復很簡單:我已經創建了一個用戶(「sonar」)和組(「sonar」)來「擁有」sonarqube文件。由於我的SonarQube進程已經以root身份運行,它已經保留了root所擁有的日誌和臨時文件。
1.我停止了服務。
2.再分配所有ownserships(「CHOWN -R聲納:聲納/opt/sonarqube-6.6」)
3. /opt/sonarqube-6.6/bin/linux-x86-64/sonar.sh線48改變#RUN_AS_USER=RUN_AS_USER=sonar到並且兩個sonarqube服務及其服務elasticsearch沒有進一步的問題重新啓動。我不得不去http://<sonarhost:port>/setup升級數據庫,並從那裏一切正常。

+3

這個答案應該被OP,@RayeRaskin接受。有關原因,另請參閱https://stackoverflow.com/a/47733598/766786。 –