【linux】【sonarqube】安装sonarqube7.9
作者:互联网
SonarQube 是一款用于代码质量管理的开源工具,它主要用于管理源代码的质量。 通过插件形式,可以支持众多计算机语言,比如 java, C#, go,C/C++, PL/SQL, Cobol, JavaScrip, Groovy 等。sonar可以通过PMD,CheckStyle,Findbugs等等代码规则检测工具来检测你的代码,帮助你发现代码的漏洞,Bug,异味等信息。 Sonar 不仅提供了对 IDE 的支持,可以在 Eclipse和 IntelliJ IDEA 这些工具里联机查看结果;同时 Sonar 还对大量的持续集成工具提供了接口支持,可以很方便地在持续集成中使用 Sonar。
sonarqube7.9的前提条件是jdk11、postgreSQL
链接:https://pan.baidu.com/s/1BcrQhzv3piH7CBRPfB_RTg 提取码:6d1q
jdk安装参考:https://www.cnblogs.com/jxd283465/p/11541506.html
1 [root@localhost home]# java -version 2 java version "11.0.4" 2019-07-16 LTS 3 Java(TM) SE Runtime Environment 18.9 (build 11.0.4+10-LTS) 4 Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.4+10-LTS, mixed mode)
postgreSQL10.1安装参考:https://www.cnblogs.com/jxd283465/p/11550745.html
1 [root@localhost bin]# ./psql -V 2 psql (PostgreSQL) 10.10
sonarqube7.9安装
1.解压,重命名
# 解压 unzip sonarqube-7.9.1.zip # 重命名 mv sonarqube-7.9.1 sonarqube
如果报错unzip not command: yum -y install unzip
2.创建sonarqube用户组和用户、赋权
1 # 创建sonarqube用户组 2 [root@localhost home]# groupadd sonarqube 3 4 # 创建sonarqube用户 -g指定用户组 -p指定密码 -M不创建home目录 5 [root@localhost home]# useradd sonarqube -g sonarqube -p sonarqube -M 6 7 # 赋予/home/sonarqube文件夹sonarqube用户权限 -R表示递归 8 [root@localhost home]# chown -R sonarqube:sonarqube /home/sonarqube
3.修改配置文件
# 修改sonarqube配置文件,增加postgres数据库配置 vi /home/sonarqube/conf/sonar.properties
# postgres数据库用户名 sonar.jdbc.username=postgres # postgres数据库用户名密码 sonar.jdbc.password=postgres # postgres数据库地址 sonar.jdbc.url=jdbc:postgresql://127.0.0.1:5432/sonar?currentSchema=public # sonar的web访问端口 sonar.web.port=9002
4.配置启动参数
# 修改sonar的启动文件 vi /home/sonarqube/bin/linux-x86-64/sonar.sh # 将runuser设置为sonarqube RUN_AS_USER=sonarqube
5.启动sonarqube
1 # 切换sonarqube用户 2 [root@localhost home]# su sonarqube 3 4 # 启动sonar 5 bash-4.2$ /home/sonarqube/bin/linux-x86-64/sonar.sh start 6 Starting SonarQube... 7 Started SonarQube.
浏览器访问http://192.168.8.20:9002 访问失败
查看日志查找原因,日志在 /home/sonarqube/logs 下,分别查看es和sonar的启动日志
1 bash-4.2$ pwd 2 /home/sonarqube/logs 3 bash-4.2$ ls -l 4 总用量 12 5 -rw-r--r--. 1 sonarqube sonarqube 3402 9月 19 16:52 es.log 6 -rw-r--r--. 1 sonarqube sonarqube 88 7月 10 12:21 README.txt 7 -rw-r--r--. 1 sonarqube sonarqube 1522 9月 19 16:52 sonar.log
查看es.log (elasticsearch)
1 bash-4.2$ cat es.log 2 2019.09.19 16:52:17 INFO es[][o.e.e.NodeEnvironment] using [1] data paths, mounts [[/home (/dev/mapper/centos-home)]], net usable_space [961.2gb], net total_space [962.7gb], types [xfs] 3 2019.09.19 16:52:17 INFO es[][o.e.e.NodeEnvironment] heap size [494.9mb], compressed ordinary object pointers [true] 4 2019.09.19 16:52:17 INFO es[][o.e.n.Node] node name [sonarqube], node ID [k784DcanQ1e4py5e75WQYQ] 5 2019.09.19 16:52:17 INFO es[][o.e.n.Node] version[6.8.0], pid[20791], build[default/tar/65b6179/2019-05-15T20:06:13.172855Z], OS[Linux/3.10.0-957.27.2.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/11.0.4/11.0.4+10-LTS] 6 2019.09.19 16:52:17 INFO es[][o.e.n.Node] JVM arguments [-XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/home/sonarqube/temp, -XX:ErrorFile=../logs/es_hs_err_pid%p.log, -Des.enforce.bootstrap.checks=true, -Xms512m, -Xmx512m, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/home/sonarqube/elasticsearch, -Des.path.conf=/home/sonarqube/temp/conf/es, -Des.distribution.flavor=default, -Des.distribution.type=tar] 7 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [analysis-common] 8 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [lang-painless] 9 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [mapper-extras] 10 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [parent-join] 11 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [percolator] 12 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [reindex] 13 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [repository-url] 14 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] loaded module [transport-netty4] 15 2019.09.19 16:52:18 INFO es[][o.e.p.PluginsService] no plugins loaded 16 2019.09.19 16:52:19 WARN es[][o.e.d.c.s.Settings] [http.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version. 17 2019.09.19 16:52:20 INFO es[][o.e.d.DiscoveryModule] using discovery type [zen] and host providers [settings] 18 2019.09.19 16:52:21 INFO es[][o.e.n.Node] initialized 19 2019.09.19 16:52:21 INFO es[][o.e.n.Node] starting ... 20 2019.09.19 16:52:21 INFO es[][o.e.t.TransportService] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001} 21 2019.09.19 16:52:21 INFO es[][o.e.b.BootstrapChecks] explicitly enforcing bootstrap checks 22 2019.09.19 16:52:21 ERROR es[][o.e.b.Bootstrap] node validation exception 23 [2] bootstrap checks failed 24 [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] 25 [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 26 2019.09.19 16:52:21 INFO es[][o.e.n.Node] stopping ... 27 2019.09.19 16:52:21 INFO es[][o.e.n.Node] stopped 28 2019.09.19 16:52:21 INFO es[][o.e.n.Node] closing ... 29 2019.09.19 16:52:21 INFO es[][o.e.n.Node] closed
发现有两个错误:
24 [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] 25 [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决第一个:
vi /etc/security/limits.conf 修改配置文件,在文件最后加入下面两个行。用户退出重新登录生效。 * soft nofile 65536 * hard nofile 65536
解决第二个:
sudo sysctl -w vm.max_map_count=262144
重启依旧报错,查看日志发现web.log报错
2019.09.19 17:13:20 WARN web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#12]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.base@11.0.4/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.4/sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:120) java.base@11.0.4/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124) java.base@11.0.4/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136) app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62) app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765) app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413) app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909) java.base@11.0.4/java.lang.Thread.run(Thread.java:834) 2019.09.19 17:13:20 INFO web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9002 2019.09.19 17:13:20 INFO web[][o.s.p.ProcessEntryPoint] Hard stopping process
经过排查是postgresql中sonar数据库未建立。
连接postgresql
CREATE DATABASE sonar WITH OWNER=postgres ENCODING='UTF-8';
启动成功。
初始化密码admin/admin
标签:2019.09,16,19,sonarqube,52,sonarqube7.9,linux,es 来源: https://www.cnblogs.com/jxd283465/p/11550291.html