CentOS上配置SonarQube踩坑


用的7.2.1版本,先下载解压

wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-7.2.1.zip
unzip sonarqube-7.2.1.zip

然后修改conf下的sonar.properties文件,我选择了mysql,新建一个sonar的数据库,配置好用户名和密码

sonar.jdbc.url=jdbc:mysql://192.168.2.195:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.sorceEncoding=UTF-8
sonar.login=sonar
sonar.password=sonar

接下来直接运行

./sonarqube-7.2.1/bin/linux-x86-64/sonar.sh start

netstat查看9000端口没有开启,ps一下进程都挂了,检查log发现提示

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]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]h-5.6.3.jar:5.6.3]

SonarQube下的elasticsearch不能以root权限运行,所以添加一个用户来运行

groupadd sonarqube
useradd sonar -g sonarqube -p sonar

并且编辑刚才启动脚本sonar.sh文件,找到RUN_AS_USER设置为sonar用户,再次尝试启动依然报错,log如下

java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed 
     at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:364) ~[elasticsearch-5.6.3.jar:5.6.3]
     at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:639) ~[elasticsearch-5.6.3.jar:5.6.3]
     at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:258) [elasticsearch-5.6.3.jar:5.6.3]
     at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-5.6.3.jar:5.6.3]
     at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) [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]

找到文件sonarqube-7.2.1/elasticsearch/config/elasticsearch.yml,增加以下配置

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

继续尝试启动,还是报错

WARN  es[][o.e.b.BootstrapChecks] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
WARN  es[][o.e.b.BootstrapChecks] max number of threads [1024] for user [sonar] is too low, increase to at least [2048]
WARN  es[][o.e.b.BootstrapChecks] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

上面几个线程及虚拟内存错误可以通过下面这篇文章解决
http://www.cnblogs.com/sloveling/p/elasticsearch.html

然后启动成功,接下来就可以通过9000端口访问了,然后在ide里面配置sonarlint插件


内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://11000011.com/?id=18

« 上一篇 下一篇 »

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

主机推荐

  • 搬瓦工