不常見,但有的時候開機redis沒有自個啟動,不知道如何查找原因,請高人指點
$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
我看了下日至,如下
[207] 29 Sep 18:22:41.020 * 1 changes in 900 seconds. Saving...
[207] 29 Sep 18:22:41.099 * Background saving started by pid 2473
[2473] 29 Sep 18:22:41.685 * DB saved on disk
[207] 29 Sep 18:22:42.014 * Background saving terminated with success
[207 | signal handler] (1380450274) Received SIGTERM, scheduling shutdown...
[207] 29 Sep 18:24:34.759 # User requested shutdown...
[207 | signal handler] (1380450274) Received SIGTERM, scheduling shutdown...
[207] 29 Sep 18:24:34.899 * Saving the final RDB snapshot before exiting.
[207] 29 Sep 18:24:35.050 * DB saved on disk
[207] 29 Sep 18:24:35.050 * Removing the pid file.
[207] 29 Sep 18:24:35.150 # Redis is now ready to exit, bye bye...
[620] 29 Sep 21:50:35.953 * Max number of open files set to 10032
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.6.14 (00000000/0) 64 bit
.-`` .-". "\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 620
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[620] 29 Sep 21:50:35.971 # Server started, Redis version 2.6.14
[620] 29 Sep 21:50:35.984 * DB loaded from disk: 0.013 seconds
[620] 29 Sep 21:50:35.984 * The server is now ready to accept connections on port 6379
好像也沒有異常,上麵提到的
[207] 29 Sep 18:24:35.050 * Removing the pid file.
因該是我關機的緣故,pid刪除了,一般的情況下,開機會自動啟動pid的,但是這次沒有,上麵啟動界麵是我最有一次手動啟動的log信息
redis在啟動的時候會為信號SIGTERM註冊信號處理函數,該函數會讓redis在結束運行之前做些資源清理工作,譬如保存RDB文件,刪除PID文件(如果redis是以daemon方式運行)等等,當這些工作都做完後,呼叫exit函數退出
所以日誌這段內容:
都是符合上述我說的流程,收到SIGTERM訊號 -> 處理資源 -> 結束redis服務
但是後面這些日誌,看時間應該跟上面的不是同一個:
所以我覺得問題的關鍵是為什麼在Redis啟動的時候會收到一個SIGTERM訊號?