SONAR下載地址: https://www.sonarqube.org/downloads/ (本文版本:sonarqube-6.3)
下載完解壓出來
根據你的電腦系統進到bin後的系統目錄 (本文機器,64位WIN7)
用CMD命令進入 E:\Program File\sonarqube-6.3\bin\windows-x86-64後執行 StartSonar.bat
E:\Program File\sonarqube-6.3\bin\windows-x86-64>StartSonar.bat
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | WrapperSimpleApp: Unable to locate the class org.sonar.application.App: java.lang.UnsupportedClassVersionError: org/sonar/application/App : Unsupport
ed major.minor version 52.0
jvm 1 |
jvm 1 | WrapperSimpleApp Usage:
jvm 1 | java org.tanukisoftware.wrapper.WrapperSimpleApp {app_class} [app_arguments]
jvm 1 |
jvm 1 | Where:
jvm 1 | app_class: The fully qualified class name of the application to run.
jvm 1 | app_arguments: The arguments that would normally be passed to the
jvm 1 | application.
wrapper | <-- Wrapper Stopped
請按任意鍵繼續. . .
這種錯誤是因爲JDK版本過低的問題,sonarqube-6.3需要JDK1.8+,所以電腦配置JDK1.8後,重新運行即可
在運行前先新建一個數據庫
在此我命名爲sonar
接下來修改
conf/sonar.properties文件,主要添加數據庫信息
sonar.jdbc.username=
sonar.jdbc.password=
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
如果沒有配置好數據庫則運行時會出現以下錯誤
E:\Program File\sonarqube-6.3\bin\windows-x86-64>StartSonar.bat
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2017.08.25 15:48:52 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory E:\Program File\sonarqube-6.3\temp
jvm 1 | 2017.08.25 15:48:53 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[es]: E:\software\java\jdk1.8.0_121\jre\bin\java -Djava.awt.headless=true
-Xmx1G -Xms256m -Xss256k -Djna.nosys=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:
+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=E:\Program File\sonarqube-6.3\temp -javaagent:E:\software\java\jdk1.8.0_121\jre\lib\management-agent.jar -cp ./lib/
common/*;./lib/search/* org.sonar.search.SearchServer E:\Program File\sonarqube-6.3\temp\sq-process1206689812975548668properties
jvm 1 | 2017.08.25 15:49:05 INFO app[][o.s.p.m.Monitor] Process[es] is up
jvm 1 | 2017.08.25 15:49:05 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[web]: E:\software\java\jdk1.8.0_121\jre\bin\java -Djava.awt.headless=true
-Dfile.encoding=UTF-8 -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=E:\Program File\sonarqube-6.3\temp -javaagent:E:\software\java\jdk1.8.
0_121\jre\lib\management-agent.jar -cp ./lib/common/*;./lib/server/*;E:\Program File\sonarqube-6.3\lib\jdbc\mysql\mysql-connector-java-5.1.39.jar org.sonar.serv
er.app.WebServer E:\Program File\sonarqube-6.3\temp\sq-process3901561166471593448properties
jvm 1 | Fri Aug 25 15:49:10 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
jvm 1 | 2017.08.25 15:49:12 INFO app[][o.s.p.m.Monitor] Process[es] is stopping
jvm 1 | 2017.08.25 15:49:12 ERROR app[][o.s.p.m.Monitor] Process[web] failed to start
jvm 1 | 2017.08.25 15:49:13 INFO app[][o.s.p.m.Monitor] Process[es] is stopped
wrapper | <-- Wrapper Stopped
弄好數據庫配置後重新運行
我們可以看到腳本會往SONAR這個庫創建很多表及自動插入一些數據
執行成功的日誌如下
E:\Program File\sonarqube-6.3\bin\windows-x86-64>StartSonar.bat
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2017.08.25 15:50:42 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory E:\Program File\sonarqube-6.3\temp
jvm 1 | 2017.08.25 15:50:42 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[es]: E:\software\java\jdk1.8.0_121\jre\bin\java -Djava.awt.headless=true
-Xmx1G -Xms256m -Xss256k -Djna.nosys=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:
+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=E:\Program File\sonarqube-6.3\temp -javaagent:E:\software\java\jdk1.8.0_121\jre\lib\management-agent.jar -cp ./lib/
common/*;./lib/search/* org.sonar.search.SearchServer E:\Program File\sonarqube-6.3\temp\sq-process1379441345670336396properties
jvm 1 | 2017.08.25 15:50:53 INFO app[][o.s.p.m.Monitor] Process[es] is up
jvm 1 | 2017.08.25 15:50:53 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[web]: E:\software\java\jdk1.8.0_121\jre\bin\java -Djava.awt.headless=true
-Dfile.encoding=UTF-8 -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=E:\Program File\sonarqube-6.3\temp -javaagent:E:\software\java\jdk1.8.
0_121\jre\lib\management-agent.jar -cp ./lib/common/*;./lib/server/*;E:\Program File\sonarqube-6.3\lib\jdbc\mysql\mysql-connector-java-5.1.39.jar org.sonar.serv
er.app.WebServer E:\Program File\sonarqube-6.3\temp\sq-process8409360607056740017properties
jvm 1 | Fri Aug 25 15:50:57 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
jvm 1 | Fri Aug 25 15:50:57 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
jvm 1 | Fri Aug 25 15:51:06 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
jvm 1 | Fri Aug 25 15:51:27 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
jvm 1 | 2017.08.25 15:51:33 INFO app[][o.s.p.m.Monitor] Process[web] is up
jvm 1 | 2017.08.25 15:51:33 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[ce]: E:\software\java\jdk1.8.0_121\jre\bin\java -Djava.awt.headless=true
-Dfile.encoding=UTF-8 -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=E:\Program File\sonarqube-6.3\temp -javaagent:E:\software\java\jdk1.8.0
_121\jre\lib\management-agent.jar -cp ./lib/common/*;./lib/server/*;./lib/ce/*;E:\Program File\sonarqube-6.3\lib\jdbc\mysql\mysql-connector-java-5.1.39.jar org.
sonar.ce.app.CeServer E:\Program File\sonarqube-6.3\temp\sq-process3449682494564184520properties
jvm 1 | Fri Aug 25 15:51:37 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
jvm 1 | Fri Aug 25 15:51:37 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
jvm 1 | 2017.08.25 15:51:41 INFO app[][o.s.p.m.Monitor] Process[ce] is up
jvm 1 | 2017.08.25 15:51:41 INFO app[][o.s.application.App] SonarQube is up
jvm 1 | Fri Aug 25 15:52:07 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using
SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
ruststore for server certificate verification.
看到最後出現紅色字體就說明SONAR啓動成功了,我們測試一下
在瀏覽器輸入http://localhost:9000
說明啓動成功,登陸的話默認賬號有admin/admin (用戶信息保存在數據庫表users)