清理zabbix历史数据
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了清理zabbix历史数据相关的知识,希望对你有一定的参考价值。
清理脚本
#!/bin/bash Date=`date -d $(date -d "-30 day" +%Y%m%d) +%s` /usr/local/mysql/bin/mysql --login-path=zabbix -e" use zabbix; DELETE FROM history WHERE ‘clock‘ < $Date; optimize table history; DELETE FROM history_str WHERE ‘clock‘ < $Date; optimize table history_str; DELETE FROM history_uint WHERE ‘clock‘ < $Date; optimize table history_uint; DELETE FROM trends WHERE ‘clock‘ < $Date; optimize table trends; DELETE FROM trends_uint WHERE ‘clock‘ < $Date; optimize table trends_uint; DELETE FROM events WHERE ‘clock‘ < $Date; optimize table events; " #此脚本删除30天之前的数据,时间可可根据需求自行修改
注意:如果MySQL数据库是5.6.6需要先设置免密码登陆
参考博文
https://my.oschina.net/ifraincoat/blog/485834
https://shazi.info/mysql-%E5%9F%B7%E8%A1%8C-bash-script-%E5%87%BA%E7%8F%BE-warning-using-a-password-on-the-command-line-interface-can-be-insecure/
以上是关于清理zabbix历史数据的主要内容,如果未能解决你的问题,请参考以下文章