当前位置:网站首页>Zabbix删除一些大表历史数据脚本
Zabbix删除一些大表历史数据脚本
2022-08-02 03:36:00 【hzsnone】
一.问题描述
由于使用的zabbix服务器配置不高,磁盘空间及CPU,内存资源有限,为提高可用性,对于历史数据进行定期清理
二.shell编写
#!/bin/bash
User="zabbix_user"
Passwd="password"
Date=`date -d $(date -d "-30 day" +%Y%m%d) +%s`
/usr/local/mysql/bin/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 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;
"其中 optimize table 用来释放删除数据后释放磁盘占用空间。
三.定时任务配置,一个星期执行一次。
边栏推荐
猜你喜欢
随机推荐
《2022年中国网络安全市场全景图》
两端是圆角的进度条微信对接笔记
树莓派4B设置双网卡静态IP、网卡优先级、查看系统多少位
DMA相应外设映射
防抖和节流(实例讲解)
跨域问题解决办法
微服务入门
树莓派4B安装OPENCV遇到ffmpeg库版本太高的问题【后续更新】
JS事件循环机制
[Database] Four characteristics of transaction
剑指Offer 32.Ⅰ从上到下打印二叉树
【LeetCode】Sum
KMP 字符串匹配
Scalar value for argument ‘color‘ is not numeric错误处理
flasgger手写phpwind接口文档
【LeetCode】Add the linked list with carry
Plus版SBOM:流水线物料清单PBOM
Location、navigator和History对象
QT之实现斗鱼直播PC客户端
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tupl









