SonarQube數據庫配置

SonarQube部署完成后,在瀏覽器地址欄輸入http://IP:9000可以進入登錄頁面,以本機運行為例,地址為http://127.0.0.1:9000/,默認登錄名:admin,登錄密碼也是admin。登錄后會要求設置密碼:
修改密碼
按要求設置新密碼即可,系統要求如下:
pwd requirement
設置后即可登錄系統:
index
從圖中可見,如果用默認的嵌入式數據庫(H2)的話,會有僅作測試用提示:

Embedded database should be used for evaluation purposes only. It doesn’t support scaling, upgrading to a new SonarQube Server version, or migration to another database engine.

插件安裝

點擊配置、應用市場:“Administration->Marketplace”,可以安裝插件,這里我們以“Chinese Pack”中文語言包為例。
plugins
安裝后界面變成了中文。此外應用市場Marketplace還有很多插件可以供我們使用,這個可以在使用過程中逐漸探索。安裝完成后系統會要求重啟(啟用插件)或復原(回退):
marketplace restart
點擊重啟按鈕“Restart Server”后,會自動重啟服務:
backend
重啟后系統需要重新登錄:
login
登錄后界面變成中文的了:
ch

數據庫配置

SonarQube默認是H2數據庫,但事實上它支持OraclePostgreSQLMicrosoft SQLServer,四種數據庫,通過修改config文件夾下sonar.propertiessonar.jdbc.url屬性,可以指向我們要使用的數據庫。
整個sonar.properties文件的數據庫配置部分摘錄如下:

#--------------------------------------------------------------------------------------------------
# DATABASE
#
# IMPORTANT:
# - The embedded H2 database is used by default. It is recommended for tests but not for
#   production use. Supported databases are 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.jdbc.password=#----- Embedded Database (default)
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092#----- Oracle 19c/21c
# The Oracle JDBC driver must be copied into the directory extensions/jdbc-driver/oracle/.
# Only the thin client is supported, and we recommend using the latest Oracle JDBC driver. 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#----- PostgreSQL 11 or greater
# By default the schema named "public" is used. It can be overridden with the parameter "currentSchema".
#sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube?currentSchema=my_schema#----- Microsoft SQLServer 2014/2016/2017/2019/2022 and SQL Azure
# A database named sonar must exist and its collation must be case-sensitive (CS) and accent-sensitive (AS)
# Use the following connection string if you want to use integrated security with Microsoft Sql Server
# Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security
# For Integrated Security to work, you have to install the Microsoft SQL JDBC Auth package
# Please refer to the online documentation https://docs.sonarsource.com/sonarqube
# for the exact procedure for this version of SonarQube.
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;integratedSecurity=true# Use the following connection string if you want to use SQL Auth while connecting to MS Sql Server.
# Set the sonar.jdbc.username and sonar.jdbc.password appropriately.
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar#----- Connection pool settings
# The maximum number of active connections that can be allocated
# at the same time, or negative for no limit.
# The recommended value is 1.2 * max sizes of HTTP pools. For example if HTTP ports are
# enabled with default sizes (50, see property sonar.web.http.maxThreads)
# then sonar.jdbc.maxActive should be 1.2 * 50 = 60.
#sonar.jdbc.maxActive=60# The minimum number of connections that can remain idle in the pool,
# without extra ones being created, or zero to create none.
#sonar.jdbc.minIdle=10# The maximum number of milliseconds that the pool will wait (when there
# are no available connections) for a connection to be returned before
# throwing an exception, or <= 0 to wait indefinitely.
#sonar.jdbc.maxWait=8000

1. 支持的數據庫
參考官方文檔(Database requirements | SonarQube Community Build Documentation)及前述,我們可以看出,SonarQube支持以下數據庫引擎:

數據庫引擎安裝要求
PostgreSQL版本:13-17(官方文檔要求,實際上看配置文件,支持版本11及以上)
Microsoft SQLServer

官方文檔版本要求:

