SonarQube的安装部署过程中踩过的坑

在安装和是用sonarqube踩过如下坑,记录一下:

 

1、java版本不正确

java版本的问题,主要体现在两个方面,

第一个:是需要安装对应电脑版本的jdk, 具体报如下错误:

Unable to load the Wrapper's native library 'wrapper.dll'.
          The file is located on the path at the following location but
          could not be loaded:
            F:\sonarqube-8.3.1.34397\bin\windows-x86-64\.\lib\wrapper.dll
          Please verify that the file is readable by the current user
          and that the file has not been corrupted in any way.
          One common cause of this problem is running a 32-bit version
          of the Wrapper with a 64-bit version of Java, or vica versa.
          This is a 32-bit JVM.

原因:因为本人的电脑是64位,却安装了32位的jdk

第二个:是需要安装对应sonarqube的jdk, 具体报如下错误:

WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11 to run

ava.lang.IllegalStateException: SonarQube requires Java 11 to run
    at com.google.common.base.Preconditions.checkState(Preconditions.java:508)
    at org.sonar.application.App.checkJavaVersion(App.java:94)
    at org.sonar.application.App.start(App.java:57)
    at org.sonar.application.App.main(App.java:98)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
    at java.lang.Thread.run(Thread.java:748)
<-- Wrapper Stopped

 

2、sonarqube不能启动java

修改wrapper.conf配置文件

SonarQube的安装部署过程中踩过的坑

 

3、一直报java.io.IOException: 远程主机强迫关闭了一个现有的连接。

--> Wrapper Started as Console
Launching a JVM...
2020.05.20 16:58:10 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2020.05.20 16:58:10 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [F:\sonarqube-8.3.1.34397]: C:\Program Files\Java\jdk-11.0.7\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=F:\sonarqube-8.3.1.34397\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/common/*;F:\sonarqube-8.3.1.34397\lib\jdbc\postgresql\postgresql-42.2.11.jar org.sonar.server.app.WebServer F:\sonarqube-8.3.1.34397\temp\sq-process5431657342893089302properties
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2020.05.20 16:58:10 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory F:\sonarqube-8.3.1.34397\temp
2020.05.20 16:58:10 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
Exception in thread "main" java.lang.IllegalStateException: Could not read properties from file: F:\sonarqube-8.3.1.34397\temp\sq-process5431657342893089302properties
    at org.sonar.process.ConfigurationUtils.loadPropsFromCommandLineArgs(ConfigurationUtils.java:78)
    at org.sonar.process.ProcessEntryPoint.createForArguments(ProcessEntryPoint.java:169)
    at org.sonar.server.app.WebServer.main(WebServer.java:95)
Caused by: java.io.FileNotFoundException: F:\sonarqube-8.3.1.34397\temp\sq-process5431657342893089302properties (系统找不到指定的文件。)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
    at org.sonar.process.ConfigurationUtils.loadPropsFromCommandLineArgs(ConfigurationUtils.java:75)
    ... 2 more
2020.05.20 16:58:10 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [F:\sonarqube-8.3.1.34397\elasticsearch]: C:\Program Files\Java\jdk-11.0.7\bin\java -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=F:\sonarqube-8.3.1.34397\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.enforce.bootstrap.checks=true -Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=F:\sonarqube-8.3.1.34397\elasticsearch -Des.path.conf=F:\sonarqube-8.3.1.34397\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
2020.05.20 16:58:10 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2020.05.20 16:58:10 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [web]: 1
2020.05.20 16:58:10 INFO  app[][o.s.a.SchedulerImpl] Process[web] is stopped
2020.05.20 16:58:10 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2020.05.20 16:58:10 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
2020.05.20 16:58:10 WARN  app[][o.e.t.TcpTransport] exception caught on transport layer [Netty4TcpChannel{localAddress=/127.0.0.1:51118, remoteAddress=/127.0.0.1:9001}], closing connection
java.io.IOException: 远程主机强迫关闭了一个现有的连接。
    at java.base/sun.nio.ch.SocketDispatcher.read0(Native Method)
    at java.base/sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
    at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:233)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223)
    at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:358)
    at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:433)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:656)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:591)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:508)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:470)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
    at java.base/java.lang.Thread.run(Thread.java:834)
2020.05.20 16:58:10 WARN  app[][o.e.t.TcpTransport] exception caught on transport layer [Netty4TcpChannel{localAddress=/127.0.0.1:51120, remoteAddress=/127.0.0.1:9001}], closing connection
java.io.IOException: 远程主机强迫关闭了一个现有的连接。
    at java.base/sun.nio.ch.SocketDispatcher.read0(Native Method)
    at java.base/sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
    at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:233)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223)
    at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:358)
    at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:433)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:656)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:591)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:508)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:470)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
    at java.base/java.lang.Thread.run(Thread.java:834)
2020.05.20 16:58:10 WARN  app[][o.e.t.TcpTransport] exception caught on transport layer [Netty4TcpChannel{localAddress=/127.0.0.1:51112, remoteAddress=/127.0.0.1:9001}], closing connection
java.io.IOException: 远程主机强迫关闭了一个现有的连接。
    at java.base/sun.nio.ch.SocketDispatcher.read0(Native Method)
    at java.base/sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
    at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:233)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223)
    at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:358)
    at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:433)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:656)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:591)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:508)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:470)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
    at java.base/java.lang.Thread.run(Thread.java:834)
2020.05.20 16:58:10 WARN  app[][o.e.t.TcpTransport] exception caught on transport layer [Netty4TcpChannel{localAddress=/127.0.0.1:51115, remoteAddress=/127.0.0.1:9001}], closing connection
java.io.IOException: 远程主机强迫关闭了一个现有的连接。

原因:

     报这个错的原因,主要因为数据库连接不成功或者端口被占用,

解决办法,首先检查一下数据库能否正确连接,如果能,请检查配置文件的参数是否正确,如果正确,确定端口是否被占用

需要修改配置sonar.properties文件

SonarQube的安装部署过程中踩过的坑

 

报如下错误The SonarQube service is not installed - 指定的服务未安装。 (0x0)

OpenSCManager failed - 拒绝访问。 (0x0)
The SonarQube service was not running.
SonarQube removed.
OpenSCManager failed - 拒绝访问。 (0x0)
The SonarQube service is not installed - 指定的服务未安装。 (0x0)
The SonarQube service is not installed - 指定的服务未安装。 (0x0)

 

5、在使用sonar-scanner时报错:

这里需要几点需要注意,就是在写配置文件的时候,需要注意:

#projectKey是项目的唯一标识,不能出现重复,可随意起,并且不能纯数字,推荐英文即可
sonar.projectKey=xxx
# this is the name displayed in the SonarQube UI,不能是中文
sonar.projectName=yyyy