我试图安装SonarQube:我已经按照这些步骤进行了操作:
Setting up SOnarQube Tuto : here
总结一下:
/opt/sonar
将这些coonfig步骤添加到/opt/sonar/conf/sonar.properties
:
sonar.jdbc.username =声纳 sonar.jdbc.password =声纳
sonar.jdbc.url = JDBC:MySQL的://本地主机:3306 /声纳了useUnicode =真安培;的characterEncoding = UTF8&安培; rewriteBatchedStatements =真安培; useConfigs = maxPerformance
和
sonar.web.host=127.0.0.1
sonar.web.context=/sonar
sonar.web.port=9000
sudo cp /opt/sonar/bin/linux-x86-64/sonar.sh /etc/init.d/sonar
sudo gedit /etc/init.d/sonar
插入两个新行:
SONAR_HOME=/opt/sonar
PLATFORM=linux-x86-64
Modify the following lines:
WRAPPER_CMD="${SONAR_HOME}/bin/${PLATFORM}/wrapper"
WRAPPER_CONF="${SONAR_HOME}/conf/wrapper.conf"
...
PIDDIR="/var/run"
Register as a Linux service:
sudo update-rc.d -f sonar remove
sudo chmod 755 /etc/init.d/sonar
sudo update-rc.d sonar defaults
完成这些步骤后:我尝试从localhost:9000/sonar
运行Sonar并执行:sudo /etc/init.d/sonar start
`
奇怪的是,它没有运行。
所以,当我运行`sudo /etc/init.d/sonar status时,我发现它在几秒钟之后就会进入步骤,并在它的日志文件中抛出一些错误,如下所示:
es.log:
2017.12.09 18:05:14 ERROR es[][o.e.b.Bootstrap] Exception
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.6.3.jar:5.6.3]
2017.12.09 18:05: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.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.3.jar:5.6.3]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.3.jar:5.6.3]
... 6 more
有什么建议吗?
答案 0 :(得分:17)
SonarSource升级了Elasticsearch工具,该工具是最新SonarQube LTS版本的一部分。因此,SonarQube无法作为root运行。请参阅this博客和SonarQube 6.6升级说明以及this SO问题。
答案 1 :(得分:2)
我遇到了同样的问题,花了很多时间才得到解决方案。
错误与
相同2017.12.09 18:05:14 ERROR es[][o.e.b.Bootstrap] Exception
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.3.jar:5.6.3]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.3.jar:5.6.3]
解决方案 使用 adduser 命令创建一个 ‘sonar’ 用户 //我使用的是 linux 系统 chown -R sonar sonar-install-folder/ 在启动脚本中编辑 sonar.sh 文件 sonar-install-folder/bin/linux-x86-6 并将 #RUN_AS_USER 更改为 RUN_AS_USER=sonar
然后使用下面的命令
./sonar.sh stop
优雅地停止 SonarQube... SonarQube 未运行。
./sonar.sh start
启动 SonarQube... 启动 SonarQube。
./sonar.sh status
SonarQube 正在运行 (22100)。
因此,基本上弹性搜索不需要由 root 用户运行。默认情况下,RUN_AS_USER 在启动脚本中被注释,该脚本选择了我当前的 root 用户,然后一些 linux 权限规则出现在图片中,因为弹性搜索进程没有启动并且导致声纳进程也关闭。
从 sonar.log 可以明显看出
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2020.05.08 06:36:36 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 78
2020.05.08 06:36:36 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
2020.05.08 06:36:36 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
答案 2 :(得分:-2)
更改对声纳文件的根访问权限。尝试以普通用户权限运行。
chown <another user>:<user group> sonar.sh