Database versioning

With all of this talk about the database version and schema changes, let's take a closer look at how version information is stored and how we can check the upgrade status. Examine the dbversion table in your Zabbix database:

 mysql> select * from dbversion;
 +-----------+----------+
 | mandatory | optional |
 +-----------+----------+
 |   4000000 |  4000003 |
 +-----------+----------+
 1 row in set (0.00 sec) 

This table is the way Zabbix components determine which version of the database schema they're dealing with. There're two numbers in there: the mandatory and optional versions. The following rules are important regarding version numbers:

  • Inside one major version, the mandatory version number is always the same
  • If a more recent server is started, it upgrades the database to the latest mandatory and optional version
  • The server and frontend can work with a database as long as its mandatory version matches their mandatory version exactly; the optional version doesn't affect compatibility

The mandatory version encodes things such as table changes, column changes, and otherwise significant changes that break compatibility. The optional version would usually denote an index change—something that's helpful but doesn't prohibit older versions from working with a more recent database.

The Zabbix server can upgrade to the latest database schema version on all versions from 2.0 onward. To upgrade the database from version 2.0 to 4.0, it isn't required to use server versions in succession; it's enough to start server version 4.0.

When a new major version of Zabbix Server is started, it's possible to observe the current status and database upgrade progress in the server log file:

 10852:20151209:094918.686 Starting Zabbix Server. Zabbix 4.0.0 (revision {ZABBIX_REVISION}). 
 10852:20151209:094918.729 ****** Enabled features ****** 
... 
 10852:20151209:094918.730 TLS support:                NO 
 10852:20151209:094918.730 ****************************** 
 10852:20151209:094918.730 using configuration file: /usr/local/etc/zabbix_server.conf 
 10852:20151209:094918.820 current database version (mandatory/optional): 4000000/ 4000000 
 10852:20151209:094918.820 required mandatory version:  4000000 
 10852:20151209:094918.820 starting automatic database upgrade 
... 
 10852:20151209:094918.866 completed 20% of database upgrade 
... 
 10852:20151209:094918.937 completed 100% of database upgrade 
 10852:20151209:094918.937 database upgrade fully completed 

Notice how it prints out the current mandatory and optional database versions we just examined in the database, and the required mandatory version. If the mandatory or optional database version numbers are lower than the required version, the server will upgrade the database. If the database mandatory version is higher than the server version, the server will refuse to start up. During the database schema upgrade, no monitoring happens. Monitoring restarts once the database upgrade is complete.

What happens if you upgrade the fronted before upgrading and starting the server to take care of the database upgrade? You're likely to see a message that warns you that the frontend doesn't matches the current Zabbix database version.

If you see such a message when upgrading, start the new server and ensure the database upgrade is successful. If that doesn't help, make sure you're not starting some older Zabbix server binary or pointing the Zabbix server at a different database. If you see a message like that when not upgrading Zabbix, you likely have a quite significant misconfiguration.

Such a situation should never happen during the normal operation of Zabbix or minor version upgrades. Note that the Zabbix frontend stores the major version it's compatible with in the defines.inc.php file in the ZABBIX_DB_VERSION constant.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.109.151