Zabbix monitoring--Clean up historical data

Source: Internet
Author: User

Zabbix after running for a period of time, will leave a lot of historical data, will find that the Zabbix database has been increasing. After 3 months of operation, the author's database reached 5.7G, which may result in degraded system performance and slow query when viewing historical data.
Zabbix inside the largest table is the history of the table, many people on the web is to write all the data to empty these tables, in fact, we can delete the history of the record in time.

The largest table inside is "history" and "History_uint" two tables;
650) this.width=650; "src=" Http://blog.chinaunix.net/attachment/201402/28/29179844_1393550864IFNG.jpg "height=" 213 "width=" 295 "style=" border:0px; "/>

The time in the Zabbix is recorded using the timestamp method, we can convert it and then delete it according to the timestamp;

For example, to delete data from 2014 years before January 1

1. Convert standard Time to timestamp first

# date +%s-d "2014-01-01 00:00:01"
1388505601

2. mysql Cleanup data

Click ( here ) to collapse or open

    1. MySQL> DELETE from ' history_uint ' WHERE ' clock ' < 1388505601;


    2. MySQL> optimize table history_uint;

Note: It may take a long time to execute a second line of command, without interruption in the middle, otherwise it is easy to lose data.


This is more practical to delete historical data according to the time period, there is also a way to completely erase historical monitoring data
Zabbix empty history MySQL database operation:

Click ( here ) to collapse or open

  1. Mysql-uroot-p Enter the MySQL password

  2. Use Zabbix;

  3. TRUNCATE TABLE history;

  4. Optimize table history;

  5. TRUNCATE TABLE History_str;

  6. Optimize table history_str;

  7. TRUNCATE TABLE History_uint;

  8. Optimize table History_uint;

  9. TRUNCATE TABLE trends;

  10. Optimize table trends;

  11. TRUNCATE TABLE Trends_uint;

  12. Optimize table Trends_uint;

  13. TRUNCATE TABLE events;

  14. Optimize table events;

Note: This operation clears all historical monitoring data for Zabbix, please back up the database before operation!


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1846389

Zabbix monitoring--Clean up historical data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.