zabbix數(shù)據(jù)庫分表

Zabbix 官網(wǎng)說明:https://www.zabbix.org/wiki/Docs/howto/mysql_partition
我的環(huán)境:

[11:26:34 root@localhost ~]#mysql -V
mysql  Ver 15.1 Distrib 10.3.27-MariaDB, for Linux (x86_64) using readline 5.1
[11:26:37 root@localhost ~]#zabbix_server -V
zabbix_server (Zabbix) 5.2.5
Revision 1afd0ded11 22 February 2021, compilation time: Feb 23 2021 11:39:25

Copyright (C) 2021 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
[11:26:49 root@localhost ~]#apachectl -v
Server version: Apache/2.4.37 (centos)
Server built:   Nov  4 2020 03:20:37
[11:27:04 root@localhost ~]#php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[11:27:14 root@localhost ~]#cat /etc/redhat-release
CentOS Linux release 8.3.2011

準(zhǔn)備知識(shí):
1臣镣、針對(duì)zabbix數(shù)據(jù)庫表要進(jìn)行分區(qū)分表,如果表數(shù)據(jù)量大執(zhí)行分區(qū)分表會(huì)非常慢铅檩,建議先清空history择膝、trends表中的數(shù)據(jù)(注意:歷史記錄會(huì)全部被清空),再執(zhí)行分區(qū)分表怜浅。
2、zabbix 數(shù)據(jù)庫主要針對(duì)以下表(zabbix歷史記錄表和zabbix存儲(chǔ)趨勢(shì)表)進(jìn)行分區(qū)分表:
history,history_uint耻蛇,history_str,history_test胞此,history_log臣咖,trends,trends_uint

history : 存儲(chǔ)浮點(diǎn)數(shù)數(shù)據(jù) 比如ping丟包漱牵,CPU使用率等 00.00 類似的數(shù)據(jù).
history_uint: 整數(shù)型數(shù)據(jù) 夺蛇,比如流量數(shù)據(jù),狀態(tài)碼等等

趨勢(shì)數(shù)據(jù)存儲(chǔ)表:
trend: 與history類似酣胀,只不過是一個(gè)小時(shí)取一個(gè)點(diǎn)
trend_unit :與history——uint類似刁赦,只不過是一個(gè)小時(shí)取一個(gè)點(diǎn)
3、zabbix 數(shù)據(jù)庫在沒有使用分區(qū)分表功能闻镶,默認(rèn)使用Housekeeping(管家功能)進(jìn)行刪除歷史數(shù)據(jù)和趨勢(shì)歷史記錄甚脉,如果zabbix數(shù)據(jù)庫使用了分區(qū)分表功能需要把Housekeeping(管理功能)關(guān)閉。Housekeeping功能監(jiān)控?cái)?shù)據(jù)量少可以使用铆农,但監(jiān)控?cái)?shù)據(jù)量多每次執(zhí)行刪除會(huì)降低MySQL數(shù)據(jù)庫性能牺氨,并且還會(huì)產(chǎn)生很多空間碎片。(zabbix_server.conf配置文件兩個(gè)參數(shù)進(jìn)行歷史記錄數(shù)據(jù)刪除:間隔多久刪除一次,默認(rèn)單位小時(shí)HousekeepingFrequency=1猴凹,一次刪除多少數(shù)據(jù)夷狰,默認(rèn)單位行MaxHousekeeperDelete=5000)

分表操作:
1、清空zabbix 數(shù)據(jù)庫歷史數(shù)據(jù)
步驟如下:

[11:27:28 root@localhost ~]#vim truncate.sql 

truncate table history;
optimize table history;
truncate table history_str;
optimize table history_str;
truncate table history_log;
optimize table history_log;
truncate table history_text;
optimize table history_text;
truncate table history_uint;
optimize table history_uint;
truncate table trends;
optimize table trends;
truncate table trends_uint;
optimize table trends_uint;

[11:27:28 root@localhost ~]#mysql -uroot -p zabbix
MariaDB [zabbix]>source /root/truncate.sql

2郊霎、zabbix 數(shù)據(jù)庫導(dǎo)入存儲(chǔ)過程
先編輯一個(gè)SQL腳本執(zhí)行導(dǎo)入四個(gè)存儲(chǔ)過程沼头,此腳本復(fù)制zabbix官網(wǎng)提供的SQL腳本

