将Ubuntu 18.04升级到Zabbix 5.4时,出现数据库错误导致升级失败
好久不见,升级Zabbix的时候遇到了错误,让我很焦急。轻松地提升版本,却陷入了解决困境,浪费了大约2个小时,希望我能帮到别人。
环境
-
- Ubuntu 18.04.5 LTS
- Zabbix 5.2 -> 5.4
现象 –
按照公式升级步骤进行操作,但显示数据库错误,无法成功升级。

确认
[Z3005]查询失败:[1832]无法更改列’scriptid’,查询未通过,升级失败。
1756:20210520:101837.080 database upgrade failed
1759:20210520:101847.314 Starting Zabbix Server. Zabbix 5.4.0 (revision 5059e20a75).
...
1759:20210520:101847.315 using configuration file: /etc/zabbix/zabbix_server.conf
1759:20210520:101847.325 Unsupported DB! MariaDB version is 50505 which is smaller than minimum of 100037
1759:20210520:101847.326 current database version (mandatory/optional): 05030069/05030069
1759:20210520:101847.326 required mandatory version: 05040000
1759:20210520:101847.326 starting automatic database upgrade
1759:20210520:101847.327 [Z3005] query failed: [1832] Cannot change column 'scriptid': used in a foreign key constraint 'c_opcommand_2' [alter table opcommand modify `scriptid` bigint unsigned not null]
1759:20210520:101847.327 database upgrade failed
解决方案 ‘àn)
我在Query失败后猜测可能存在不正数据,困惑了大约一小时并考虑回退,但后来得知是由于数据库版本的问题。
1759年:20210520:101847.325 不支持的数据库!MariaDB版本为50505,小于最低要求的100037。
确实…。即使普通升级,MariaDB的版本也不会自动更新到更高的版本,因此在停止服务后明确指定安装10.5版本并执行操作。
# sudo service zabbix-server stop
# sudo apt-get install mariadb-server-10.5
# sudo service zabbix-server start
如果仍然无法移动 (行大小太大)
此外,由于出现了过大的行大小错误,因此需要进行设置更改。
(※如果已经在前一个版本中进行了设置且不需要覆盖,则可能没有问题)
....
3446:20210520:102323.335 [Z3005] query failed: [1118] Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs [alter table `config` add `url` varchar(255) default '' not null]
在my.cnf或mariadb.cnf文件中添加innodb_strict_mode=0。
[mysqld]
innodb_strict_mode=0
请看以下内容: