0.参考文档
https://www.sonarqube.org/downloads/
JDK11 下载地址:
参考https://www.cnblogs.com/schblog/p/13287799.html
1.下载软件包
下载链接: https://www.sonarqube.org/downloads/
2.添加系统用户
|
1
2
|
useradd sonarqubepasswd sonarqube |
3.优化系统参数
|
1
2
3
4
|
sysctl -w vm.max_map_count=262144sysctl -w fs.file-max=65536ulimit -u 4096 sonarqubeulimit -n 65536 sonarqube |
永久修改系统参数:
1.vi /etc/sysctl.conf
在最后增加两行:
vm.max_map_count=262144
fs.file-max=65536
然后再控制台输入sysctl -p 写入内存,即可立即生效
2.vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
@sonarqube soft noproc 4096
@sonarqube hard noproc 4096
截图如下:
sysctl.conf文件:

limits.conf文件:

4.解压安装包
|
1
2
3
4
5
|
mv sonarqube-7.9.1.zip /home/sonarqube/chown -R sonarqube:sonarqube /home/sonarqube/su - sonarqubeyum -y install unzipunzip sonarqube-7.9.1.zip |
5.更改配置文件
|
1
2
3
4
5
6
|
vim sonarqube-7.9.1/conf/sonar.properties[sonarqube@localhost ~]$ grep -v "^#" sonarqube-7.9.1/conf/sonar.properties | grep -v "^$"sonar.jdbc.username=sonarqubesonar.jdbc.password=meiyoumimasonar.jdbc.url=jdbc:postgresql://127.0.0.1/sonarqube |
6.安装PostgreSQL#下载pg9.6 源
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<em id="__mceDel">yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpmyum install postgresql96-server postgresql96-contrib#初始化db/usr/pgsql-9.6/bin/postgresql96-setup initdb#启动服务、开机自启systemctl start postgresql-9.6systemctl enable postgresql-9.6#防火墙firewall-cmd --add-service=postgresql --permanentfirewall-cmd --reload #登录数据库su - postgrespsql -U postgresALTER USER postgres with encrypted password 'xxxxxx';qexit<br><br>#创建sonarqube用户<br>create user sonarqube with password 'xxxxx';<br>create database sonarqube owner sonarqube;<br>grant all on database sonarqube to sonarqube;<br>create schema my_schema;<br>#开启远程访问vi /var/lib/pgsql/9.6/data/postgresql.conf #listen_addresses = '*' vi /var/lib/pgsql/9.6/data/pg_hba.conf<br><br>systemctl restart postgresql-9.6.service<br><br>#pg_hba.conf</em> |
|
1
2
3
4
5
6
7
8
9
10
|
# IPv4 local connections:host all all 0.0.0.0/0 trust# IPv6 local connections:host all all ::1/128 ident# Allow replication connections from localhost, by a user with the# replication privilege.#local replication postgres peer#host replication postgres 127.0.0.1/32 ident#host replication postgres ::1/128 identhost all all 0.0.0.0/0 ident |
7.添加系统服务
配置服务参考官网:https://docs.sonarqube.org/7.9/setup/operate-server/
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
ln -s /home/sonarqube/sonarqube-7.9.1/bin/linux-x86-64/sonar.sh /usr/bin/sonarvim /etc/init.d/sonarqube#!/bin/sh## rc file for SonarQube## chkconfig: 345 96 10# description: SonarQube system (www.sonarsource.org)#### BEGIN INIT INFO# Provides: sonar# Required-Start: $network# Required-Stop: $network# Default-Start: 3 4 5# Default-Stop: 0 1 2 6# Short-Description: SonarQube system (www.sonarsource.org)# Description: SonarQube system (www.sonarsource.org)### END INIT INFO/usr/bin/sonar $*chkconfig --add sonarqubechkconfig sonarqube onservice sonarqube status |
8.FAQ
1. JDK11错误: 需要安装JDK11
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[sonarqube@localhost linux-x86-64]$ ./sonar.sh consoleRunning SonarQube...wrapper | --> Wrapper Started as Consolewrapper | Launching a JVM...jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.orgjvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.jvm 1 |jvm 1 | 20:46:06.753 [WrapperSimpleAppMain] WARN org.sonar.application.config.JdbcSettings - JDBC URL is recommended to have the property 'rewriteBatchedStatements=true'jvm 1 | 20:46:06.764 [WrapperSimpleAppMain] WARN org.sonar.application.config.JdbcSettings - JDBC URL is recommended to have the property 'useConfigs=maxPerformance'jvm 1 |jvm 1 | WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11+ to runjvm 1 | java.lang.IllegalStateException: SonarQube requires Java 11+ to runjvm 1 | at org.sonar.application.App.checkJavaVersion(App.java:93)jvm 1 | at org.sonar.application.App.start(App.java:56)jvm 1 | at org.sonar.application.App.main(App.java:98)jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)jvm 1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)jvm 1 | at java.lang.reflect.Method.invoke(Method.java:498)jvm 1 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)jvm 1 | at java.lang.Thread.run(Thread.java:748)wrapper | <-- Wrapper Stopped |
2.MySQL数据库不支持

参考:https://www.cnblogs.com/mascot1/p/11179767.html