将SonarQube从v5.6.5升级到V6.7时,运行\setup
会产生以下错误:
2017.12.01 10:33:12 WARN web[][o.s.s.p.DatabaseServerCompatibility] Database must be upgraded. Please backup database and browse /setup
....
2017.12.01 10:33:12 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin Findbugs / 3.6.0 /
....
2017.12.01 10:33:12 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarTS / 1.1.0.1079 / 042c9e65239a47d92d305f9767f730b3cc1e5ed3
2017.12.01 10:33:12 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarXML / 1.4.3.1027 / 39588245cecf538bb27be4e496ff303b0143d20b
2017.12.01 10:33:12 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin Sonargraph / 3.5
2017.12.01 10:33:12 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin Sonargraph Integration / 2.0.1
2017.12.01 10:33:12 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin Web / 2.5.0.476 / 636872f5d37fa7a440fe07d08d504e1a881225e5
2017.12.01 10:33:12 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin jDepend / 1.1.1
2017.12.01 10:33:13 INFO web[][o.s.s.p.Platform] Database needs migration
2017.12.01 10:33:13 INFO web[][o.s.s.p.w.MasterServletFilter] Initializing servlet filter org.sonar.server.ws.WebServiceFilter@5851f091 [pattern=UrlPattern{inclusions=[/api/system/migrate_db/*, ...], exclusions=[/api/properties*, ...]}]
2017.12.01 10:33:13 INFO web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2017.12.01 10:33:29 INFO web[][o.s.s.p.d.m.DatabaseMigrationImpl] Starting DB Migration and container restart
2017.12.01 10:33:29 INFO web[][DbMigrations] Executing DB migrations...
2017.12.01 10:33:29 INFO web[][DbMigrations] #1200 'Create table PERM_TPL_CHARACTERISTICS'...
2017.12.01 10:33:29 ERROR web[][DbMigrations] #1200 'Create table PERM_TPL_CHARACTERISTICS': failure | time=12ms
2017.12.01 10:33:29 ERROR web[][DbMigrations] Executed DB migrations: failure | time=13ms
2017.12.01 10:33:29 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=57ms
2017.12.01 10:33:29 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration ended with an exception
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #1200 'Create table PERM_TPL_CHARACTERISTICS' failed
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:79)
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:67)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.ReferencePipeline$Head.forEachOrdered(ReferencePipeline.java:590)
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:52)
at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(MigrationEngineImpl.java:50)
at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(DatabaseMigrationImpl.java:105)
at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(DatabaseMigrationImpl.java:80)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Fail to execute CREATE TABLE perm_tpl_characteristics (id INTEGER NOT NULL AUTO_INCREMENT,template_id INTEGER NOT NULL,permission_key VARCHAR (64) NOT NULL,with_project_creator TINYINT(1) DEFAULT false NOT NULL,created_at BIGINT NOT NULL,updated_at BIGINT NOT NULL, CONSTRAINT pk_perm_tpl_characteristics PRIMARY KEY (id)) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin
at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:97)
at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:77)
at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:117)
at org.sonar.server.platform.db.migration.version.v60.CreatePermTemplatesCharacteristics.execute(CreatePermTemplatesCharacteristics.java:48)
at org.sonar.server.platform.db.migration.step.DdlChange.execute(DdlChange.java:45)
at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
... 11 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'perm_tpl_characteristics' already exists
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2444)
at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:745)
at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:82)
... 16 common frames omitted
从一个LTS版本升级到下一个版本太多了吗?我应该先升级到中级版吗?如果是这样,最短的升级路径是什么?
各种MySql版本是:
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| innodb_version | 5.7.20 |
| protocol_version | 10 |
| slave_type_conversions | |
| tls_version | TLSv1,TLSv1.1 |
| version | 5.7.20-log |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | x86_64 |
| version_compile_os | Win64 |
+-------------------------+------------------------------+
v5.6.5和v6.7实例之间的插件不是100%相同。版本6.x中不再支持某些插件。根据错误消息,我不认为这是问题,但这是两种配置之间的差异。
答案 0 :(得分:4)
问题是这个数据库最初是作为新的V6.2安装的一部分创建的。插件出现问题,因此安装回滚到v5.6.5。我不知道在'降级'期间是否必须调用/upgrade
。无论哪种方式,升级过程都没有预料到这种边缘情况,所以我手动修复它。
我运行了MySql查询show table status;
并显示perm_tpl_characteristics
为空,因此我删除了它。我重新运行升级,另一个失败,另一个表出现类似的错误。我删除了表并重新运行升级,直到成功。这就是我最终的结果:
USE DATABASE sonar;
DROP TABLE perm_tpl_characteristics;
DROP TABLE ce_task_input;
DROP TABLE ce_scanner_context;
DROP TABLE internal_properties;
DROP TABLE qprofile_changes;
DROP TABLE rule_repositories;
DROP TABLE organizations;
DROP TABLE webhook_deliveries;
我在prod实例上执行了这些DDL语句,升级成功。谢谢大家的建议。他们指出了我正确的方向。
答案 1 :(得分:1)
在升级到6.X LTS之前,您必须升级到最新的5.X LTS版本。
最新的5.X LTS版本是5.6.7(见release notes),所以首先你需要将5.6.5升级到5.6.7并且在6.7旁边升级。