Alma Linux 8, MySQL partitioning, perl, Zabbix 7.0

Source:
https://www.thezabbixbook.com/ch13-advanced-security/partitioning-database/

systemctl disable --now zabbix-server
dnf --enablerepo=powertools -y install perl-DateTime wget perl-DBI perl-Sys-Syslog perl-DBD-mysql vim
cd /usr/local/bin
wget https://raw.githubusercontent.com/OpensourceICTSolutions/zabbix-mysql-partitioning-perl/refs/heads/main/mysql_zbx_part.pl
chmod +x mysql_zbx_part.pl
Initialize partitions:
TRUNCATE TABLE auditlog;
ALTER TABLE auditlog DROP PRIMARY KEY, ADD PRIMARY KEY (auditid, clock);
ALTER TABLE auditlog PARTITION BY RANGE (clock) (PARTITION p2010_01_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-01-02 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE history_uint;
ALTER TABLE history_uint PARTITION BY RANGE (clock) (PARTITION p2010_01_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-01-02 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE history_str;
ALTER TABLE history_str PARTITION BY RANGE (clock) (PARTITION p2010_01_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-01-02 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE history_log;
ALTER TABLE history_log PARTITION BY RANGE (clock) (PARTITION p2010_01_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-01-02 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE history_text;
ALTER TABLE history_text PARTITION BY RANGE (clock) (PARTITION p2010_01_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-01-02 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE history_bin;
ALTER TABLE history_bin PARTITION BY RANGE (clock) (PARTITION p2010_01_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-01-02 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE history;
ALTER TABLE history PARTITION BY RANGE (clock) (PARTITION p2010_01_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-01-02 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE trends_uint;
ALTER TABLE trends_uint PARTITION BY RANGE (clock) (PARTITION p2010_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-02-01 00:00:00")) ENGINE = InnoDB);

TRUNCATE TABLE trends;
ALTER TABLE trends PARTITION BY RANGE (clock) (PARTITION p2010_01 VALUES LESS THAN (UNIX_TIMESTAMP("2010-02-01 00:00:00")) ENGINE = InnoDB);
Install script:
cd /usr/local/bin
Set executable:
chmod +x mysql_zbx_part.pl
Observe application password:
grep ^DB /etc/zabbix/zabbix_server.conf
Run script:
./mysql_zbx_part.pl

No comments: