久しぶりにZabbixのバージョンアップ時にエラーが出て焦りました。気軽にバージョンを上げて解決に悩んで2時間程消耗したので、誰かの助けになれば幸いです。
環境
- Ubuntu 18.04.5 LTS
- Zabbix 5.2 -> 5.4
現象
公式のアップグレード手順通りに行ったのだが、Database errorが表示され正常にアップグレードできない。
確認
[Z3005] query failed: [1832] Cannot change column 'scriptid'という感じでQueryが通らずアップグレードが失敗している。
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
解決方法
Query失敗で不正データがあるのかと思って1時間程悩み戻しも検討するが、Databaseのバージョンの問題との事
1759:20210520:101847.325 Unsupported DB! MariaDB version is 50505 which is smaller than minimum of 100037
たしかに...。普通にupgradeしても自動ではMariaDBのバージョンはそれ以上上がらないようなので、という事でサービスを停止後に10.5を明示してインストールを実行
# sudo service zabbix-server stop
# sudo apt-get install mariadb-server-10.5
# sudo service zabbix-server start
それでも動かない場合 (Row size too large)
さらに、Row size too largeが出たので設定変更を行います。
(※すでに前バージョンで設定済で上書きしなければ問題無い可能性有り)
....
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
参考:
