[ZBX-23903] Database replication error Created: 2024 Jan 02  Updated: 2024 Feb 14  Resolved: 2024 Feb 14

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Igor Luiz Oliveira Assignee: Aigars Kadikis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File count_itens_and_hosts.png     PNG File image-2024-01-04-14-53-35-175.png     PNG File selinux.png     PNG File zabbix_server_conf_DB-1.png     PNG File zabbix_server_conf_DB.png    

 Description   

Specifications:
Zabbix server version: 6.0.23
Zabbix Database version: 6.0.23
Database vendor (version): Mysql (8.0.33)

Description:
We are in the process of replicating the Zabbix database to reduce available storage. We utilize Amazon RDS with MySQL for the Zabbix application. To transfer the data, we performed a full dump of the 'DDL' of the database, and then populated the target database using AWS DMS.

Although the migration was successful, with all data and objects correctly replicated to the target database, we are facing issues related to the database version and communication with the database instance.

The application fails to start due to these issues. Even when the database is updated to a version compatible with the application version, the application still attempts internal updates, resulting in the mentioned errors.

Steps to reproduce:

1. Alter parameter group set log_bin_trust_function_creator=1 and row_format=ROW 
2. Dump DDL from source database
3. Data insertion in target database via AWS DMS
4. Change DNS from source to target 
5. Alter parameter group set log_bin_trust_function_creator=0 and row_format=MIXED
6. Start zabbix-server service 

Result:
zabbix_server.log
Current database version (mandatory/optional): 06000000/06000043
Required mandatory version: 06000000
Unable to read the database instance ID.



 Comments   
Comment by Aigars Kadikis [ 2024 Jan 03 ]

Dear Igor,
Thank you for contacting Zabbix.
From the perspective of the Zabbix application (component "zabbix-server"), I'm unable to locate the error message "Unable to read the database instance ID".

Could it be possible that the line starts with "query failed" and contains the error above? Please share more original lines from zabbix_server.log.

Please simulate if the dedicated application user can read the data.

Observe the connection characteristics to communicate with DB:

grep ^DB /etc/zabbix/zabbix_server.conf

From the same host where service "zabbix-server" is installed, use "mysql" client utility to connect to the database. Use dedicated user from the previous output:

mysql --host=dns.of.ip --user=zabbix --password='zabbix' --database=zabbix

See how many items are inside:

SELECT COUNT(*) FROM items;

A few recognizable host titles which did exist in old instances:

SELECT hosts.host FROM hosts WHERE hosts.flags IN (0,4) AND hosts.status IN (0,1);

Does the SELinux run on the host? This will tell:

getenforce
Comment by Igor Luiz Oliveira [ 2024 Jan 04 ]

Hi Aigars. Thank you for your reply. 

 

Follow the commands and images. 

I've changed this query to COUNT because of privacy policies. 

SELECT hosts.host FROM hosts WHERE hosts.flags IN (0,4) AND hosts.status IN (0,1);

DB configuration on zabbix_server.conf: 

SELECT COUNT(*) FROM items;
SELECT COUNT(*) FROM hosts WHERE hosts.flags IN (0,4) AND hosts.status IN (0,1);

 

Selinux configuration:

Sorry, the message is "cannot read instance id" not "unable". 
See log file lines:
 49052:20240104:174819.899 Starting Zabbix Server. Zabbix 6.0.23 (revision 315e9acac58).
 49052:20240104:174819.899 ****** Enabled features ******
 49052:20240104:174819.899 SNMP monitoring:           YES
 49052:20240104:174819.899 IPMI monitoring:           YES
 49052:20240104:174819.899 Web monitoring:            YES
 49052:20240104:174819.899 VMware monitoring:         YES
 49052:20240104:174819.899 SMTP authentication:       YES
 49052:20240104:174819.899 ODBC:                      YES
 49052:20240104:174819.899 SSH support:               YES
 49052:20240104:174819.899 IPv6 support:              YES
 49052:20240104:174819.899 TLS support:               YES
 49052:20240104:174819.899 ******************************
 49052:20240104:174819.900 using configuration file: /etc/zabbix/zabbix_server.conf
 49052:20240104:174819.932 current database version (mandatory/optional): 00600000/06000043
 49052:20240104:174819.933 required mandatory version: 06000000
 49052:20240104:174819.952 cannot read instance id from database

I've noted that config table isn't populated as well: 

 

Comment by Aigars Kadikis [ 2024 Jan 30 ]

Hi Igor. Sorry for late reply.

There should be only one row in the config table and you have this one row. It seems the column "instanceid" currently has an empty value.

The syntax of instanced is a 32-character long hex string. We can use a bash command to generate one:

< /dev/urandom tr -dc a-f0-9 | head -c${1:-32};echo;

It can print a string like: "cafc344fe615d8cb24a416cdbd3e9201"

After that, you can use DB command to update the field:

UPDATE config SET instanceid='cafc344fe615d8cb24a416cdbd3e9201';

Please check if other data is there. There should be a lot:

SELECT * FROM config;

At the bare minimum via stock installation, we have:

INSERT INTO `config` (`configid`,`work_period`,`alert_usrgrpid`,`discovery_groupid`,`dbversion_status`,`geomaps_tile_provider`) values ('1','1-5,09:00-18:00','7','5','','OpenStreetMap.Mapnik');
Comment by Igor Luiz Oliveira [ 2024 Feb 14 ]

Hello, Aigars! 

Thank you for your help. 

The problem was in AWS tool.
The DMS was getting timeout during data migration, which caused data loss in target database. 

It's ok now. 

Thank you. 

Generated at Sat Aug 02 09:24:06 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.