欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          Zabbix監(jiān)控歷史數(shù)據(jù)清理

          Zabbix監(jiān)控運(yùn)行一段時(shí)間以后,會(huì)留下大量的歷史監(jiān)控?cái)?shù)據(jù),Zabbix數(shù)據(jù)庫一直在增大;可能會(huì)造成系統(tǒng)性能下降,查看歷史數(shù)據(jù)室查詢速度緩慢。

          Zabbix里面最大的表就是history和history_uint兩個(gè)表,而且zabbix里面的時(shí)間是使用的時(shí)間戳方式記錄,所以可以根據(jù)時(shí)間戳來刪除歷史數(shù)據(jù)

           一、關(guān)閉zabbix、http服務(wù)

              pkill -9 zabbix
              service httpd stop
          二、清理zabbix歷史數(shù)據(jù)

          1、查看數(shù)據(jù)庫目錄文件

              [root@zabbix-server zabbix]# cd /var/lib/mysql/zabbix/
              [root@zabbix-server zabbix]# ls -lh | grep G
              total 177G
              -rw-r—– 1 mysql mysql 1.7G Dec 24 13:49 events.ibd
              -rw-r—– 1 mysql mysql  60G Dec 24 13:49 history.ibd
              -rw-r—– 1 mysql mysql 2.4G Dec 24 13:49 history_str.ibd
              -rw-r—– 1 mysql mysql  99G Dec 24 13:49 history_uint.ibd
              -rw-r—– 1 mysql mysql 4.6G Dec 24 13:02 trends.ibd
              -rw-r—– 1 mysql mysql 9.5G Dec 24 13:49 trends_uint.ibd
              [root@zabbix-server zabbix]#
              生成Unix時(shí)間戳。時(shí)間定為2018年2月1日(暫定是保存18年2月以后的監(jiān)控?cái)?shù)據(jù))
              [root@zabbix-server zabbix]# date +%s -d “Feb 1, 2018 00:00:00”    #執(zhí)行此命令以后會(huì)生成一個(gè)ID
              1517414400            #這是生成的ID

          2、數(shù)據(jù)備份

              [root@zabbix-server zabbix]#mysql -uroot -p zabbix > /root/mysqlback/zabbix.sql    #需要?jiǎng)?chuàng)建mysqlback目錄

          3、 登錄數(shù)據(jù)庫

              [root@zabbix-server zabbix]# mysql -uroot -p
              Enter password:
              Welcome to the MariaDB monitor.  Commands end with ; or g.
              Your MariaDB connection id is 7
              Server version: 5.5.60-MariaDB MariaDB Server

              Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

              Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

              MariaDB [(none)]>

              執(zhí)行sql查看指定日期之前的數(shù)據(jù)大?。?br />        SELECT table_schema as `Database`,table_name AS `Table`,round(((data_length + index_length) / 1024 / 1024 / 1024), 2) `Size in MB`FROM information_schema.TABLES where CREATE_TIME < ‘2018-02-01 00:00:00′ and table_name=’history.ibd’;

                  根據(jù)需要修改日期和查詢的表名稱(如果查詢出來的結(jié)果是0.0,需要將sql中的三個(gè)1024刪除一個(gè),以G為單位顯示)
             
          4、 執(zhí)行以下命令,清理指定時(shí)間之前的數(shù)據(jù)、對(duì)zabbix數(shù)據(jù)庫執(zhí)行sql命令

              use zabbix;
              delete from history where clock < 1517414400;
              optimize table history;

              delete from history_uint where clock < 1517414400;
              optimize table history_uint;

              delete from trends where clock < 1517414400;
              optimize table trends;

              delete from trends_uint where clock < 1517414400;
              optimize table trends_uint;

              注意:sql中的ID是生成Unix時(shí)間戳的ID號(hào),需要改為自己生成的ID號(hào)
           三、啟動(dòng)服務(wù)

              /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf    #zabbix server
              /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf    #zabbix agent
              service httpd start

              ===============分===========隔==========符============

          1、使用truncate命令清空zabbix 所有監(jiān)控?cái)?shù)據(jù)

              ——————————————————-
              truncate table history;
              optimize table history;
              ——————————————————-
              truncate table history_str;
              optimize table history_str;
              ——————————————————-
              truncate table history_uint;
              optimize table history_uint;
              ——————————————————-
              truncate table trends;
              optimize table trends;
              ——————————————————-
              truncate table trends_uint;
              optimize table trends_uint;
              ——————————————————-
              truncate table events;
              optimize table events;
              ——————————————————-
          注意:這些命令會(huì)把zabbix所有的監(jiān)控?cái)?shù)據(jù)清空,操作前注意備份數(shù)據(jù)庫

          truncate是刪除了表,然后根據(jù)表結(jié)構(gòu)重新建立,delete刪除的是記錄的數(shù)據(jù)沒有修改表

          truncate執(zhí)行刪除比較快,但是在事務(wù)處理安全性方面不如delete,如果我們執(zhí)行truncat的表正在處理事務(wù),這個(gè)命令退出并會(huì)產(chǎn)生錯(cuò)誤信息

          一些Zabbix相關(guān)教程集合

          Ubuntu 14.04下Zabbix2.4.5 源碼編譯安裝  http://www.haoyitu.cn/Linux/2015-05/117657.htm
          CentOS 7 LNMP環(huán)境搭建Zabbix3.0  http://www.haoyitu.cn/Linux/2017-02/140134.htm
          Ubuntu 16.04安裝部署監(jiān)控系統(tǒng)Zabbix2.4  http://www.haoyitu.cn/Linux/2017-03/141436.htm
          Zabbix監(jiān)控安裝部署及警報(bào)配置  http://www.haoyitu.cn/Linux/2017-03/141611.htm
          Zabbix觸發(fā)器表達(dá)式詳解 http://www.haoyitu.cn/Linux/2017-03/141921.htm
          Ubuntu 16.04下安裝部署Zabbix3.0  http://www.haoyitu.cn/Linux/2017-02/140395.htm
          CentOS 6.3下Zabbix監(jiān)控apache server-status http://www.haoyitu.cn/Linux/2013-05/84740.htm
          CentOS 7 下 Zabbix 3.0安裝詳解 http://www.haoyitu.cn/Linux/2017-03/141716.htm
          64位CentOS 6.2下安裝Zabbix 2.0.6  http://www.haoyitu.cn/Linux/2014-11/109541.htm

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)