Ad Widget

Collapse

Need to add primary key to my history tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sullivanindy
    Junior Member
    • Feb 2024
    • 1

    #1

    Need to add primary key to my history tables

    I have very stable and performant Zabbix solution that has been upgraded over the last 5 years and working well until recently. This past weekend, MariaDB just crashed. I tried several things and finally restored the whole VM to a point prior to the crash and it crashed again within an hour with what looked like Innodb database corruption.
    • To resolve I restored again and shut all Zabbix down and upgraded to Zabbix to 6.0.26 and MariaDB to 10.5.24 all on Ubuntu 20.04.
    • I noticed tables were huge so tweaked down history, trends and auditing and ran housekeeper as well as did some database tunning.
    • I then installed Percona tools so I could optimize tables while online, since the history_uint tables was 130GB and would take forever.
    • pt-online-schema-change worked on some other tables like audit etc but would not run on history or history_uint due to missing primary keys.
    • At any rate, I got everything running again and everything seems ok now, but I would really like to reclaim space on those huge history tables and in checkin Zabbix documentation it seems that maybe I missed something in my upgrade to 6 to migrate to Primary keys.
    My question is: What the simplest way is to add primary Keys to my tables that don't have them, with the least amount of downtime?


    Thanks!
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Manual says so .. https://www.zabbix.com/documentation...ary_keys#mysql
    It is said, can be done even with a running server..

    Comment

    Working...