首页 > 代码库 > zabbix 清理旧数据
zabbix 清理旧数据
zabbix 清理旧数据
#!/bin/bash User=user Passwd=passwd Date=`date -d $(date -d "-90 day" +%Y%m%d) +%s` #取90天之前的时间戳 $(which mysql) -u${User} -p${Passwd} -S /tmp/mysql.sock -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 history_text WHERE ‘clock‘ < $Date; optimize table history_text; 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; "
mysql ibdata空间清理
mysqldump -u [username] -p[root_password] [database_name] > dumpfilename.sql DROP DATABASE database_name /etc/init.d/mysqld stop rm /var/lib/mysql/ibdata1 rm /var/lib/mysql/ib_logfile* /etc/init.d/mysqld start create database [database_name] mysql -u [username]-p[root_password] [database_name] < dumpfilename.sql
本文出自 “webgame 自动化运维” 博客,请务必保留此出处http://mstools.blog.51cto.com/1104047/1923644
zabbix 清理旧数据
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。