Linux 後台啟動 Redis

1. 修改 redis.conf

首先,這裡有一個坑 !

不同的 redis版本,在安裝的時候,redis.conf 的路徑稍微有些不同

redis.conf 可能出現的三個位置:

  • /etc/redis.conf
  • /redis/src/redis.conf
  • /redis/redis.conf

 

redis.conf配置文件中daemonize守護執行緒,默認是NO,daemonize是用來指定redis是否要用守護執行緒的方式啟動

daemonize yes : redis採用的是單進程多執行緒的模式。當redis.conf中選項daemonize設置成yes時,代表開啟守護進程模式。在該模式下,redis會在後台運行,並將進程pid號寫入至redis.conf選項pidfile設置的文件中,此時redis將一直運行,除非手動kill該進程。
daemonize no :當daemonize選項設置成no時,當前介面將進入redis的命令行介面,exit強制退出或者關閉連接工具(putty,xshell等)都會導致redis進程退出。
 
 

2. 執行後台啟動命令

./redis-server redis.conf