[11:27:28 root@localhost ~]#vim par.sql
DELIMITER $$
CREATE PROCEDURE `partition_create`(SCHEMANAME varchar(64), TABLENAME varchar(64), PARTITIONNAME varchar(64), CLOCK int)
BEGIN
        /*
           SCHEMANAME = The DB schema in which to make changes
           TABLENAME = The table with partitions to potentially delete
           PARTITIONNAME = The name of the partition to create
        */
        /*
           Verify that the partition does not already exist
        */

        DECLARE RETROWS INT;
        SELECT COUNT(1) INTO RETROWS
        FROM information_schema.partitions
        WHERE table_schema = SCHEMANAME AND table_name = TABLENAME AND partition_description >= CLOCK;

        IF RETROWS = 0 THEN
        /*
           1. Print a message indicating that a partition was created.
           2. Create the SQL to create the partition.
           3. Execute the SQL from #2.
        */
        SELECT CONCAT( "partition_create(", SCHEMANAME, ",", TABLENAME, ",", PARTITIONNAME, ",", CLOCK, ")" ) AS msg;
        SET @sql = CONCAT( 'ALTER TABLE ', SCHEMANAME, '.', TABLENAME, ' ADD PARTITION (PARTITION ', PARTITIONNAME, ' VALUES LESS THAN (', CLOCK, '));' );
        PREPARE STMT FROM @sql;
        EXECUTE STMT;
        DEALLOCATE PREPARE STMT;
        END IF;
END$$
DELIMITER ;
DELIMITER $$
CREATE PROCEDURE `partition_drop`(SCHEMANAME VARCHAR(64), TABLENAME VARCHAR(64), DELETE_BELOW_PARTITION_DATE BIGINT)
BEGIN
        /*
           SCHEMANAME = The DB schema in which to make changes
           TABLENAME = The table with partitions to potentially delete
           DELETE_BELOW_PARTITION_DATE = Delete any partitions with names that are dates older than this one (yyyy-mm-dd)
        */
        DECLARE done INT DEFAULT FALSE;
        DECLARE drop_part_name VARCHAR(16);

        /*
           Get a list of all the partitions that are older than the date
           in DELETE_BELOW_PARTITION_DATE.  All partitions are prefixed with
           a "p", so use SUBSTRING TO get rid of that character.
        */
        DECLARE myCursor CURSOR FOR
        SELECT partition_name
        FROM information_schema.partitions
        WHERE table_schema = SCHEMANAME AND table_name = TABLENAME AND CAST(SUBSTRING(partition_name FROM 2) AS UNSIGNED) < DELETE_BELOW_PARTITION_DATE;
        DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

        /*
           Create the basics for when we need to drop the partition.  Also, create
           @drop_partitions to hold a comma-delimited list of all partitions that
           should be deleted.
        */
        SET @alter_header = CONCAT("ALTER TABLE ", SCHEMANAME, ".", TABLENAME, " DROP PARTITION ");
        SET @drop_partitions = "";

        /*
           Start looping through all the partitions that are too old.
        */
        OPEN myCursor;
        read_loop: LOOP
        FETCH myCursor INTO drop_part_name;
        IF done THEN
    LEAVE read_loop;
        END IF;
        SET @drop_partitions = IF(@drop_partitions = "", drop_part_name, CONCAT(@drop_partitions, ",", drop_part_name));
        END LOOP;
        IF @drop_partitions != "" THEN
        /*
           1. Build the SQL to drop all the necessary partitions.
           2. Run the SQL to drop the partitions.
           3. Print out the table partitions that were deleted.
        */
        SET @full_sql = CONCAT(@alter_header, @drop_partitions, ";");
        PREPARE STMT FROM @full_sql;
        EXECUTE STMT;
        DEALLOCATE PREPARE STMT;

        SELECT CONCAT(SCHEMANAME, ".", TABLENAME) AS `table`, @drop_partitions AS `partitions_deleted`;
        ELSE
        /*
           No partitions are being deleted, so print out "N/A" (Not applicable) to indicate
           that no changes were made.
        */
        SELECT CONCAT(SCHEMANAME, ".", TABLENAME) AS `table`, "N/A" AS `partitions_deleted`;
        END IF;
