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)