如何将当前平台升级到SonarQube7.9?[最新]
整体思路
- 准备测试数据(实际环境可跳过此步骤)
- 数据库迁移(从版本7.9开始,SonarQube将不再支持MySQL,Mysql-->PG)
- Sonar版本升级(6.7.7 -> 7.9.1)
准备测试数据
创建用户数据

创建项目数据
安装sonar-scanner(mac)
tar zxf sonar-scanner-4.0.0.1744-macosx.tar.gz -C /usr/local/
export SONAR_HOME=/usr/local/sonar-scanner-4.0.0.1744-macosx
export PATH=$PATH:$M2_HOME/bin:$SONAR_HOME/bin
获取maven项目
git clone https://github.com/zeyangli/simple-java-maven-app.git
mvn clean package
ls -l target/ | awk '{print $NF}'
classes
maven-archiver
maven-status
my-app-1.1-SNAPSHOT.jar
surefire-reports
test-classes
扫描项目
写个for循环,循环执行。 执行两次该脚本(因第一次分析的时候没有缺陷会不显示数据)
#!/bin/bash projectName="demo-service"
scanTime=`date +%Y%m%d%H%M%S` for((i=1;i<=10;i++))
do
sonar-scanner -Dsonar.host.url=http://xxxxxx:9000 \
-Dsonar.projectKey=${projectName}${i} \
-Dsonar.projectName=${projectName}${i} \
-Dsonar.projectVersion=${scanTime} \
-Dsonar.login=admin \
-Dsonar.password=admin \
-Dsonar.ws.timeout=30 \
-Dsonar.projectDescription="my first project!" \
-Dsonar.links.homepage=http://www.baidu.com \
-Dsonar.sources=src \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.java.binaries=target/classes \
-Dsonar.java.test.binaries=target/test-classes \
-Dsonar.java.surefire.report=target/surefire-reports echo "${projectName} scan success!"
done
效果

准备迁移数据库
- 请注意我们要做的是数据库迁移,是将MySQL迁移到PG数据库。
- 我们需要启动一个跟当前同版本的sonar来完成迁移。
- 若启动不同版本的sonar会报错,详见FAQ2。
备份MySQL
[root@devops ~]# mysqldump -h 127.0.0.1 -uroot -p sonar >sonar-190803.sql
Enter password:
[root@devops ~]# du -sh sonar-190803.sql
4.6M sonar-190803.sql
配置PG
#安装
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
yum install postgresql96-server postgresql96-contrib
/usr/pgsql-9.6/bin/postgresql96-setup initdb
systemctl start postgresql-9.6
systemctl enable postgresql-9.6
#创建Sonar数据库
su - postgres
psql
create user sonarqube with password 'sonarqube';
create database sonarqube owner sonarqube;
grant all on database sonarqube to sonarqube;
\q
#远程访问设置
vi /var/lib/pgsql/9.6/data/postgresql.conf
#listen_addresses = '*'
vi /var/lib/pgsql/9.6/data/pg_hba.conf
# 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 ident
host all all 0.0.0.0/0 ident
启动新Sonar
#安装同版本Sonarqube
mkdir pg
unzip sonarqube-6.7.7.zip -d pg/
cp sonarqube-6.7.7/conf/sonar.properties pg/sonarqube-6.7.7/conf/sonar.properties #跟源sonar配置相同,唯一不同的是数据库配置。要改成postgreSQL。
sonar.jdbc.username=xxxx
sonar.jdbc.password=xxxx
sonar.jdbc.url=jdbc:postgresql://127.0.0.1/sonarqube #一定要启动,否则会报错。提示找到目标数据库中的版本信息。详见FAQ1
./sonar.sh start
MySQL Migrator工具
#解压
wget https://binaries.sonarsource.com/Distribution/mysql-migrator/mysql-migrator-1.1.0.119.zip
unzip mysql-migrator-1.1.0.119.zip && cd bin
#source.properties
sonar.jdbc.username=xxxx
sonar.jdbc.password=xxxx
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
#target.properties
sonar.jdbc.username=xxxx
sonar.jdbc.password=xxxx
sonar.jdbc.url=jdbc:postgresql://127.0.0.1/sonarqube
# 运行迁移工具
./mysql-migrator -source source.properties -target target.properties
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table organizations ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table organization_members ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table groups_users ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table rules_parameters ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table rules_profiles ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table org_qprofiles ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table default_qprofiles ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table project_qprofiles ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table qprofile_edit_users ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table qprofile_edit_groups ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table groups ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table snapshots ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table group_roles ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table rule_repositories ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table rules ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table rules_metadata ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table events ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table quality_gates ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table quality_gate_conditions ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table properties ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table project_links ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table duplications_index ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table project_measures ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table internal_properties ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table projects ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table manual_measures ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table active_rules ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table notifications ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table user_roles ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table active_rule_parameters ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table users ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table metrics ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table loaded_templates ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table issues ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table issue_changes ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table permission_templates ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table perm_tpl_characteristics ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table perm_templates_users ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table perm_templates_groups ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table qprofile_changes ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table file_sources ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table ce_queue ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table ce_activity ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table ce_task_characteristics ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table ce_task_input ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table ce_scanner_context ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table user_tokens ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table webhook_deliveries ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table es_queue ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table plugins ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table project_branches ...
[main] INFO org.sonarsource.sqdbmigrator.migrator.ContentCopier - copying table analysis_properties ...
Tables Records Seconds
------------------------ ------- -------
organizations 1 0.1
organization_members 4 0.0
groups_users 5 0.0
rules_parameters 686 0.1
rules_profiles 18 0.0
org_qprofiles 18 0.0
default_qprofiles 9 0.1
project_qprofiles 0 0.0
qprofile_edit_users 0 0.0
qprofile_edit_groups 0 0.0
groups 2 0.0
snapshots 22 0.0
group_roles 28 0.0
rule_repositories 25 0.0
rules 2888 0.3
rules_metadata 0 0.0
events 21 0.0
quality_gates 1 0.0
quality_gate_conditions 5 0.0
properties 4 0.0
project_links 11 0.0
duplications_index 0 0.0
project_measures 3839 0.3
internal_properties 3 0.0
projects 55 0.1
manual_measures 0 0.0
active_rules 2957 0.1
notifications 0 0.0
user_roles 0 0.0
active_rule_parameters 167 0.0
users 4 0.0
metrics 145 0.0
loaded_templates 2 0.0
issues 473 0.1
issue_changes 0 0.0
permission_templates 1 0.0
perm_tpl_characteristics 0 0.0
perm_templates_users 0 0.0
perm_templates_groups 4 0.0
qprofile_changes 6543 0.3
file_sources 22 0.0
ce_queue 0 0.0
ce_activity 22 0.0
ce_task_characteristics 0 0.0
ce_task_input 0 0.0
ce_scanner_context 22 0.0
user_tokens 0 0.0
webhook_deliveries 0 0.0
es_queue 0 0.0
plugins 14 0.0
project_branches 11 0.0
analysis_properties 0 0.0
Migration successful in 2.7 seconds
#检查pg中的数据
\c sonarqube
\dt
select * from projects;
重启服务
#清除es索引
rm -fr data/es5
#重启服务
./sonar.sh restart
验证数据
项目信息

