当前位置: 代码迷 >> 综合 >> :signal-handler (1523582415) Received SIGINT scheduling shutdown...
  详细解决方案

:signal-handler (1523582415) Received SIGINT scheduling shutdown...

热度:22   发布时间:2023-12-26 02:36:54.0

linux下安装redis---解决redis-cli不能正常使用

Linux中进入redis客户端,报链接超时

Could not connect to Redis at 127.0.0.1:6379: Connection timed out

 

Redis使用守护进程启动sentinel并指定其日志目录

正常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



  相关解决方案