天天看点

centos安装SonarQube并汉化安装需求mysql创建用户和数据库安装SonarQubeSonarQube汉化

centos安装SonarQube并汉化

  • 安装需求
  • mysql创建用户和数据库
  • 安装SonarQube
  • SonarQube汉化

安装需求

名称 版本
jdk 1.8+
mysql MySQL >=5.6 && < 8.0
SonarQube

2020-01-21(SonarQube 7.9.2 LTS)

sonarQube8.0新特性支持gitlab

  • 安装地址

SonarQube官网下载地址:https://www.sonarqube.org/downloads/

SonarQube汉化地址:https://github.com/SonarQubeCommunity/sonar-l10n-zh/

wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.9.2.zip

mysql创建用户和数据库

#建库
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
#创建用户
CREATE USER 'sonar' IDENTIFIED BY 'password';
#授权
GRANT ALL ON sonar.* TO 'sonar'@"%" identified by "password";
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'password';
#刷新权限
FLUSH PRIVILEGES;
           

安装SonarQube

  • 从官网下载zip安装包

    wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.9.2.zip

  • 解压

    yum install -y unzip && unzip sonarqube-7.9.2.zip -d /opt/

  • 因为sonarqube组件包括ES所以不能用root用户启动。创建用户sonar

    useradd sonar

    chow -R sonar. /opt/sonarqube-7.9.2/

  • 编辑配置文件

    vim ./conf/sonar.properties

# Property values can:
# - reference an environment variable, for example sonar.jdbc.url= ${env:SONAR_JDBC_URL}
# - be encrypted. See https://redirect.sonarsource.com/doc/settings-encryption.html

#--------------------------------------------------------------------------------------------------
# DATABASE
#
# IMPORTANT:
# - The embedded H2 database is used by default. It is recommended for tests but not for
#   production use. Supported databases are MySQL, Oracle, PostgreSQL and Microsoft SQLServer.
# - Changes to database connection URL (sonar.jdbc.url) can affect SonarSource licensed products.

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username=数据库用户名sonar
sonar.jdbc.password=数据库sonar的密码

#----- Embedded Database (default)
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092

#----- DEPRECATED 
#----- MySQL >=5.6 && <8.0
# Support of MySQL is dropped in Data Center Editions and deprecated in all other editions
# Only InnoDB storage engine is supported (not myISAM).
# Only the bundled driver is supported. It can not be changed.

#jdbc连接串
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false


#----- Oracle 11g/12c
# The Oracle JDBC driver must be copied into the directory extensions/jdbc-driver/oracle/.
# Only the thin client is supported, and only the versions 11.2.x or 12.2.x must be used. See
# https://jira.sonarsource.com/browse/SONAR-9758 for more details.
# If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
#sonar.jdbc.url=jdbc:oracle:thin:@localhost:1521/XE


#-----连接池设置(可以分配的活动连接的最大数目)
#不限制可能会有负面影响。
#建议值为HTTP池的最大值的1.2倍。例如,如果HTTP端口是
#启用默认大小(50,请参阅属性sonar.web.http.maxThreads)
#那么sonar.jdbc.maxActive应该是1.2*50=60。
sonar.jdbc.maxActive=60

#数据库连接池最大空闲连接数
sonar.jdbc.maxIdle=5

#数据库最小连接数,0为不创建空闲线程
sonar.jdbc.minIdle=2

#连接池最大等待毫秒数(当前无可用连接,等至线程抛出异常)
#小于0表示无限期等待
sonar.jdbc.maxWait=5000

sonar.jdbc.minEvictableIdleTimeMillis=600000
sonar.jdbc.timeBetweenEvictionRunsMillis=30000

#Web Server网站的相关配置--------------------------------
#网站于JAVA环境运行,该项配置java启动的环境变量,内存cpu占用等,不建议修改
#sonar.web.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError

#网站bind地址,默认为0.0.0.0,建议设为内网地址
sonar.web.host=本机内网地址
#网站监听HTTP请求的TCP端口。默认9000
sonar.web.port=9000
           
  • 启动服务

    以sonar用户启动服务并查看日志,用法:console、start、status、stop、restart

    su sonar && ./bin/linux-x86-64/sonar.sh start && tail -f logs/sonar.log

    centos安装SonarQube并汉化安装需求mysql创建用户和数据库安装SonarQubeSonarQube汉化
    - 登录网站http://服务器地址:9000
  • 管理员默认账号密码 admin/admin
    centos安装SonarQube并汉化安装需求mysql创建用户和数据库安装SonarQubeSonarQube汉化

SonarQube汉化

  • 汉化插件版本对应
centos安装SonarQube并汉化安装需求mysql创建用户和数据库安装SonarQubeSonarQube汉化
例如7.9版本应使用1.29版本的汉化.jar
  • 汉化以插件形式提供 Chinese Pack
  • 安装方式有两种:在线/手动

    在线安装:

    centos安装SonarQube并汉化安装需求mysql创建用户和数据库安装SonarQubeSonarQube汉化
    手动安装:

    wget https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases/download/sonar-l10n-zh-plugin-8.1/sonar-l10n-zh-plugin-【版本号】.jar

    将下载好的插件放入到目录:

    ./extensions/plugins/

    后在重启服务即可

    ./bin/linux-x86-64/sonar.sh restart

继续阅读