用户信息

总结
- 到此数据迁移完成,开始准备后面的工作。将sonarqube版本升级到7.9.1 LTS
升级7.9.1
安装JDK11
#因为现在在通过jdk8运行sonar6.7.7,所以暂时可以不配置全局变量,升级完成后将jdk11配置成全局即可。
tar zxf jdk-11_linux-x64_bin.tar.gz -C /usr/local/
配置SonarQube7.9.1
https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.9.1.zip
unzip sonarqube-7.9.1.zip
cp pg/sonarqube-6.7.7/conf/sonar.properties sonarqube-7.9.1/conf/sonar.properties
# sonarqube 7.9.1 必须使用jdk11
vim ../../conf/wrapper.conf
wrapper.java.command=/usr/local/jdk-11/bin/java
切换服务
#停止旧版本
cd pg/sonarqube-6.7.7/bin/linux-x86-64/
./sonar.sh stop
#启动新版本
cd sonarqube-7.9.1/bin/linux-x86-64/
./sonar.sh start
启动后会看到如下错误,需要初始化服务。

初始化服务 http://xxxxxxx:9000/setup



哈哈哈哈哈 升级完成了,数据未丢失


总结
- 升级完成,剩下的就需要安装相关的插件了。
FAQ
1.Could not determine SonarQube version of the target database. Could not select version from schema_migrations. ERROR: relation "schema_migrations" does not exist
新创建的空的PG是不能进行迁移的,需要同版本的soanr使用后才会找到和这个表!
2.Versions in source and target database don't match: 1838 != 2804
此问题一定要注意在做数据库迁移的时候,先运行一个同版本的新sonar进行迁移哦!
3.迁移完成没有数据怎么办? 是不是我操作错误了?
需要先删除es索引再启动sonarqube,详见切换服务部分。
4.出现SonarQube is under maintenance
升级后需要初始化详见切换服务部分。
如何将当前平台升级到SonarQube7.9?[最新]的更多相关文章
- vSphere虚拟化平台升级注意事项
关注嘉为科技,获取运维新知 一. Vmware生命周期查询 目前,绝对部分企业均使用VMware vSphere 来构建云计算基础架构,从而减少运行的服务器数量,降低资金成本和运营成本,提高业务灵活性 ...
- K2 BPM_万翼科技携手上海斯歌,全面启动K2平台升级项目_十年专注业务流程管理系统
2019年7月25日,万翼科技和上海斯歌在深圳召开了“2019年K2平台升级项目启动会”.万翼科技核心合伙人何建春.管金华,协同管理支撑组负责人贾磊,K2平台产品负责人黄平显,上海斯歌总裁李明,技术研 ...
- TPT Fusion平台升级,AUTOSAR及ViL测试功能重装上线
TPT简介 TPT是针对嵌入式系统基于模型的测试工具,特别是针对控制系统的软件功能测试.TPT支持众多业内主流的工具平台和测试环境,可以完成V模式要求所有阶段(MiL-SiL-PiL-HiL-ViL) ...
- 《微赢微信公众平台系统5月14最新破解高级运营版+水果机+邀请函+微汽车+微食品+用户CRM》
<微赢微信公众平台系统5月14最新破解高级运营版+水果机+邀请函+微汽车+微食品+用户CRM> 此版本号眼下是淘宝卖600RMB的,其他VIP源代码论坛也都还没有公布.咱们这里全然免费分享 ...
- CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)
---恢复内容开始--- CentOS 6.6 升级GCC G++ (当前最新GCC/G++版本为v6.1.0) 没有便捷方式, yum update.... yum install 或者 添加y ...
- 【转】CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)
原文地址:https://www.cnblogs.com/lzpong/p/5755678.html 我这里是centos7 升级到gcc8.1,过程差不多,参考这篇文章,记录一下. ---原文--- ...
- 秋日上新!H5活动之家营销平台升级大盘点!
H5活动之家活动营销平台,免费定制使用抽奖.投票.砍价.红包.互动.游戏等不同类型的微信营销活动. 近期多个活动进行了升级改造,更有集福卡持续热度,微助力火热上线等亮点:同时平台也进行了提高访问速度. ...
- windows平台升级ORACLE11.2.0.1到11.2.0.4
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://4445027.blog.51cto.com/4435027/1674217 一 ...
- AEAI DP开发平台升级说明
本次发版的AEAI DP_v3.5.0版本为AEAI DP _v3.4.0版本的升级版本,该产品现已开源并上传至开源社区http://www.oschina.net/p/aeaidp. 1 升级说明 ...
随机推荐
- 结构体和typedef
在C语言中,可以使用结构体(Struct)来存放一组不同类型的数据.结构体的定义形式为: struct 结构体名{ 结构体所包含的变量或数组}; 结构体是一种集合,它里面包含了多个变量或数组,它 ...
- 杂项-Map:高德地图
ylbtech-杂项-Map:高德地图 1.返回顶部 1. 开放分类:地图手机软件高德地图(Amap) 是国内一流的免费地图导航产品,也是基于位置的生活服务功能最全面.信息最丰富的手机地图,由国内最大 ...
- Linux随笔 - 修改主机名
1.临时修改主机名: hostname 主机名 修改只能临时有效,机器重启后会自动还原. 2.永久修改主机名: 修改hostname文件(路径:/etc/sysconfig/network),把hos ...
- <读书笔记>JavaScript系列之7种创建对象(面向对象)
写在前面: 以下三选一: 阅读博文JavaScript 对象详解. 阅读<JavaScript权威指南>第6章. 阅读<JavaScript高级程序设计>第6章. 注意:只需要 ...
- 洛谷P3366 【模板】最小生成树(LCT)
[模板]最小生成树 题目传送门 解题思路 用LCT来维护最小生成树. 除了把各顶点作为节点外,每条边也都视为一个节点.对于要加入的边\(e\),检查其两顶点\(x\)和\(y\)是否在同一棵树中,如果 ...
- 记录规则(recording rules)与告警规则(alerting rule)
记录规则(recording rules) 配置规则 Prometheus支持两种类型的规则,可以对其进行配置,然后定期进行评估:记录规则和警报规则.要在Prometheus中包含规则,请创建一个包含 ...
- Java程序员必精通之—synchronized
更多Java并发文章:https://www.cnblogs.com/hello-shf/category/1619780.html 一.简介 相信每一个java程序员对synchronized都不会 ...
- python文件的读写总结
读写文件是最常见的IO操作.Python内置了读写文件的函数,用法和C是兼容的. 读写文件前,我们先必须了解一下,在磁盘上读写文件的功能都是由操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘, ...
- C#冒泡排序法学习
一,冒泡排序法理解:就是将一个集合里的数据当前位置和后一位比较,然当前位置大于后一位,则两个位置替换,直到排序完成 using System; using System.Collections.Gen ...
- RabbitMQ 在 Win10 环境下的安装与配置
1 RabbitMQ 环境配置 1.1 ErLang 下载安装 RabbitMQ 需要 ErLang 环境支持:首先下载 ErLang 并安装. 建议使用新版本,版本过低存在与 Rab ...