linux配置sonarqube遇到的坑

1、9000端口开了,sonar配置的9000端口,但是连接失败

[sonar@localhost linux-x86-64]$ curl http://localhost:9000
curl: (7) Failed connect to localhost:9000; Connection refused

本来以为是权限问题,各种百度,才知道应该查看sonarqube.log日志信息,日志会给出报错,

当sonarqube运行有错的时候,访问9000也是访问不到的。

2、elasticsearch文件权限与内存大小问题

SonarQube is stopped,日志sonarqube.log查看报错信息

ERROR: [2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch.
bootstrap check failure [1] of [2]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
bootstrap check failure [2] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

参考如下文章,解决问题,需要注意这篇文章里的elk是当前登录的用户,而不是命令,第一次按照命令直接照搬,未解决问题,再次查看文章才发现。elasticsearch7.x安装异常 ERROR: [2] bootstrap checks failed. You must address the points described in th_qq690452074的专栏-CSDN博客

我登录的用户是sonar 所以 

sonar hard nofile 65536

sonar soft nofile 65536 

3、can not run elasticsearch as root

java.lang.RuntimeException: can not run elasticsearch as root

原因是,sonarqube不能以root用户运行

 参考 https://blog.csdn.net/u010777099/article/details/83819911

新建用户,配置权限,以后启动sonar都用新的用户启动。

4、Sonarqube requires java 11 to run

原因是需要安装jdk11,原来的版本是jdk8不行。

我采取的方法

0、卸载linux上的jdk8,找到java的安装目录用rm命令删除

运行java -version 没有版本提示说明卸载成功

1、windows在jdk官网下载 jdk-11.0.12_linux-x64_bin.tar.gz

2、用wincp传到linux,解压 tar zxvf jdk-11.0.12_linux-x64_bin.tar.gz

参考 Linux 安装JDK .tar.gz_把酒问天专栏-CSDN博客

3、配置jdk环境变量 

运行java -version 提示11 说明安装配置成功

5、服务器端口没开

sonar开启后,监听9000端口,访问服务器9000端口,即可访问sonar服务,

但是可能由于防火墙,导致访问失败

查看防火墙状态

[root@azrlnx04 ~]# systemctl status firewalld

如未运行,则需要先让它运行,关于如何开始firewalld,参考:How to Start and Enable Firewalld on CentOS 7 | Liquid Web

增加9000端口

[root@azrlnx04 ~]# firewall-cmd --zone=public --add-port=9000/tcp --permanent
success
[root@azrlnx04 ~]# firewall-cmd --zone=dmz --add-port=9000/tcp --permanent
success
[root@azrlnx04 ~]# firewall-cmd --reload
success

如何9000端口开启,且sonar服务正常,则 

netstat -tpln | grep 9000

运行结果会是

 [sonar@localhost linux-x86-64]$ netstat -tpln | grep 9000
tcp6       0      0 :::9000                 :::*                    LISTEN      17063/java

猜你喜欢

转载自blog.csdn.net/seanyang_/article/details/120441828