zabbix 清理旧数据#!/bin/bash User=user Passwd=passwd Date=`date -d $(date -d "-30 d
zabbix 清理旧数据
#!/bin/bash
User=user
Passwd=passwd
Date=`date -d $(date -d "-30 day" +%Y%m%d) +%s` #取30天之前的时间戳
$(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
--结束END--
本文标题: zabbix 清理旧数据
本文链接: https://lsjlt.com/news/41378.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0