END$$
DELIMITER ;
DELIMITER $$
CREATE PROCEDURE `partition_maintenance`(SCHEMA_NAME VARCHAR(32), TABLE_NAME VARCHAR(32), KEEP_DATA_DAYS INT, HOURLY_INTERVAL INT, CREATE_NEXT_INTERVALS INT)
BEGIN
        DECLARE OLDER_THAN_PARTITION_DATE VARCHAR(16);
        DECLARE PARTITION_NAME VARCHAR(16);
        DECLARE OLD_PARTITION_NAME VARCHAR(16);
        DECLARE LESS_THAN_TIMESTAMP INT;
        DECLARE CUR_TIME INT;

        CALL partition_verify(SCHEMA_NAME, TABLE_NAME, HOURLY_INTERVAL);
        SET CUR_TIME = UNIX_TIMESTAMP(DATE_FORMAT(NOW(), '%Y-%m-%d 00:00:00'));

        SET @__interval = 1;
        create_loop: LOOP
        IF @__interval > CREATE_NEXT_INTERVALS THEN
    LEAVE create_loop;
        END IF;

        SET LESS_THAN_TIMESTAMP = CUR_TIME + (HOURLY_INTERVAL * @__interval * 3600);
        SET PARTITION_NAME = FROM_UNIXTIME(CUR_TIME + HOURLY_INTERVAL * (@__interval - 1) * 3600, 'p%Y%m%d%H00');
        IF(PARTITION_NAME != OLD_PARTITION_NAME) THEN
    CALL partition_create(SCHEMA_NAME, TABLE_NAME, PARTITION_NAME, LESS_THAN_TIMESTAMP);
        END IF;
        SET @__interval=@__interval+1;
        SET OLD_PARTITION_NAME = PARTITION_NAME;
        END LOOP;

        SET OLDER_THAN_PARTITION_DATE=DATE_FORMAT(DATE_SUB(NOW(), INTERVAL KEEP_DATA_DAYS DAY), '%Y%m%d0000');
        CALL partition_drop(SCHEMA_NAME, TABLE_NAME, OLDER_THAN_PARTITION_DATE);

END$$
DELIMITER ;
DELIMITER $$
CREATE PROCEDURE `partition_verify`(SCHEMANAME VARCHAR(64), TABLENAME VARCHAR(64), HOURLYINTERVAL INT(11))
BEGIN
        DECLARE PARTITION_NAME VARCHAR(16);
        DECLARE RETROWS INT(11);
        DECLARE FUTURE_TIMESTAMP TIMESTAMP;

        /*
         * Check if any partitions exist for the given SCHEMANAME.TABLENAME.
         */
        SELECT COUNT(1) INTO RETROWS
        FROM information_schema.partitions
        WHERE table_schema = SCHEMANAME AND table_name = TABLENAME AND partition_name IS NULL;

        /*
         * If partitions do not exist, go ahead and partition the table
         */
        IF RETROWS = 1 THEN
        /*
         * Take the current date at 00:00:00 and add HOURLYINTERVAL to it.  This is the timestamp below which we will store values.
         * We begin partitioning based on the beginning of a day.  This is because we don't want to generate a random partition
         * that won't necessarily fall in line with the desired partition naming (ie: if the hour interval is 24 hours, we could
         * end up creating a partition now named "p201403270600" when all other partitions will be like "p201403280000").
         */
        SET FUTURE_TIMESTAMP = TIMESTAMPADD(HOUR, HOURLYINTERVAL, CONCAT(CURDATE(), " ", '00:00:00'));
        SET PARTITION_NAME = DATE_FORMAT(CURDATE(), 'p%Y%m%d%H00');

        -- Create the partitioning query
        SET @__PARTITION_SQL = CONCAT("ALTER TABLE ", SCHEMANAME, ".", TABLENAME, " PARTITION BY RANGE(`clock`)");
        SET @__PARTITION_SQL = CONCAT(@__PARTITION_SQL, "(PARTITION ", PARTITION_NAME, " VALUES LESS THAN (", UNIX_TIMESTAMP(FUTURE_TIMESTAMP), "));");

        -- Run the partitioning query
        PREPARE STMT FROM @__PARTITION_SQL;
        EXECUTE STMT;
        DEALLOCATE PREPARE STMT;
        END IF;
END$$
DELIMITER ;

DELIMITER $$
CREATE PROCEDURE`partition_maintenance_all`(SCHEMA_NAME VARCHAR(32))
BEGIN
               CALL partition_maintenance(SCHEMA_NAME, 'history', 33, 24, 14);
               CALL partition_maintenance(SCHEMA_NAME, 'history_log', 33, 24, 14);
               CALL partition_maintenance(SCHEMA_NAME, 'history_str', 33, 24, 14);
               CALL partition_maintenance(SCHEMA_NAME, 'history_text', 33, 24, 14);
               CALL partition_maintenance(SCHEMA_NAME, 'history_uint', 367, 24, 14);
               CALL partition_maintenance(SCHEMA_NAME, 'trends', 368, 720, 12);
               CALL partition_maintenance(SCHEMA_NAME, 'trends_uint', 368, 168, 12);
