设为首页 收藏本站
查看: 1360|回复: 0

[经验分享] 清除zabbix历史缓存

[复制链接]

尚未签到

发表于 2019-1-18 10:58:23 | 显示全部楼层 |阅读模式
  mysql>use zabbix;
  显示zabbix数据库中的表大小;
  mysql>SELECT table_name AS "Tables", round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = 'zabbix' ORDER BY (data_length + index_length) DESC;
  +----------------------------+------------+
  | Tables                     | Size in MB |
  +----------------------------+------------+
  | history_uint               |     887.00 |
  | history                    |     674.05 |
  | trends_uint                |      22.38 |
  | trends                     |      19.39 |
  | events                     |       4.55 |
  | images                     |       1.53 |
  | items                      |       0.72 |
  | history_str                |       0.33 |
  | alerts                     |       0.25 |
  | items_applications         |       0.23 |
  | profiles                   |       0.22 |
  | auditlog                   |       0.17 |
  | triggers                   |       0.14 |
  | graphs                     |       0.13 |
  | hosts                      |       0.11 |
  | graphs_items               |       0.11 |
  | sysmaps_elements           |       0.09 |
  | item_discovery             |       0.09 |
  | sysmaps                    |       0.08 |
  | httptest                   |       0.08 |
  | functions                  |       0.08 |
  | sysmaps_links              |       0.06 |
  | acknowledges               |       0.06 |
  | group_prototype            |       0.06 |
  | scripts                    |       0.06 |
  | actions                    |       0.06 |
  | slideshows                 |       0.05 |
  | config                     |       0.05 |
  | item_application_prototype |       0.05 |
  | slideshow_usrgrp           |       0.05 |
  | sysmaps_link_triggers      |       0.05 |
  | optemplate                 |       0.05 |
  | hosts_templates            |       0.05 |
  | slideshow_user             |       0.05 |
  | media                      |       0.05 |
  | opmessage_usr              |       0.05 |
  | hosts_groups               |       0.05 |
  | users_groups               |       0.05 |
  | interface                  |       0.05 |
  | slides                     |       0.05 |
  | screens                    |       0.05 |
  | dservices                  |       0.05 |
  | opmessage_grp              |       0.05 |
  | maintenances_windows       |       0.05 |
  | screen_usrgrp              |       0.05 |
  | sysmap_usrgrp              |       0.05 |
  | drules                     |       0.05 |
  | maintenances_hosts         |       0.05 |
  | screen_user                |       0.05 |
  | icon_mapping               |       0.05 |
  | opgroup                    |       0.05 |
  | rights                     |       0.05 |
  | services_links             |       0.05 |
  | maintenances_groups        |       0.05 |
  | application_template       |       0.05 |
  | host_discovery             |       0.05 |
  | icon_map                   |       0.05 |
  | trigger_depends            |       0.05 |
  | application_prototype      |       0.05 |
  | httptestitem               |       0.05 |
  | sysmap_user                |       0.05 |
  | service_alarms             |       0.05 |
  | application_discovery      |       0.05 |
  | history_text               |       0.05 |
  | opcommand_hst              |       0.05 |
  | httpstepitem               |       0.05 |
  | opcommand_grp              |       0.05 |
  | httpstep                   |       0.03 |
  | opcommand                  |       0.03 |
  | expressions                |       0.03 |
  | media_type                 |       0.03 |
  | conditions                 |       0.03 |
  | usrgrp                     |       0.03 |
  | groups                     |       0.03 |
  | interface_discovery        |       0.03 |
  | autoreg_host               |       0.03 |
  | escalations                |       0.03 |
  | mappings                   |       0.03 |
  | group_discovery            |       0.03 |
  | auditlog_details           |       0.03 |
  | users                      |       0.03 |
  | sessions                   |       0.03 |
  | opmessage                  |       0.03 |
  | hostmacro                  |       0.03 |
  | services_times             |       0.03 |
  | dhosts                     |       0.03 |
  | applications               |       0.03 |
  | trigger_discovery          |       0.03 |
  | graph_theme                |       0.03 |
  | operations                 |       0.03 |
  | services                   |       0.03 |
  | graph_discovery            |       0.03 |
  | regexps                    |       0.03 |
  | opconditions               |       0.03 |
  | sysmap_url                 |       0.03 |
  | valuemaps                  |       0.03 |
  | dchecks                    |       0.03 |
  | sysmap_element_url         |       0.03 |
  | screens_items              |       0.03 |
  | item_condition             |       0.03 |
  | housekeeper                |       0.02 |
  | ids                        |       0.02 |
  | opinventory                |       0.02 |
  | host_inventory             |       0.02 |
  | maintenances               |       0.02 |
  | globalvars                 |       0.02 |
  | proxy_history              |       0.02 |
  | globalmacro                |       0.02 |
  | proxy_dhistory             |       0.02 |
  | timeperiods                |       0.02 |
  | proxy_autoreg_host         |       0.02 |
  | dbversion                  |       0.02 |
  | history_log                |       0.02 |
  +----------------------------+------------+
  113 rows in set (0.14 sec)
  描述表结构:
  mysql>desc history_uint;
  +--------+---------------------+------+-----+---------+-------+
  | Field  | Type                | Null | Key | Default | Extra |
  +--------+---------------------+------+-----+---------+-------+
  | itemid | bigint(20) unsigned | NO   | MUL | NULL    |       |
  | clock  | int(11)             | NO   |     | 0       |       |
  | value  | bigint(20) unsigned | NO   |     | 0       |       |
  | ns     | int(11)             | NO   |     | 0       |       |
  +--------+---------------------+------+-----+---------+-------+
  4 rows in set (0.00 sec)
  清除历史缓存:
  mysql> truncate table history;
  Query OK, 0 rows affected (0.15 sec)
  mysql> truncate table history_uint;
  Query OK, 0 rows affected (0.13 sec)
  有时候我们会需要清除一个表格中的所有资料。要达到者个目的,一种方式是我们在 SQL DROP 那一页 看到 的 DROP TABLE 指令。不过这样整个表格就消失,而无法再被用了。另一种方式就是运用 TRUNCATE TABLE 的指令。在这个指令之下,表格中的资料会完全消失,可是表格本身会继续存在。 TRUNCATE TABLE 的语法为下:
  TRUNCATE TABLE "表格名";
  所以,我们如果要清除在 SQL Create Table 那一页建立的顾客表格之内的资料,我们就打入:
  TRUNCATE TABLE Customer;




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-664739-1-1.html 上篇帖子: Zabbix 详细的安装方法 下篇帖子: Zabbix 3.4.3之企业微信报警
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表