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.mzph.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;保证…