Redis使用守護進程啓動sentinel並指定其日誌目錄

Redis使用守護進程啓動sentinel並指定其日誌目錄

2728人閱讀 評論(0) 收藏 舉報
分類: http://blog.csdn.net/xuxile/article/details/52216923

正常Redis-server可以通過配置文件來指定守護進程啓動以及指定日誌路徑,但sentinel就不一樣了。
正常啓動redis的sentinel時,進程會直接在前臺跑,一退出sentinel進程就關了:

[root@redis_01 redis]# redis-server /etc/redis/sentinel.conf --sentinel
7980:X 23 Nov 18:02:41.348 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 26379
 |    `-._   `._    /     _.-'    |     PID: 7980
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

7980:X 23 Nov 18:02:41.355 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
7980:X 23 Nov 18:02:41.355 # Sentinel runid is 43de323d55627d896b2caf1da2e305f0eb59dcee
7980:X 23 Nov 18:02:41.356 # +monitor master mymaster 127.0.0.1 6379 quorum 1
^C7980:signal-handler (1448273325) Received SIGINT scheduling shutdown...
7980:X 23 Nov 18:08:45.618 # User requested shutdown...
7980:X 23 Nov 18:08:45.618 # Sentinel is now ready to exit, bye bye...
[root@redis_01 redis]# ll

第一種方法:
使用nohub來啓動sentinel,使得進程在後臺啓動以及在指定目錄記錄日誌信息:
[root@redis_01 redis]# nohup /usr/local/redis/bin/redis-sentinel /etc/redis/sentinel.conf  >> /var/log/redis_sentinel.log 2>&1 &
[1] 8002
[root@redis_01 redis]# netstat -tunpl|grep sentinel
tcp        0      0 0.0.0.0:26379               0.0.0.0:*                   LISTEN      8002/redis-sentinel 
tcp        0      0 :::26379                    :::*                        LISTEN      8002/redis-sentinel 
[root@redis_01 redis]# tail -f /var/log/redis_sentinel.log 
8002:X 23 Nov 18:25:52.043 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
8002:X 23 Nov 18:25:52.043 # Sentinel runid is 7f1d63c2aede6ac97242aeaaba26d10778e28f0a
8002:X 23 Nov 18:25:52.043 # +monitor master mymaster 127.0.0.1 6379 quorum 1
這樣就可以實現後臺其他以及日誌記錄了。

第二種方法:
在sentinel的配置文件中添加以下內容:
[root@redis_01 redis]# vim sentinel.conf 
daemonize yes
logfile "/var/log/sentinel_log.log"
啓動,查看日誌:
[root@redis_01 redis]# redis-server /etc/redis/sentinel.conf --sentinel
[root@redis_01 redis]# cat /var/log/sentinel_log.log 
11109:X 26 Nov 11:22:04.376 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 26379
 |    `-._   `._    /     _.-'    |     PID: 11109
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

11109:X 26 Nov 11:22:04.379 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
11109:X 26 Nov 11:22:04.379 # Sentinel runid is 0f82780194cd3822ab32397b01996e205b4195c9
11109:X 26 Nov 11:22:04.379 # +monitor master mymaster 127.0.0.1 6379 quorum 1
[root@redis_01 redis]# ll
[root@redis_01 redis]# ps -ef|grep sentinel
root     11109     1  0 11:22 ?        00:00:00 redis-server *:26379 [sentinel]                 
root     11115 11076  0 11:22 pts/0    00:00:00 grep sentinel
已正常啓動。

本人使用第二種,所以也推薦第二種方法大笑

轉載自:http://www.suohi.cc/posts/5652e9401f6d1303e9f04a4d

發佈了8 篇原創文章 · 獲贊 22 · 訪問量 48萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章