訪問日誌文件過大而導致啓動 Apache 時出現 httpd could not be started 錯誤

正式應用又好久沒有重啓過了,所以先停了 IBM Http Server (IHS,Apache 1.3.28),再把所有應用啓動妥當後,最後把 Apache 啓起來。終端下進到 IBMHttpServer 目錄,然後敲入命令:bin/apachectl start,得到的錯誤是:bin/apachectl start: httpd could not be started。

這下有點慌了神,以前從未碰到過,懷疑是配置文件 httpd.conf 有問題,但一般 httpd.conf 有問題有提示錯誤的,不管,還是用 bin/apachectl configtest 看下,返回 Syntax OK,沒問題。

可能別的程序佔用了 80 端口?netstat -na|grep 80 沒發現什麼。

翻看日誌,打開 IBMHttpServer 下的 log.txt,好久以前的信息,打開 logs/error_log 也是很久以前的信息。

網上搜索到一個相關的頁面是這個 http://lists.freebsd.org/pipermail/freebsd-questions/2006-January/110052.html

它給出來的答案是這兩個

Some ideas, I may be off base here:
1. Is there anything being written to the error_log file?
2. Can you start Apache with the -F argument to make it stay in the
foreground? Any output there?

真還有別的程序在寫 error_log 嗎?於是試着 mv error_log error_log_bak,更名也能成功,說明沒有其他進程鎖住了這個文件。再 bin/apachectl start 看看,依舊是:bin/apachectl start: httpd could not be started。但此時我立刻注意到在 logs/ 目錄下又生成了一個 error_log 文件,打開它,裏面赫然寫着:

[Mon May 19 23:19:05 2008] [error] (79)Value too large for defined data type: could not open transfer log file /d02/IBM/IBMHttpServer/logs/access_log.

就是說 access_log 的什麼數據類型太大,索性把 access_log 也用 mv access_log access_log_bak 更了名,再次執行 bin/apachectl start 提示 bin/apachectl start: httpd started,啓動成功。

再醒過神來用 ls -l logs 來看看,原來是那個 access_log_bak(從 access_log 更名而來的) 文件過大,已達到了 2147483734 字節,不能再寫了;而且 error_log_bak(從 error_log 更名而來的) 也不小了,405811968,連真正的錯誤信息都懶得記了。

所以,如果 access_log 裏的訪問記錄對你意義不大的話,你可以不記載它們,要修改配置文件 conf/httpd.conf,找到大致如 CustomLog /d02/IBM/IBMHttpServer/logs/access_log common 這樣的行,註釋掉就重啓 apache 就行了。


補充:2008-05-27 訪問日誌文件或錯誤日誌文件過大也會影響到響應請求的速度。當你的 Apache 處理請求很慢時,請留意一下這兩個文件的大小。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章