2022 (MSSQL Server 16.0); 2019 (MSSQL Server 15.0); 2017 (MSSQL Server 14.0); 2016 (MSSQL Server 13.0),需要Micorsoft JDBC驅動(SonarQubelib目錄已包含)

配置文件實際版本要求:

Microsoft SQLServer 2014/2016/2017/2019/2022 and SQL Azure

注:

  • 支持SQL Server Express版本
  • 支持WindowsSQL Server兩種身份驗證方式

Oracle

版本要求:23ai, 21C, 19C, XE Editions

推薦:最新版本的 Oracle JDBC驅動

注:

  • 不支持odbc14.jar驅動
  • 只支持thin模式,不支持OCI
  • 只支持MAX_STRING_SIZE=STANDARD參數,不支持EXTENDED
  • Oracle JDBC 驅動12.1.0.112.1.0.2有較大bug不推薦應用在SonarQube社區版中(點擊可查看詳情)

2. 修改數據庫連接
Microsoft SQL Server為例,我們嘗試對SonarQube連接的數據庫進行配置。
(1)數據庫創建
create db
ssms
需要注意的是,SonarQube要求大小寫和強調差異(case-sensitive and accent-sensitive)敏感的排序規則,如:Chinese_PRC_CS_AS

ALTER DATABASE sonar COLLATE Chinese_PRC_CS_AS

collate
(2)數據庫連接修改
根據config/sonar.properties配置文件的說明,修改連接指向后,表結構等內容會自動創建(要求具有相應權限)。
首先,我們設置數據庫的用戶名和密碼:

sonar.jdbc.username=your_db_user
sonar.jdbc.password=your_db_password

接著,我們修改數據庫連接字符串,對于SQL Server,其配置參考如下:

#----- Microsoft SQLServer 2014/2016/2017/2019/2022 and SQL Azure
# A database named sonar must exist and its collation must be case-sensitive (CS) and accent-sensitive (AS)
# Use the following connection string if you want to use integrated security with Microsoft Sql Server
# Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security
# For Integrated Security to work, you have to install the Microsoft SQL JDBC Auth package
# Please refer to the online documentation https://docs.sonarsource.com/sonarqube
# for the exact procedure for this version of SonarQube.
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;integratedSecurity=true# Use the following connection string if you want to use SQL Auth while connecting to MS Sql Server.
# Set the sonar.jdbc.username and sonar.jdbc.password appropriately.
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar

我們可以選擇集成安全模式(需要安裝配套的包),或使用SQL Server自己的鑒權方式,本例為了簡單我們選擇后者,考慮本機連接,Encrypt屬性設置為truetrustServerCertificate屬性設置為true(信任服務器證書,使用自簽名證書,否則會報錯的):

sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;encrypt=true;trustServerCertificate=true

(3)修改后運行效果
重新啟動SonarQube服務,我們可以觀察到如下變化:
restart sonarqube
1)數據庫相關對象自動創建了
db tables
2)密碼需要重新設定登錄
因為換了數據庫,需要重新設置密碼并登錄。
relogin

從上圖也可以看出不再提示測試數據庫環境(H2)了。

總結

至此,我本機環境的SonarQube實現了數據庫的更改,當然,在實際的應用中使用Docker容器安裝Sonar會簡便很多,但為了對這個工具有更多了解(踩更多的坑,更改數據庫配置過程也遇到一些問題,參見這里),手工操作也是一個不錯的體驗。
接下來,我將嘗試對這個工具做更多的學習、應用與探索。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/74719.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/74719.shtml
英文地址,請注明出處:http://en.pswp.cn/web/74719.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

醫藥檔案區塊鏈系統

1. 醫生用戶模塊?? ??目標用戶??&#xff1a;醫護人員 ??核心功能??&#xff1a; ??檢索檔案??&#xff1a;通過關鍵詞或篩選條件快速定位患者健康檔案。??請求授權??&#xff1a;向個人用戶發起檔案訪問權限申請&#xff0c;需經對方確認。??查看檔案?…

CSS3學習教程,從入門到精通, 化妝品網站 HTML5 + CSS3 完整項目(26)

