2013-12-21 145 views
1

我有以下的.plist啓動守護進程在/ Library/LaunchDaemons/的Mac OS X的mysql啓動守護進程定期不啓動開機

根據您發佈的文章中,我創建了下面的.plist爲啓動守護進程。

雖然它似乎現在工作,它仍然展現相同的行爲或啓動多個mysqld進程(我認爲這是它有時不工作的原因)。我還附上日誌

phppos-mysql.plist

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
<dict> 
    <key>Label</key> 
    <string>phppos-mysql</string> 
    <key>Disabled</key> 
    <false/> 
    <key>RunAtLoad</key> 
    <true/> 
    <key>KeepAlive</key> 
    <true/> 
    <key>Program</key> 
    <string>/Applications/phppos/mysql/bin/mysqld</string> 
    <key>ProgramArguments</key> 
    <array> 
     <string>--defaults-file=/Applications/phppos/mysql/my.cnf</string> 
     <string>--port=8081</string> 
     <string>--socket=/Applications/phppos/mysql/tmp/mysql.sock</string> 
     <string>--datadir=/Applications/phppos/mysql/data</string> 
     <string>--log-error=/Applications/phppos/mysql/data/mysqld.log</string> 
     <string>--pid-file=/Applications/phppos/mysql/data/mysqld.pid</string> 
     <string>--lower-case-table-names=1</string> 
     <string>--user=_mysql</string> 
    </array> 
    <key>UserName</key> 
    <string>_mysql</string> 
    <key>GroupName</key> 
    <string>_mysql</string> 
    <key>WorkingDirectory</key> 
    <string>/Applications/phppos/mysql/</string> 
    <key>Umask</key> 
    <integer>7</integer> 
</dict> 
</plist> 

日誌文件:

131222 13:46:28 [Note] /Applications/phppos/mysql/bin/mysqld.bin: Normal shutdown 

131222 13:46:28 [Note] Event Scheduler: Purging the queue. 0 events 
131222 13:46:28 InnoDB: Starting shutdown... 
131222 13:46:30 InnoDB: Shutdown completed; log sequence number 0 310408 
131222 13:46:30 [Note] /Applications/phppos/mysql/bin/mysqld.bin: Shutdown complete 

131222 13:46:43 mysqld_safe Starting mysqld.bin daemon with databases from /Applications/phppos/mysql/data 
131222 13:46:43 [Note] Plugin 'FEDERATED' is disabled. 
131222 13:46:43 [Note] Plugin 'FEDERATED' is disabled. 
131222 13:46:43 InnoDB: Initializing buffer pool, size =131222 13:46:43 InnoDB: Initializing buffer pool, size = 8.0M 
131222 13:46:43 InnoDB: Completed initialization of buffer pool 
8.0M 
131222 13:46:43 InnoDB: Completed initialization of buffer pool 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
131222 13:46:43 InnoDB: Retrying to lock the first data file 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
131222 13:46:49 InnoDB: Started; log sequence number 0 310408 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
131222 13:46:49 [Note] Event Scheduler: Loaded 0 events 
131222 13:46:49 [Note] /Applications/phppos/mysql/bin/mysqld.bin: ready for connections. 
Version: '5.1.56' socket: '/Applications/phppos/mysql/tmp/mysql.sock' port: 8081 MySQL Community Server (GPL) 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
InnoDB: Unable to lock ./ibdata1, error: 35 
InnoDB: Check that you do not already have another mysqld process 
InnoDB: using the same InnoDB data or log files. 
131222 13:48:25 InnoDB: Unable to open the first data file 
InnoDB: Error in opening ./ibdata1 
131222 13:48:25 InnoDB: Operating system error number 35 in a file operation. 
InnoDB: Error number 35 means 'Resource temporarily unavailable'. 
InnoDB: Some operating system error numbers are described at 
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html 
InnoDB: Could not open or create data files. 
InnoDB: If you tried to add new data files, and it failed here, 
InnoDB: you should now edit innodb_data_file_path in my.cnf back 
InnoDB: to what it was, and remove the new ibdata files InnoDB created 
InnoDB: in this failed attempt. InnoDB only wrote those files full of 
InnoDB: zeros, but did not yet use them in any way. But be careful: do not 
InnoDB: remove old data files which contain your precious data! 
131222 13:48:25 [ERROR] Plugin 'InnoDB' init function returned error. 
131222 13:48:25 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
131222 13:48:25 [ERROR] Unknown/unsupported table type: InnoDB 
131222 13:48:25 [ERROR] Aborting 

131222 13:48:25 [Note] /Applications/phppos/mysql/bin/mysqld.bin: Shutdown complete 

131222 13:48:25 mysqld_safe mysqld from pid file /Applications/phppos/mysql/data/mysqld.pid ended 
+1

launchd要求進程不守護進程(即它們保持在前臺運行)。 mysqld_safe不符合。見http://hints.macworld.com/article.php?story=20080128103022907 – eggyal

+0

我很難跟隨你鏈接到的文章。它似乎使用launchd,但不使用mysqld_safe(它似乎使用/ usr/local/mysql/bin/mysqld)。那是我應該注意的嗎? –

+0

重啓後30秒後似乎死亡 –

回答

1

這是有可能的問題是你最後的意見是問正是。我的理解是,mysqld_safe運行mysqld守護進程作爲用戶(通常是mysql)而不是root用戶。這違反了launchd(作爲非特權用戶)運行的規則,並且無法正確使用。

在終端發出命令(在MySQL正在運行):

ps -ef | grep mysqld 

應該給你正確的參數在你的plist中ProgramArguments使用。可能需要改變的唯一事情是:

<string>/Applications/phppos/mysql/bin/mysqld_safe</string> 

,使之成爲:

<string>/Applications/phppos/mysql/bin/mysqld</string> 

*如果問題仍然存在,請檢查您的my.cnf,以確保它與您的.plist中的參數一致,並沒有任何其他事情正在使用端口8081. This musing也有一些優秀的信息和洞察力,可以幫助您瞭解launchdaemons如何與mysql直接相關。

+0

我試圖用mysqld代替mysqld_safe。它啓動並運行了大約一分鐘,然後關機。以上我發佈了mysqld日誌。 –

+0

我已經讀過這篇文章,並模仿他們的.plist文件,但它現在似乎工作,它仍然啓動一堆mysqld進程啓動。 –

+0

我還需要能夠停止mysql(執行升級)。 keep alive參數似乎不能阻止它。 –

0

我想出了這個問題。我有兩個腳本同時啓動mysql。其中一個腳本嘗試關閉mysql。如果在第二個腳本啓動mysql之前這樣做了,那麼mysql會停止。

解決的辦法是修改該腳本不做任何與mysql有關的事情。