天天看點

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

繼續閱讀