我在使用 redis 时遇到了一个奇怪的问题,大约每 30 分钟它会断开所有客户端的连接。注销请见下文。在这种情况下,我既没有设置 maxclients,也没有应用超时。
有任何想法吗?
[23829] 29 Dec 16:32:09 * DB saved on disk
[1332] 29 Dec 16:32:09 * Background saving terminated with success
..................... last save ...................
[1332] 29 Dec 16:32:11 - DB 0: 71487 keys (0 volatile) in 131072 slots HT.
[1332] 29 Dec 16:32:11 - DB 10: 1270390 keys (23754 volatile) in 2097152 slots HT.
[1332] 29 Dec 16:32:11 - 240 clients connected (0 slaves), 505148952 bytes in use
.............. everything runs smoothly .............................
[1332] 29 Dec 16:32:42 - DB 0: 71487 keys (0 volatile) in 131072 slots HT.
[1332] 29 Dec 16:32:42 - DB 10: 1270407 keys (23756 volatile) in 2097152 slots HT.
[1332] 29 Dec 16:32:42 - 240 clients connected (0 slaves), 505151288 bytes in use
[1332] 29 Dec 16:32:47 - DB 0: 71486 keys (0 volatile) in 131072 slots HT.
[1332] 29 Dec 16:32:56 - DB 10: 1270389 keys (23737 volatile) in 2097152 slots HT.
[1332] 29 Dec 16:32:56 - 240 clients connected (0 slaves), 505145592 bytes in use
[1332] 29 Dec 16:32:56 - Client closed connection
[1332] 29 Dec 16:32:56 - Client closed connection
[1332] 29 Dec 16:32:56 - Client closed connection
.......... all 240 clients disconnect here at once ............
[1332] 29 Dec 16:32:56 - Client closed connection
[1332] 29 Dec 16:32:56 - Accepted xxx.xxx.xxx.xxx:54879
.......... clients start reconnecting
[1332] 29 Dec 16:32:56 - Client closed connection
[1332] 29 Dec 16:32:56 - Accepted xxx.xxx.xxx.xxx:53152
[1332] 29 Dec 16:32:56 - Accepted 127.0.0.1:33971
[1332] 29 Dec 16:33:06 - DB 0: 71489 keys (0 volatile) in 131072 slots HT.
[1332] 29 Dec 16:33:06 - DB 10: 1270315 keys (23658 volatile) in 2097152 slots HT.
[1332] 29 Dec 16:33:06 - 225 clients connected (0 slaves), 504819848 bytes in use
[1332] 29 Dec 16:33:06 - Accepted xxx.xxx.xxx.xxx:53764
[1332] 29 Dec 16:33:06 - Accepted xxx.xxx.xxx.xxx:53766
[1332] 29 Dec 16:33:06 - Accepted xxx.xxx.xxx.xxx:54940
[1332] 29 Dec 16:33:07 - Accepted xxx.xxx.xxx.xxx:54941
[1332] 29 Dec 16:33:09 - Accepted xxx.xxx.xxx.xxx:54942
[1332] 29 Dec 16:33:09 - Accepted xxx.xxx.xxx.xxx:49227
[1332] 29 Dec 16:33:10 * 10000 changes in 60 seconds. Saving...
[1332] 29 Dec 16:33:10 * Background saving started by pid 24057
[1332] 29 Dec 16:33:11 - DB 0: 71489 keys (0 volatile) in 131072 slots HT.
[1332] 29 Dec 16:33:11 - DB 10: 1270270 keys (23615 volatile) in 2097152 slots HT.
[1332] 29 Dec 16:33:11 - 234 clients connected (0 slaves), 504908696 bytes in use
..... everything returns to normal, for about 30 minutes .............
答案1
好吧,答案是 cronjob...但不在 Redis 主机上。我让另一台主机每 30 分钟将数据库备份 ~900MB 复制到运行 redis 的主机上。
显然这导致了一些问题,我将备份切换到了不同的主机,从那时起一切都运行顺利。