I tried to partition the DB into 365 parts - day by day but that is to much for the mysql server So I tried to summarize days and with 14 days it is handy.
Code: Select all
CREATE TABLE `plugin_camm_syslog` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`host` varchar(128) DEFAULT NULL,
`sourceip` varchar(45) NOT NULL,
`facility` varchar(10) DEFAULT NULL,
`priority` varchar(10) DEFAULT NULL,
`sys_date` datetime DEFAULT NULL,
`message` text,
`status` tinyint(4) NOT NULL DEFAULT '0',
`alert` smallint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`,`sys_date` ),
KEY `facility` (`facility`),
KEY `priority` (`priority`),
KEY `sourceip` (`sourceip`),
KEY `status` (`status`),
KEY `alert` (`alert`),
KEY `status_date` (`status`,`sys_date`),
KEY `sys_date` (`sys_date`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='camm plugin SYSLOG Data'
PARTITION BY RANGE ( dayofyear(sys_date))
(PARTITION syslog_day0 VALUES LESS THAN (0) ENGINE = MyISAM,
PARTITION syslog_day14 VALUES LESS THAN (14) ENGINE = MyISAM,
PARTITION syslog_day28 VALUES LESS THAN (28) ENGINE = MyISAM,
PARTITION syslog_day42 VALUES LESS THAN (42) ENGINE = MyISAM,
PARTITION syslog_day56 VALUES LESS THAN (56) ENGINE = MyISAM,
PARTITION syslog_day70 VALUES LESS THAN (70) ENGINE = MyISAM,
PARTITION syslog_day84 VALUES LESS THAN (84) ENGINE = MyISAM,
PARTITION syslog_day98 VALUES LESS THAN (98) ENGINE = MyISAM,
PARTITION syslog_day112 VALUES LESS THAN (112) ENGINE = MyISAM,
PARTITION syslog_day126 VALUES LESS THAN (126) ENGINE = MyISAM,
PARTITION syslog_day140 VALUES LESS THAN (140) ENGINE = MyISAM,
PARTITION syslog_day154 VALUES LESS THAN (154) ENGINE = MyISAM,
PARTITION syslog_day168 VALUES LESS THAN (168) ENGINE = MyISAM,
PARTITION syslog_day182 VALUES LESS THAN (182) ENGINE = MyISAM,
PARTITION syslog_day196 VALUES LESS THAN (196) ENGINE = MyISAM,
PARTITION syslog_day210 VALUES LESS THAN (210) ENGINE = MyISAM,
PARTITION syslog_day224 VALUES LESS THAN (224) ENGINE = MyISAM,
PARTITION syslog_day238 VALUES LESS THAN (238) ENGINE = MyISAM,
PARTITION syslog_day252 VALUES LESS THAN (252) ENGINE = MyISAM,
PARTITION syslog_day266 VALUES LESS THAN (266) ENGINE = MyISAM,
PARTITION syslog_day280 VALUES LESS THAN (280) ENGINE = MyISAM,
PARTITION syslog_day294 VALUES LESS THAN (294) ENGINE = MyISAM,
PARTITION syslog_day308 VALUES LESS THAN (308) ENGINE = MyISAM,
PARTITION syslog_day322 VALUES LESS THAN (322) ENGINE = MyISAM,
PARTITION syslog_day336 VALUES LESS THAN (336) ENGINE = MyISAM,
PARTITION syslog_day350 VALUES LESS THAN (350) ENGINE = MyISAM,
PARTITION syslog_day364 VALUES LESS THAN (364) ENGINE = MyISAM,
PARTITION syslog_day369 VALUES LESS THAN (369) ENGINE = MyISAM) ;
";
Perhaps this helps you for the code. Take care on the index and the time intervall.
Torsten