END$$

其中需要修改的地方
CALL partition_maintenance(SCHEMA_NAME, 'history', 33, 24, 14);
CALL partition_maintenance(SCHEMA_NAME, 'history_log', 33, 24, 14);
CALL partition_maintenance(SCHEMA_NAME, 'history_str', 33, 24, 14);
CALL partition_maintenance(SCHEMA_NAME, 'history_text', 33, 24, 14);
CALL partition_maintenance(SCHEMA_NAME, 'history_uint', 367, 24, 14);
CALL partition_maintenance(SCHEMA_NAME, 'trends', 368, 720, 12);
CALL partition_maintenance(SCHEMA_NAME, 'trends_uint', 368, 168, 12);

舉例:
('history', 33, 24, 14);
history :表名
33:歷史數(shù)據(jù)保留時(shí)間 單位天
24:每多長時(shí)間分表 單位小時(shí)
14:每次運(yùn)行腳本分多少張表 單位張

#導(dǎo)入存儲(chǔ)過程到數(shù)據(jù)庫
[11:27:28 root@localhost ~]#mysql -uzabbix -p zabbix < par.sql
#調(diào)用存儲(chǔ)過程
[11:27:28 root@localhost ~]#mysql  -uzabbix -pPASSWORD zabbix -e"CALL partition_maintenance_all('zabbix')" &>/var/log/partition.log
#查看是否生成相關(guān)數(shù)據(jù)庫表
[12:04:04 root@localhost ~]#ll -ah /var/lib/mysql/zabbix/trend*
-rw-rw---- 1 mysql mysql 2.0K Jul 21 10:48 /var/lib/mysql/zabbix/trends.frm
-rw-rw---- 1 mysql mysql  244 Jul 21 10:48 /var/lib/mysql/zabbix/trends.par
-rw-rw---- 1 mysql mysql 368K Jul 21 12:04 /var/lib/mysql/zabbix/trends#P#p202107210000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202108200000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202109190000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202110190000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202111180000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202112180000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202201170000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202202160000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202203180000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202204170000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202205170000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends#P#p202206160000.ibd
-rw-rw---- 1 mysql mysql 2.0K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint.frm
-rw-rw---- 1 mysql mysql  244 Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint.par
-rw-rw---- 1 mysql mysql  15M Jul 21 12:04 /var/lib/mysql/zabbix/trends_uint#P#p202107210000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202107280000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202108040000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202108110000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202108180000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202108250000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202109010000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202109080000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202109150000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202109220000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202109290000.ibd
-rw-rw---- 1 mysql mysql  96K Jul 21 10:48 /var/lib/mysql/zabbix/trends_uint#P#p202110060000.ibd
[12:04:14 root@localhost ~]#ll -ah /var/lib/mysql/zabbix/history*
-rw-rw---- 1 mysql mysql 2.1K Jul 21 10:48 /var/lib/mysql/zabbix/history.frm
-rw-rw---- 1 mysql mysql 2.4K Jul 21 10:48 /var/lib/mysql/zabbix/history_log.frm
-rw-rw---- 1 mysql mysql  284 Jul 21 10:48 /var/lib/mysql/zabbix/history_log.par
-rw-rw---- 1 mysql mysql 352K Jul 21 12:04 /var/lib/mysql/zabbix/history_log#P#p202107210000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107220000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107230000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107240000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107250000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107260000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107270000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107280000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107290000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107300000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202107310000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202108010000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202108020000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_log#P#p202108030000.ibd
-rw-rw---- 1 mysql mysql  284 Jul 21 10:48 /var/lib/mysql/zabbix/history.par
-rw-rw---- 1 mysql mysql  18M Jul 21 12:04 /var/lib/mysql/zabbix/history#P#p202107210000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107220000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107230000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107240000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107250000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107260000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107270000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107280000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107290000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107300000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202107310000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202108010000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202108020000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history#P#p202108030000.ibd
-rw-rw---- 1 mysql mysql 2.8K Jul 21 10:48 /var/lib/mysql/zabbix/history_str.frm
-rw-rw---- 1 mysql mysql  284 Jul 21 10:48 /var/lib/mysql/zabbix/history_str.par
-rw-rw---- 1 mysql mysql 368K Jul 21 12:01 /var/lib/mysql/zabbix/history_str#P#p202107210000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107220000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107230000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107240000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107250000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107260000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107270000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107280000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107290000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107300000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202107310000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202108010000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202108020000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_str#P#p202108030000.ibd
-rw-rw---- 1 mysql mysql 2.1K Jul 21 10:48 /var/lib/mysql/zabbix/history_text.frm
-rw-rw---- 1 mysql mysql  284 Jul 21 10:48 /var/lib/mysql/zabbix/history_text.par
-rw-rw---- 1 mysql mysql 224K Jul 21 12:04 /var/lib/mysql/zabbix/history_text#P#p202107210000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107220000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107230000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107240000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107250000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107260000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107270000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107280000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107290000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107300000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202107310000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202108010000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202108020000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_text#P#p202108030000.ibd
-rw-rw---- 1 mysql mysql 2.1K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint.frm
-rw-rw---- 1 mysql mysql  284 Jul 21 10:48 /var/lib/mysql/zabbix/history_uint.par
-rw-rw---- 1 mysql mysql 144M Jul 21 12:04 /var/lib/mysql/zabbix/history_uint#P#p202107210000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107220000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107230000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107240000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107250000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107260000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107270000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107280000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107290000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107300000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202107310000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202108010000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202108020000.ibd
-rw-rw---- 1 mysql mysql 112K Jul 21 10:48 /var/lib/mysql/zabbix/history_uint#P#p202108030000.ibd