化妝品網站 HTML5 CSS3 完整項目 下面是一個完整的化妝品網站項目&#xff0c;包含主頁、登錄頁面和注冊頁面。我將按照您的要求提供詳細的代碼和注釋。 1. 網站規劃與需求分析 需求分析 展示化妝品產品信息提供用戶注冊和登錄功能響應式設計&#xff0c;適配不同設備美觀…

ROS2 多機時間同步(Chrony配置簡明指南)

適用場景&#xff1a; 主機運行 ROS2 Humble&#xff08;發布 /scan 等&#xff09;&#xff0c;板子運行 ROS2 Foxy&#xff08;發布 /tf 等&#xff09;&#xff0c;兩邊通過 ROS_DOMAIN_ID 跨平臺通訊。需要保證系統時間對齊&#xff0c;避免 TF 插值失敗、建圖抖動等問題。…

Nginx配置偽靜態,URL重寫

Nginx配置偽靜態&#xff0c;URL重寫 [ Nginx ] 在Nginx低版本中&#xff0c;是不支持PATHINFO的&#xff0c;但是可以通過在Nginx.conf中配置轉發規則實現&#xff1a; location / { // …..省略部分代碼if (!-e $request_filename) {rewrite ^(.*)$ /index.php?s/$1 l…

電路筆記(元器件):ADC LTC系列模數轉換器的輸出范圍+滿量程和偏移調整

LTC1740(LTC1740官方文檔)是Analog Devices&#xff08;原Linear Technology&#xff09;公司生產的一款高性能、低功耗的14位模數轉換器(ADC)。它通常用于需要高精度和快速采樣率的應用中&#xff0c;如通信系統、數據采集設備等。同類產品 LTC1746&#xff1a;一款14位、40Ms…

續-算法-數學知識

3、歐拉函數 1、定義&#xff1a; 1~n 中與 n 互質的數的個數 例如&#xff1a;6 的有 1 2 3 4 5 6 其中&#xff0c;與 n 互質 的 數的個數為 2個分別是&#xff1a;1、5 2、計算&#xff1a; $ N p_1^{a1} p_2^{a2} p_3^{a3} … p_k^{ak} $&#xff08;例如&#x…

C/C++測試框架googletest使用示例

文章目錄 文檔編譯安裝示例參考文章 文檔 https://github.com/google/googletest https://google.github.io/googletest/ 編譯安裝 googletest是cmake項目&#xff0c;可以用cmake指令編譯 cmake -B build && cmake --build build將編譯產物lib和include 兩個文件夾…

LintCode第974題-求矩陣各節點的最短路徑(以0為標準)

描述 給定一個由0和1組成的矩陣&#xff0c;求每個單元格最近的0的距離。 兩個相鄰細胞之間的距離是1。 給定矩陣的元素數不超過10,000。 在給定的矩陣中至少有一個0。 單元格在四個方向上相鄰:上&#xff0c;下&#xff0c;左和右。 樣例 例1: 輸入: [[0,0,0],[0,0,0],[0…

Redis核心機制-緩存、分布式鎖

目錄 緩存 緩存更新策略 定期生成 實時生成 緩存問題 緩存預熱&#xff08;Cache preheating&#xff09; 緩存穿透&#xff08;Cache penetration&#xff09; 緩存雪崩&#xff08;Cache avalanche&#xff09; 緩存擊穿&#xff08;Cache breakdown&#xff09; 分…

CF每日5題(1300-1500)

最近急速補練藍橋杯中&#xff0c;疏于cf練習。 感覺自己過題還是太慢了。 今日水題&#xff0c;我水水水水。 1- 1979C lcm 水 1400 第 i i i局贏了&#xff0c;1個硬幣頂 k [ i ] k[i] k[i]個貢獻&#xff0c;所以每局分硬幣 x i 1 k [ i ] x_i{1\over k[i]} xi?k[i]1?個…

從代碼學習深度學習 - LSTM PyTorch版

