2014-10-18 38 views
0

我已配置系統配置以創建進程核心轉儲。進程核心轉儲不會在崩潰後創建

下面是我的配置。

/etc/sysctl.conf 
    kernel.core_uses_pid = 1 
    kernel.core_pattern = /var/core/core.%e.%p.%h.%t 
    fs.suid_dumpable = 2 

/etc/security/limits.conf 
    *    soft core unlimited 
    root   soft core unlimited 

以下是我關注的用於生成進程內核的步驟。

1)我重新啓動了mysql服務並執行了命令「kill -s SEGV <mysql_pid>」,然後我在/ var/core位置獲得了核心轉儲文件。

2)然後我開始我的服務mysql說"/etc/init.d/mysql start""service mysql start"。現在如果我給「kill -s SEGV <mysql_pid>」,那麼核心轉儲文件沒有被創建。

3)爲了再次獲得崩潰文件,我必須重新啓動mysql服務,然後只有當我給「kill -s SEGV <mysql_pid>」我收到核心轉儲文件。

任何人都可以請幫助我如何解決這個問題嗎?

回答

0

首先,你可以驗證核心轉儲是MySQL進程禁用運行:

# cat /proc/`pidof -s mysqld`/limits|egrep '(Limit|core)' 
Limit      Soft Limit   Hard Limit   Units 
Max core file size  0     unlimited   bytes 

的「軟」限制是一個在這種情況下,尋找,零意味着核心轉儲禁用。

默認情況下,在/etc/security/limits.conf中設置的限制僅適用於以交互方式啓動的程序。您可能必須在mysqld啓動腳本中包含'ulimit -c unlimited'才能永久啓用內核。

如果你幸運的話,那麼你就可以啓用核心轉儲當前shell和使用其的init.d腳本來重新啓動守護進程:

# ulimit -c unlimited 
# /etc/init.d/mysql restart 
* Stopping MySQL database server mysqld    [ OK ] 
* Starting MySQL database server mysqld    [ OK ] 
* Checking for tables which need an upgrade, are corrupt 
    or were not closed cleanly. 
# cat /proc/`pidof -s mysqld`/limits|egrep '(Limit|core)' 
Limit      Soft Limit   Hard Limit   Units 
Max core file size  unlimited   unlimited   bytes 

正如你所看到的,這適用於MySQL的我的系統上。

請注意,這不適用於像Apache這樣的應用程序,它在內部調用ulimit來禁用核心轉儲,而不是用於使用upstart的init.d腳本。