3、設(shè)置定時(shí)任務(wù)

[12:04:27 root@localhost ~]#crontab -e

01 01 * * *  /usr/bin/mysql -uzabbix -ppassword zabbix -e "CALL partition_maintenance_all('zabbix')" &>/var/log/partition.log

4歹篓、關(guān)閉zabbix 管家功能(housekeeping)


image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末瘫证,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子庄撮,更是在濱河造成了極大的恐慌背捌,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,042評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件洞斯,死亡現(xiàn)場(chǎng)離奇詭異毡庆,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)烙如,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,996評(píng)論 2 384
  • 文/潘曉璐 我一進(jìn)店門么抗,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人亚铁,你說我怎么就攤上這事蝇刀。” “怎么了徘溢?”我有些...
    開封第一講書人閱讀 156,674評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵吞琐,是天一觀的道長。 經(jīng)常有香客問我然爆,道長站粟,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,340評(píng)論 1 283
  • 正文 為了忘掉前任曾雕,我火速辦了婚禮奴烙,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘剖张。我一直安慰自己切诀,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,404評(píng)論 5 384
  • 文/花漫 我一把揭開白布搔弄。 她就那樣靜靜地躺著趾牧,像睡著了一般。 火紅的嫁衣襯著肌膚如雪肯污。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,749評(píng)論 1 289
  • 那天,我揣著相機(jī)與錄音蹦渣,去河邊找鬼哄芜。 笑死,一個(gè)胖子當(dāng)著我的面吹牛柬唯,可吹牛的內(nèi)容都是我干的认臊。 我是一名探鬼主播,決...
    沈念sama閱讀 38,902評(píng)論 3 405
  • 文/蒼蘭香墨 我猛地睜開眼锄奢,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼失晴!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起拘央,我...
    開封第一講書人閱讀 37,662評(píng)論 0 266
  • 序言:老撾萬榮一對(duì)情侶失蹤涂屁,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后灰伟,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體拆又,經(jīng)...
    沈念sama閱讀 44,110評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,451評(píng)論 2 325
  • 正文 我和宋清朗相戀三年栏账,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了帖族。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,577評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡挡爵,死狀恐怖竖般,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情茶鹃,我是刑警寧澤涣雕,帶...
    沈念sama閱讀 34,258評(píng)論 4 328
  • 正文 年R本政府宣布,位于F島的核電站前计,受9級(jí)特大地震影響胞谭,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜男杈,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,848評(píng)論 3 312
  • 文/蒙蒙 一丈屹、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧伶棒,春花似錦旺垒、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,726評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至宛渐,卻和暖如春竞漾,著一層夾襖步出監(jiān)牢的瞬間眯搭,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,952評(píng)論 1 264
  • 我被黑心中介騙來泰國打工业岁, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留鳞仙,地道東北人纱新。 一個(gè)月前我還...
    沈念sama閱讀 46,271評(píng)論 2 360
  • 正文 我出身青樓最域,卻偏偏與公主長得像相味,于是被迫代替她去往敵國和親昭抒。 傳聞我的和親對(duì)象是個(gè)殘疾皇子歪赢,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,452評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容