系统运维
zabbix 数据清理
在服务器上操作数据库是挺危险的事情,这里一定要慎重操作,清理数据有两种方法:1. 更改zabbix 上历史数据、趋势保存时间2. 通过对zabbxi mysql 数据库进行操作清理 这里笔者比较怂,妥妥使用的第二种,保留30d数据,还有就是在操作的时候一定要注意:关闭报警---->报警媒介,今天备份数据的时候造成误报,短信大量发送,一定要记住惨痛经历,不然就要走人啦!使用表清理数据基本操作语句如下:zabbix 数据库查询大小mariadb [(none)]> select table_schema, concat(truncate(sum(data_length)/1024/1024,2),\\\' mb\\\') as data_size,concat(truncate(sum(index_length)/1024/1024,2),\\\'mb\\\') as index_size from information_schema.tables group by table_schema order by data_size desc; -------------------- ------------- ------------ | table_schema | data_size | index_size | -------------------- ------------- ------------ | zabbix | 63447.98 mb | 74299.04mb || information_schema | 0.08 mb | 0.08mb | -------------------- ------------- —————— 数据大小: 61g索引大小: 37g查询zabbix数据库里所有表大小mariadb [(none)]> select table_name, (data_length index_length)/1024/1024 as total_mb,table_rows from information_schema.tables where table_schema=\\\'zabbix\\\' order by total_mb desc;执行sql查看指定日期之前的数据大小select table_schema as `database`,table_name as `table`,round(((data_length index_length)), 2) `size in mb`from information_schema.tables where create_time < \\\'2019-09-01 00:00:00\\\' and table_name=\\\'history.ibd\\\';查看当前目录大与50m 的文件# find ./ -size 50m | xargs ls -slh删除2019年11月22日11点以前的数据[root@128lastsummer ~]# date %s -d nov 22, 2019 11:00:001574391600mariadb [zabbix]> delete from history where clock < 1574391600;mariadb [zabbix]> delete from history_uint where clock < 1574391600;mariadb [zabbix]> optimize table history;mariadb [zabbix]> optimize table history_unit;备份与恢复zabbix history 的表[root@128lastsummer ~]# mysqldump -uzabbix -p zabbix history > /tmp/zabbix_history.sqlmariadb [zabbix]> source /tmp/zabbix_history.sql;查询数据库每个表有多少条数据select table_name,table_rows from information_schema.tables where table_schema = \\\'数据库的名称\\\' order by table_rows desc;
这个核验照不可以么最近已经没有那么冷啦javascript怎样实现网页在线时钟功能云服务器怎么设置代理php url地址栏传中文乱码怎么办?阿里云服务器不续费的后果稳定的免备案美国云服务器云计算跟服务器有什么区别百度云无法找到sftp服务器