我在ubuntu Linux(ubuntu 20)上安装了SonarQube
目前我使用的是SonarQube版本9.9.3(早些时候我安装了SonarQube 10.3.0.82913也有同样的问题,所以我回到一个版本,安装了9.9.3.79811)
即使回到9.9.3,问题仍然存在
我正在使用openjdk 17.0.8.1 2023-08-24和PostgreSQL 12.16(Ubuntu 12.16-0ubuntu0.20.04.1)
我遵循的步骤如下
1.安装了一个Ubuntu Linux 20.2版服务器,并创建了一个名为“sonaruser”的Linux用户。
1.安装openjdk 17.0.8.1 2023-08-24使用apt
1.使用apt安装PostgreSQL 12.16
1.下载SONAR压缩文件sonarqube-9.9.3.79811并将其解压缩到路径/opt/sonarqube-9.9.3.79811
1.将/opt/sonarqube-9.9.3.79811及其所有子内容的所有权更改为“sonaruser”
1.通过PSQL db超级用户运行以下数据库命令
CREATE DATABASE sonardb;
CREATE USER sonaruser with password 'sonarpass';
ALTER USER sonaruser SET search_path to sonarschema;
GRANT ALL PRIVILEGES ON DATABASE sonardb TO sonaruser```
字符串
1.以linux用户sonaruser的身份登录到Linux,然后以sonaruser的身份登录到postgres;然后运行以下命令
第一个月
1.在文件opt/sonarqube-9.9.3.79811/conf/sonar.properties中更改配置,如下所示
sonar.jdbc.username=sonaruser
sonar.jdbc.password=sonarpass
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonardb?
currentSchema=sonarschema
sonar.web.host=0.0.0.0
sonar.web.context=/sonarqube
sonar.web.port=9000 ```
型
1.完成上述所有操作后,我通过运行命令启动sonarqube/opt/sonarqube/bin/linux-x86-64/sonar.sh
个
然而,这在日志中不断地给我错误,如下所示
```[o.a.h.i.n.c.MainClientExec] [exchange: 1] start execution
2023.11.22 13:56:20 DEBUG app[][o.a.h.c.p.RequestAddCookies] CookieSpec
selected: default
2023.11.22 13:56:20 DEBUG app[][o.a.h.c.p.RequestAuthCache] Re-using
cached 'basic' auth scheme for http://127.0.0.1:9001
2023.11.22 13:56:20 DEBUG app[][o.a.h.c.p.RequestAuthCache] No
credentials for preemptive authentication
2023.11.22 13:56:20 DEBUG app[][o.a.h.i.n.c.InternalHttpAsyncClient]
[exchange: 1] Request connection for {}->http://127.0.0.1:9001
2023.11.22 13:56:20 DEBUG app[]
[o.a.h.i.n.c.PoolingNHttpClientConnectionManager] Connection request:
[route: {}->http://127.0.0.1:9001][total kept alive: 0; route
allocated: 0 of 10; total allocated: 0 of 30]
2023.11.22 13:56:20 DEBUG app[]
[o.a.h.i.n.c.PoolingNHttpClientConnectionManager] Connection request
failed
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at java.base/java.lang.Thread.run(Thread.java:833)
...
2023.11.22 13:56:20 DEBUG app[][o.e.c.RestClient] added [[host=http://127.0.0.1:9001]] to blacklist
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at java.base/java.lang.Thread.run(Thread.java:833)
...
2023.11.22 13:56:20 DEBUG app[][o.e.c.RestClient] added
[[host=http://127.0.0.1:9001]] to blacklist
...
...
2023.12.01 10:34:36 DEBUG app[][o.e.c.RestClient] updated
[[host=http://127.0.0.1:9001]] already in blacklist
2023.12.01 10:34:36 WARN app[][o.s.a.p.AbstractManagedProcess]
Process exited with exit value [ElasticSearch]: 78```
型
有趣的是,当我删除JDBC配置并让SONARQUBE使用嵌入式数据库启动时,这些错误就消失了,SONARQUBE启动正常
我确实确定了在启动sonarqube之前使用的wither端口9000或9001没有问题,并且我还确保防火墙关闭
我确实使用netcat和telnet检查了端口9000和9001是空闲的,服务器可以监听它们,本地主机上的客户端可以连接
我改变日志级别为调试的elasticsearch以及.我看到在/opt/sonarqube/log/nohup. log如下所示-这表明ElasticSearch能够绑定到端口9001成功和Sonarqube连接到它以及.然而,在同一个日志-它显示“连接请求失败”一段时间后
enter code here
2023.12.01 09:16:34 DEBUG app[][o.s.a.NodeLifecycle] main
tryToMoveTo from INIT to STARTING => true
2023.12.01 09:16:34 DEBUG app[][o.s.a.p.ManagedProcessLifecycle]
main tryToMoveTo ElasticSearch from INIT to STARTING => true
2023.12.01 09:16:34 INFO app[][o.s.a.es.EsSettings] Elasticsearch
listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:38141]
2023.12.01 09:16:34 INFO app[][o.s.a.ProcessLauncherImpl] Launch
process[ELASTICSEARCH] from [/opt/sonarqube-
9.9.3.79811/elasticsearch]: /opt/sonarqube-
9.9.3.79811/elasticsearch/bin/elasticsearch
2023.12.01 09:16:34 DEBUG app[][o.s.a.p.ManagedProcessLifecycle]
main tryToMoveTo ElasticSearch from STARTING to STARTED => true
2023.12.01 09:16:34 INFO app[][o.s.a.SchedulerImpl] Waiting for
Elasticsearch to be up and running
2023.12.01 09:16:34 DEBUG app[][o.s.a.e.EsConnectorImpl] Connected
to Elasticsearch node: [127.0.0.1:9001]
....
....
....
2023.12.01 09:16:34 DEBUG app[][o.a.h.i.n.c.MainClientExec]
[exchange: 1] start execution
2023.12.01 09:16:34 DEBUG app[][o.a.h.c.p.RequestAddCookies]
CookieSpec selected: default
2023.12.01 09:16:34 DEBUG app[][o.a.h.c.p.RequestAuthCache] Re-
using cached 'basic' auth scheme for http://127.0.0.1:9001
2023.12.01 09:16:34 DEBUG app[][o.a.h.c.p.RequestAuthCache] No
credentials for preemptive authentication
2023.12.01 09:16:34 DEBUG app[]
[o.a.h.i.n.c.InternalHttpAsyncClient] [exchange: 1] Request
connection for {}->http://127.0.0.1:9001
2023.12.01 09:16:34 DEBUG app[]
[o.a.h.i.n.c.PoolingNHttpClientConnectionManager] Connection
request: [route: {}->http://127.0.0.1:9001][total kept alive: 0;
route allocated: 0 of 10; total allocated: 0 of 30]
2023.12.01 09:16:34 DEBUG app[]
[o.a.h.i.n.c.PoolingNHttpClientConnectionManager] Connection
request failed
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
....
[o.a.h.i.n.c.InternalHttpAsyncClient] [exchange: 1] connection request failed
2023.12.01 09:16:34 DEBUG app[][o.e.c.RestClient] request [GET http://127.0.0.1:9001/] failed
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
at
型
最后,这将导致前面引用的相同连接错误
问题是因为ElasticSearch开始,然后退出
我做错了什么,Sonarqube没有开始与postgresql JDBC配置完成?
衷心感谢您的建议/意见
Yogesh
1条答案
按热度按时间h5qlskok1#
问题确实出在elasticsearch上。
我指的是这个https://github.com/SonarSource/docker-sonarqube/issues/282
并且还
https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html的
Elasticsearch默认使用mmapfs目录来存储其索引。默认操作系统对mmap计数的限制太低,导致elasticsearch退出
我将vm.max_map_count设置为值262144,然后elasticsearch加上sonarqube开始工作
要在运行时运行命令中设置vm.max_map_count
字符串
要永久设置此值(重新启动后仍有效),请更新/etc/sysctl. conf中的vm.max_map_count设置。
第一个月
正如@andreypc在上面的评论中所建议的,还有其他参数,如最大线程数和打开文件参数。