您在這裡

一啟動Drupal,伺服器就掛點?

tky's 的頭像
tky 在 2008-04-20 (周日) 16:26 發表

昨天發現的問題,蠻突然的,到現在都不曉得該怎麼解決,希望大家可以給點意見。

在ubuntu的伺服器上安裝了一個html站、一個預備要取代與轉換html的Drupal站,以及一個全新的Drupal網站;後兩個都是6.2版本的。

3個網站一直都運作良好,而且可以同時執行。直到昨天下午突然出問題,症狀是伺服器端回應非常慢,一直到連線逾時。原以為是被人家砍站,跑去重開伺服器後發現,一切都好好的,HTML網站運作正常。但只要一連線到Drupal站,系統的記憶體用量會突然飆到99.x%這麼多,直到把記憶體耗光,整個伺服器就慢到像掛點一樣。

原以為是裝了什麼模組的影響,不過發現說另一個幾乎什麼模組都沒裝的新Drupal網站也是一樣的狀況,一連線就狂吃記憶體。

查看一下伺服器報告,發現有這樣的訊息:

test.accesslog
warning : 3 clients are using or haven't closed the table properly
test.cache
warning : 3 clients are using or haven't closed the table properly
test.cache_update
warning : 1 client is using or hasn't closed the table properly
test.locales_source
warning : 1 client is using or hasn't closed the table properly
test.variable
warning : 3 clients are using or haven't closed the table properly
test.watchdog
error : Table './phil/watchdog' is marked as crashed and should be repaired

Improperly closed tables are also reported if clients are accessing
the tables *now*. A list of current connections is below.

+----+------------------+-----------+----+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info
|
+----+------------------+-----------+----+---------+------+-------+------------------+
| 7 | debian-sys-maint | localhost | | Query | 0 | | show processlist
|
+----+------------------+-----------+----+---------+------+-------+------------------+
Uptime: 52 Threads: 1 Questions: 516 Slow queries: 0 Opens: 495 Flush tables:
1 Open tables: 64 Queries per second avg: 9.923

每次一連線Drupal就會收到這樣的報告。有試著透過phpmyadmin來修復過所有的資料表,但是情況依舊。不是很清楚到底問題出在那裡。

另一方面,tky有試著把php的記憶體用量調低為32MB,不過仍舊沒有什麼影響。

應該是amp架構中不曉得哪個部分出了問題,一運作就把記憶體吃光了;希望有經驗的朋友們給點維修上的建議。不然tky的伺服器就只能用來跑html網頁而已了。XD

TKY

Ubuntu 7.10 Server edition
Web server Apache/2.2.4 (Ubuntu) PHP/5.2.3-1ubuntu6.3
MySQL database 5.0.45
PHP 5.2.3-1ubuntu6.3
PHP memory limit 128M
PHP register globals Disabled
Unicode library PHP Mbstring Extension
GD library 2.0 or higher

Drupal 6.2

以上是我的小小伺服器的 AMP 的版本。(與你的配置應該差不多,記憶中 TKY 在 Ubuntu 中文網詢問使用 Ubuntu Server edition 是否 OK)

我的經驗是 Drupal 掛了,其他的網站正常。

原因是 Drupal 的某一個 "table" is marked as crashed and should be repaired. (table 的名稱忘了)

因為手賤在後台測試 Modules,突然網頁開不出來。心中一驚,死好,沒事找事。

連到 phpMyAdmin 查看 Drupal 資料庫狀況,沒錯那一個 table 掛了。

解決方法:ssh 連到伺服器,進入 MySQL 使用 REPAIR 指令修復掛掉的 table,完工。(我不是使用 phpMyAdmin 修復掛掉的 table)

我發誓再也不手賤,Drupal 其實很穩定。安啦!

找出原因了。
居然是因為poormanscron 6.1的關係。因為網站還沒上線,每次一開網頁就會跑cron,不曉得是模組沒有寫好收尾還是怎樣,就是會跑到記憶體耗盡、網站陷入停頓的狀況。

換成dev的版本反而就沒有問題,真是奇怪。

而且很怪的地方是,明明在setting.php的地方有限制記憶體用量為24M,但是居然還是會耗光包含虛擬記憶體的一切記憶體而導致網站掛點?真是挺危險的一個問題。

目前還不曉得怎麼用ubuntu來跑Drupal的cron,等知道了之後恐怕要把poormanscron給停掉,以免萬一。

tky

tky

應該...是這樣吧?
看了Ubuntu 7.10的設定,檔案位置和CentOS 一樣啊...
#>vi /etc/crontab

...
0 * * * * wget -O - -q http://www.example.com/cron.php

tky這樣問,害我回答的有點惶恐。

我是MIS,略懂mail、http、dns、proxy server
習慣使用redhat系列linux
debian系列摸索中...