Tuesday, December 11, 2012

Zabbix Server - query failed duplicate entry solution

After backing up and restoring one of my Zabbix servers, I was getting the following error that was preventing all of my auto-registration from working:

18317:20121211:224348.314 [Z3005] query failed: [1062] Duplicate entry '296101' for key 'PRIMARY' [insert into events (eventid,source,object,objectid,clock,ns,value,value_changed) values (296101,2,3,606,1355265828,0,1,0)]

The Zabbix server worked perfectly fine otherwise, but auto-registration was completely broken. It turns out that the eventid table needs to be cleared if it's full of old hosts, which is very possible if you did a dump and restore. It's pretty simple to clear.

Warning, this should only be done on new servers which you are restoring. You would not want to run this command on an established Zabbix server:

mysql -e zabbix 'delete from events'

Let it purge the events table. This allowed auto-registration to work again properly. Hope that helps somebody else out there.

1 comment: