【求助】有夠大的log檔



贊助商連結


皮皮
2002-11-12, 08:35 PM
【求助】有夠大的log檔
皮皮這幾飽受syn flood之苦...
頻寬老是被佔據!

想說查看個log檔看看!
沒有想到httpd抵下的access_log檔
居然440MB
另一個access_log.2也有200多MB

用SAMBA把檔案叫到WIN上看...
使用筆記本打開到記憶體不足....有什麼辦法可以查看裡面的資訊呢?

真是給它有夠恐怖...在LINUX內也是跑了半黇沒有反應說!
LOG檔有辦法字定大小限制嗎?

謝謝~

贊助商連結


repsol
2002-11-12, 11:31 PM
把 LOG file 分割成幾個file , 然後再逐一看
詳情可以 man split

SPLIT(1) FreeBSD General Commands Manual SPLIT(1)

NAME
split - split a file into pieces

SYNOPSIS
split [-a suffix_length] [-b byte_count[k|m]] [-l line_count]
[-p pattern] [file [name]]

DESCRIPTION
The split utility reads the given file and breaks it up into files of
1000 lines each. If file is a single dash (`-') or absent, split reads
from the standard input.

The options are as follows:

-a Use suffix_length letters to form the suffix of the file name.

-b Create smaller files byte_count bytes in length. If ``k'' is
appended to the number, the file is split into byte_count kilo?
byte pieces. If ``m'' is appended to the number, the file is
split into byte_count megabyte pieces.

-l Create smaller files n lines in length.

-p pattern
The file is split whenever an input line matches pattern, which
is interpreted as an extended regular expression. The matching
line will be the first line of the next output file. This option
is incompatible with the -b and -l options.

If additional arguments are specified, the first is used as the name of
the input file which is to be split. If a second additional argument is
specified, it is used as a prefix for the names of the files into which
the file is split. In this case, each file into which the file is split
is named by the prefix followed by a lexically ordered suffix using
suffix_length characters in the range ``a-z''. If -a is not specified,
two letters are used as the suffix.

If the name argument is not specified, the file is split into lexically
ordered files named with prefixes in the range of ``x-z'' and with suf?
fixes as above.

SEE ALSO
re_format(7)

STANDARDS
The split utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'').

HISTORY
A split command appeared in Version 3 AT&T UNIX.

BUGS
For historical reasons, if you specify name, split can only create 676
separate files. The default naming convention allows 2028 separate
files. The -a option can be used to work around this limitation.

The maximum line length for matching patterns is 65536.

FreeBSD 4.7 April 16, 1994 FreeBSD 4.7


ex :

split -l 幾行 愈分解的 file


限制 LOG 檔案大小的問題
可以定時 rotate log , 就可以控制 log 的檔案大小
可以一天 rotate 一次 , 或是每12個小時 rotate 一次
都可以控制 log file 的大小
下面的文章說明的很清楚 , 可以參考參考...



http://httpd.apache.org/docs/logs.html#rotation

On even a moderately busy server, the quantity of information stored in the log files is very large. The access log file typically grows 1 MB or more per 10,000 requests. It will consequently be necessary to periodically rotate the log files by moving or deleting the existing logs. This cannot be done while the server is running, because Apache will continue writing to the old log file as long as it holds the file open. Instead, the server must be restarted after the log files are moved or deleted so that it will open new log files.

By using a graceful restart, the server can be instructed to open new log files without losing any existing or pending connections from clients. However, in order to accomplish this, the server must continue to write to the old log files while it finishes serving old requests. It is therefore necessary to wait for some time after the restart before doing any processing on the log files. A typical scenario that simply rotates the logs and compresses the old logs to save space is:

mv access_log access_log.old
mv error_log error_log.old
apachectl graceful
sleep 600
gzip access_log.old error_log.old
Another way to perform log rotation is using piped logs as discussed in the next section


Good Luck !!!

dominic
2002-11-12, 11:54 PM
這怪怪滴ㄝ........我的access_log到了一個程度就會變成access_log.1......然後舊滴accessㄝ會自動被刪除才是.....怪怪.......

皮皮
2002-11-12, 11:59 PM
超正....這是我想要的!
學習內容中....謝謝repsol兄...