- 论坛徽章:
- 0
|
我的表结构如下:
- --
- -- 表的结构 `logs`
- --
- CREATE TABLE `logs` (
- `host` varchar(32) default NULL,
- `facility` varchar(10) default NULL,
- `priority` varchar(10) default NULL,
- `level` varchar(10) default NULL,
- `tag` varchar(10) default NULL,
- `date` date default NULL,
- `time` time default NULL,
- `program` varchar(15) default NULL,
- `msg` text,
- `seq` int(10) unsigned NOT NULL auto_increment,
- `flag` tinyint(10) unsigned NOT NULL default '0',
- PRIMARY KEY (`seq`),
- KEY `host` (`host`),
- KEY `seq` (`seq`),
- KEY `program` (`program`),
- KEY `time` (`time`),
- KEY `date` (`date`),
- KEY `priority` (`priority`),
- KEY `facility` (`facility`),
- KEY `flag` (`flag`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1530668 ;
-
-
- -- 表的结构 `info`
- --
- CREATE TABLE `info` (
- `id` int(11) NOT NULL auto_increment,
- `name` varchar(60) character set latin1 NOT NULL default '',
- `name_en` varchar(60) collate gb2312_bin default NULL,
- `ip` varchar(60) character set latin1 NOT NULL default '',
- `memo` varchar(60) character set latin1 default NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=gb2312 COLLATE=gb2312_bin AUTO_INCREMENT=96 ;
-
复制代码
logs表中记录大概有10W条左右;
通过perl程序每30秒,查询一次数据库,找出新记录(flag为0的记录,默认值0,处理过置1)的,输出到文本文件中,然后再进行处理,
sql语句如下:
- my $sth1 = $dbh1->prepare("select logs.seq,logs.host,info.name,info.name_en,logs.priority,logs.msg into outfile \'/tmp/syslog.txt\' fields terminated by \'|\' lines terminated by \'\\n\' from info,logs where info.ip=logs.host and logs.flag=0 order by logs.seq ASC limit $rec_once ");
-
- if ($sth1->execute) {
- print "$timenow : Succeed to get data from syslog database !\n";
- system("cp /tmp/syslog.txt /tmp/tmpdir/syslog_$timenow.txt")
- }
- else {
- print "$timenow : Failed to get data ! \n"
- }
复制代码
现在碰到这样的问题:
一般情况下,运行还是比较正常的,但过一段时间后,多长时间也没准,导出的文本文件中会有很多flag为1的记录(肯定被处理过的,从序号seq可以看出来,是最早的一些记录),不知道是为什么? 还请哪位高手帮忙解惑,不胜感激
[ 本帖最后由 kobbydf 于 2006-8-23 11:47 编辑 ] |
|