dnf --enablerepo=powertools install perl-DateTime wget perl-DBI perl-Sys-Syslog perl-DBD-mysql -y
I am using Zabbix server in Amazon Web Services (AWS) cloud solution.I am running partitioning script from:
https://zabbix.org/wiki/Docs/howto/mysql_partitioning#Partitioning_with_an_external_script
Here is the issue list I face and how I solved them.
First problem:
Can't locate Sys/Syslog.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./zabbix-partitioning.perl line 6.
BEGIN failed--compilation aborted at ./zabbix-partitioning.perl line 6.To solve:yum -y install perl-Sys-SyslogAnd now the next error occurs:Can't locate DateTime.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./zabbix-partitioning.perl line 7.
BEGIN failed--compilation aborted at ./zabbix-partitioning.perl line 7.To solve:yum -y install perl-DateTime
On CentOS 8:dnf --enablerepo=powertools install perl-DateTime
And now:DBI connect('zabbix:mysql_socket=/var/lib/mysql/mysql.sock','zbx_srv',...) failed: Access denied for user 'zbx_srv'@'localhost' (using password: YES) at ./zabbix-partitioning.perl line 30.
Can't call method "prepare" on an undefined value at ./zabbix-partitioning.perl line 68.Lets create new user just for partitioning:mysql -h localhost -uroot -p5sRj4GXspvDKsBXW -P 3306 -s <<< 'grant all privileges on zabbix.* to zbx_part@localhost identified by "dwyQv5X3G6WwtYKg";'Here the daily script I end up placing under '/etc/cron.daily':In case if want to test if the script recreates paritions I can aouthorize in database:mysql -u$(grep "^DBUser" /etc/zabbix/zabbix_server.conf|sed "s/^.*=//") -p$(grep "^DBPassword" /etc/zabbix/zabbix_server.conf|sed "s/^.*=//")Go to zabbix DB:use zabbix;Drop same partition:ALTER TABLE history DROP PARTITION p2018_07_06;
Error:Can't locate DBI.pm in @INC (you may need to install the DBI module) (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at ./zabbix_partitioning.pl line 4.
BEGIN failed--compilation aborted at ./zabbix_partitioning.pl line 4.
Solution on CentOS8:dnf install perl-DBI
If tables do not exist then create it:
CREATE TABLE `history` (
`itemid` bigint unsigned NOT NULL,
`clock` int NOT NULL DEFAULT '0',
`value` double(16,4) NOT NULL DEFAULT '0.0000',
`ns` int NOT NULL DEFAULT '0',
KEY `history_1` (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `history_uint` (
`itemid` bigint unsigned NOT NULL,
`clock` int NOT NULL DEFAULT '0',
`value` bigint unsigned NOT NULL DEFAULT '0',
`ns` int NOT NULL DEFAULT '0',
KEY `history_uint_1` (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `history_str` (
`itemid` bigint unsigned NOT NULL,
`clock` int NOT NULL DEFAULT '0',
`value` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
`ns` int NOT NULL DEFAULT '0',
KEY `history_str_1` (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `history_log` (
`itemid` bigint unsigned NOT NULL,
`clock` int NOT NULL DEFAULT '0',
`timestamp` int NOT NULL DEFAULT '0',
`source` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
`severity` int NOT NULL DEFAULT '0',
`value` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`logeventid` int NOT NULL DEFAULT '0',
`ns` int NOT NULL DEFAULT '0',
KEY `history_log_1` (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `history_text` (
`itemid` bigint unsigned NOT NULL,
`clock` int NOT NULL DEFAULT '0',
`value` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`ns` int NOT NULL DEFAULT '0',
KEY `history_text_1` (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `trends` (
`itemid` bigint unsigned NOT NULL,
`clock` int NOT NULL DEFAULT '0',
`num` int NOT NULL DEFAULT '0',
`value_min` double(16,4) NOT NULL DEFAULT '0.0000',
`value_avg` double(16,4) NOT NULL DEFAULT '0.0000',
`value_max` double(16,4) NOT NULL DEFAULT '0.0000',
PRIMARY KEY (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `trends_uint` (
`itemid` bigint unsigned NOT NULL,
`clock` int NOT NULL DEFAULT '0',
`num` int NOT NULL DEFAULT '0',
`value_min` bigint unsigned NOT NULL DEFAULT '0',
`value_avg` bigint unsigned NOT NULL DEFAULT '0',
`value_max` bigint unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Create very old partition:
ALTER TABLE `history` PARTITION BY RANGE(clock)(PARTITION p2008_12_11 VALUES LESS THAN (UNIX_TIMESTAMP("2008-12-12 00:00:00")) ENGINE=InnoDB);
ALTER TABLE `history_uint` PARTITION BY RANGE(clock)(PARTITION p2008_12_11 VALUES LESS THAN (UNIX_TIMESTAMP("2008-12-12 00:00:00")) ENGINE=InnoDB);
ALTER TABLE `history_log` PARTITION BY RANGE(clock)(PARTITION p2008_12_11 VALUES LESS THAN (UNIX_TIMESTAMP("2008-12-12 00:00:00")) ENGINE=InnoDB);
ALTER TABLE `history_text` PARTITION BY RANGE(clock)(PARTITION p2008_12_11 VALUES LESS THAN (UNIX_TIMESTAMP("2008-12-12 00:00:00")) ENGINE=InnoDB);
ALTER TABLE `history_str` PARTITION BY RANGE(clock)(PARTITION p2008_12_11 VALUES LESS THAN (UNIX_TIMESTAMP("2008-12-12 00:00:00")) ENGINE=InnoDB);
ALTER TABLE `trends` PARTITION BY RANGE(clock)(PARTITION p2008_12_11 VALUES LESS THAN (UNIX_TIMESTAMP("2008-12-12 00:00:00")) ENGINE=InnoDB);
ALTER TABLE `trends_uint` PARTITION BY RANGE(clock)(PARTITION p2008_12_11 VALUES LESS THAN (UNIX_TIMESTAMP("2008-12-12 00:00:00")) ENGINE=InnoDB);
Aditional user for maintaining:groupadd zbx_part
useradd -g zbx_part -s /bin/bash zbx_part
# test connection
su - zbx_part
Problem:install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 29) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge.
Solution on RHEL deriative:yum install perl-DBD-mysql
CentOS8:dnf install perl-DBD-mysql