标签:行锁 ima 一段 dao cpu stat 负载 使用 dia
#通过如下命令进行获取90天以前的时间戳
[root@zabbix-server ~]# date -d $(date -d "-90 day" +%Y%m%d) +%s 1590105600
[root@zabbix-server ~]# mysql -uzabbix -p Enter password: mysql> use zabbix; Database changed #delete history_uint mysql> delete from history_uint where clock < 1590105600 LIMIT 10000; Query OK, 1653 rows affected (1 min 45.42 sec) #delete history mysql> delete from history where clock < 1590105600 LIMIT 10000; Query OK, 0 rows affected (24.72 sec)
mysql> optimize table history_uint; +---------------------+----------+----------+-------------------------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +---------------------+----------+----------+-------------------------------------------------------------------+ | zabbix.history_uint | optimize | note | Table does not support optimize, doing recreate + analyze instead | | zabbix.history_uint | optimize | status | OK | +---------------------+----------+----------+-------------------------------------------------------------------+ 2 rows in set (5 min 33.76 sec)
mysql> optimize table history; +----------------+----------+----------+-------------------------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +----------------+----------+----------+-------------------------------------------------------------------+ | zabbix.history | optimize | note | Table does not support optimize, doing recreate + analyze instead | | zabbix.history | optimize | status | OK | +----------------+----------+----------+-------------------------------------------------------------------+ 2 rows in set (1 min 39.51 sec)
#!/bin/bash
User="zabbix"
Passwd="zabbix"
Date=`date -d $(date -d "-90 day" +%Y%m%d) +%s`
echo $Date
$(which mysql) -u${User} -p${Passwd} -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;
"
标签:行锁 ima 一段 dao cpu stat 负载 使用 dia
原文地址:https://www.cnblogs.com/xuewenlong/p/13540165.html