4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Zabbix6.0にアップグレードしたらDatabase errorに遭遇した

Posted at

環境

・Ubuntu 20.04
・MariaDB 10.3
Zabbix 4.2 -> 6.0 にアップグレード

Zabbix6.0にアップグレード

公式手順も用意されてるのでその通りにアップグレードしていきます。

トラブル

zabbixのアップグレードは問題なく完了したが、フロントエンドでDatabase errorが表示

The Zabbix database version does not match current requirements. 
Your database version: 4020000. Required version: 6000000. Please contact your system administrator.

/var/log/zabbix/zabbix_server.log にログが何も出力されず原因不明。

そもそもデータベースのサポートバージョンはMariaDBの場合10.5以上なので、
MariaDBも10.3->10.5にアップグレードを実施。

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 53948
Server version: 10.5.15-MariaDB-1:10.5.15+maria~focal mariadb.org binary distribution

MariaDBのアップグレード後も、フロントエンドでは上記のDatabase errorが表示されたが
/var/log/zabbix/zabbix_server.logにはログが出力されるようになった。

  4859:20220329:010905.627 Starting Zabbix Server. Zabbix 6.0.1 (revision a80cb13868).
 ・・・(略)
  4859:20220329:010905.628 using configuration file: /etc/zabbix/zabbix_server.conf
  4859:20220329:010905.664 Zabbix supports only "utf8,utf8mb3,utf8mb4" character set(s). Database "zabbix" has default character set "latin1"
  4859:20220329:010905.664 Zabbix supports only "utf8_bin,utf8mb3_bin,utf8mb4_bin" collation(s). Database "zabbix" has default collation "latin1_swedish_ci"
  4859:20220329:010905.690 character set name or collation name that is not supported by Zabbix found in 392 column(s) of database "zabbix"
  4859:20220329:010905.694 only character set(s) "utf8,utf8mb3,utf8mb4" and corresponding collation(s) "utf8_bin,utf8mb3_bin,utf8mb4_bin" should be used in database
  4859:20220329:010905.696 current database version (mandatory/optional): 04030004/04030004
  4859:20220329:010905.696 required mandatory version: 06000000
  4859:20220329:010905.696 starting automatic database upgrade
  4859:20220329:010906.335 [Z3005] query failed: [1366] Incorrect string value: '\xE3\x81\x9D\xE3\x81\xAE...' for column `zabbix`.`item_rtdata`.`error` at row 68 [insert into item_rtdata (itemid,lastlogsize,state,mtime,error) select i.itemid,i.lastlogsize,i.state,i.mtime,i.error from items i join hosts h on i.hostid=h.hostid where h.status in (0,1) and i.flags<>2]
  4859:20220329:010906.378 database upgrade failed

解決

ログの通りitem_rtdataカラムを確認するとCollationがlatin1_swedish_ciになっていたので下記コマンドを実行した。

ALTER TABLE zabbix.item_rtdata CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;

これでzabbixが起動してフロントエンドのエラーも消えて無事にアップグレードが完了しました。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?