文章目錄 前言一、數據加載與預處理1.1 代碼實現1.2 功能解析二、LSTM介紹2.1 LSTM原理2.2 模型定義代碼解析三、訓練與預測3.1 訓練邏輯代碼解析3.2 可視化工具功能解析功能結果總結前言 深度學習中的循環神經網絡(RNN)及其變種長短期記憶網絡(LSTM)在處理序列數據(如文…

easy-poi 一對多導出

1. 需求&#xff1a; 某一列上下兩行單元格A,B值一樣且這兩個單元格&#xff0c; 前面所有列對應單元格值一樣的話&#xff0c; 就對A,B 兩個單元格進行縱向合并單元格 1. 核心思路&#xff1a; 先對數據集的國家&#xff0c;省份&#xff0c;城市...... id 身份證進行排序…

AI比人腦更強,因為被植入思維模型【42】思維投影思維模型

giszz的理解&#xff1a;本質和外在。我們的行為舉止&#xff0c;都是我們的內心的表現。從外邊可以看內心&#xff0c;從內心可以判斷外在。曾國藩有&#xff17;個識人的方法&#xff0c;大部分的人在他的面前如同沒穿衣服一樣。對于我們自身的啟迪&#xff0c;我認為有四點&…

Spring Boot 打印日志

1.通過slf4j包中的logger對象打印日志 Spring Boot內置了日志框架slf4j&#xff0c;在程序中調用slf4j來輸出日志 通過創建logger對象打印日志&#xff0c;Logger 對象是屬于 org.slf4j 包下的不要導錯包。 2.日志級別 日志級別從高到低依次為: FATAL:致命信息&#xff0c;表…

【IOS webview】源代碼映射錯誤,頁面卡住不動

報錯場景 safari頁面報源代碼映射錯誤&#xff0c;頁面卡住不動。 機型&#xff1a;IOS13 技術棧&#xff1a;react 其他IOS也會報錯&#xff0c;但不影響頁面顯示。 debug webpack配置不要GENERATE_SOURCEMAP。 解決方法&#xff1a; GENERATE_SOURCEMAPfalse react-app…

ES中經緯度查詢geo_point

0. ES版本 6.x版本 1. 創建索引 PUT /location {"settings": {"number_of_shards": 1,"number_of_replicas": 0},"mappings": {"location": {"properties": {"id": {"type": "keywor…

OpenCV界面編程

《OpenCV計算機視覺開發實踐&#xff1a;基于Python&#xff08;人工智能技術叢書&#xff09;》(朱文偉&#xff0c;李建英)【摘要 書評 試讀】- 京東圖書 OpenCV的Python開發環境搭建(Windows)-CSDN博客 OpenCV也支持有限的界面編程&#xff0c;主要是針對窗口、控件和鼠標…

GOC L2 第五課模運算和周期二

課堂回顧&#xff1a; 求取余數的過程叫做模運算 每輪的動作都是重復的&#xff0c;我們稱這個過程位周期。 課堂學習&#xff1a; 剩余計算器 秋天到了&#xff0c;學校里的蘋果熟了&#xff0c;太乙老師&#xff0c;想讓哪吒幫忙設計一個計算器&#xff0c;看每個小朋友能分…

54.大學生心理健康管理系統(基于springboot項目)

目錄 1.系統的受眾說明 2.相關技術 2.1 B/S結構 2.2 MySQL數據庫 3.系統分析 3.1可行性分析 3.1.1時間可行性 3.1.2 經濟可行性 3.1.3 操作可行性 3.1.4 技術可行性 3.1.5 法律可行性 3.2系統流程分析 3.3系統功能需求分析 3.4 系統非功能需求分析 4.系統設計…

Redis 除了數據類型外的核心功能 的詳細說明,包含事務、流水線、發布/訂閱、Lua 腳本的完整代碼示例和表格總結

以下是 Redis 除了數據類型外的核心功能 的詳細說明&#xff0c;包含事務、流水線、發布/訂閱、Lua 腳本的完整代碼示例和表格總結&#xff1a; 1. Redis 事務&#xff08;Transactions&#xff09; 功能描述 事務通過 MULTI 和 EXEC 命令將一組命令打包執行&#xff0c;保證…