使用Redis无需停机即可丢失数据

时间:2017-12-16 13:59:26

标签: redis

Redis似乎丢失了一些我的数据,没有服务器进程死机。第一个持续存在的新数据似乎是在12:26。 Redis的日志如下。 redis-cli info stats显示进程正常运行时间为3天。这个RDB后台保存失败了吗?有足够的磁盘空间。

Redis版本是4.0.6

24121:M 16 Dec 12:17:26.011 * 10 changes in 300 seconds. Saving...
24121:M 16 Dec 12:17:26.117 * Background saving started by pid 370
370:C 16 Dec 12:17:44.994 * DB saved on disk
370:C 16 Dec 12:17:45.068 * RDB: 167 MB of memory used by copy-on-write
24121:M 16 Dec 12:17:45.260 * Background saving terminated with success
24121:M 16 Dec 12:21:19.891 * DB saved on disk
24121:M 16 Dec 12:21:21.465 * DB saved on disk
24121:M 16 Dec 12:22:00.152 * DB saved on disk
24121:M 16 Dec 12:22:00.474 * DB saved on disk
24121:M 16 Dec 12:22:32.699 * DB saved on disk
24121:M 16 Dec 12:22:33.044 * DB saved on disk
24121:M 16 Dec 12:22:33.579 * DB saved on disk
24121:M 16 Dec 12:22:33.993 * DB saved on disk
24121:M 16 Dec 12:22:34.462 * DB saved on disk
24121:M 16 Dec 12:22:35.167 * DB saved on disk
24121:M 16 Dec 12:22:35.500 * DB saved on disk
24121:M 16 Dec 12:22:36.107 * DB saved on disk
24121:M 16 Dec 12:23:02.170 * DB saved on disk
24121:M 16 Dec 12:23:02.564 * DB saved on disk
24121:M 16 Dec 12:23:02.853 * DB saved on disk
24121:M 16 Dec 12:23:03.142 * DB saved on disk
24121:M 16 Dec 12:23:03.505 * DB saved on disk
24121:M 16 Dec 12:23:03.792 * DB saved on disk
24121:M 16 Dec 12:23:04.174 * DB saved on disk
24121:M 16 Dec 12:23:04.526 * DB saved on disk
24121:M 16 Dec 12:23:04.898 * DB saved on disk
24121:M 16 Dec 12:23:05.214 * DB saved on disk
24121:M 16 Dec 12:23:05.573 * DB saved on disk
24121:M 16 Dec 12:23:06.078 * DB saved on disk
24121:M 16 Dec 12:23:06.266 * DB saved on disk
24121:M 16 Dec 12:23:06.452 * DB saved on disk
24121:M 16 Dec 12:23:19.422 * DB saved on disk
24121:M 16 Dec 12:23:29.048 * DB saved on disk
24121:M 16 Dec 12:23:38.699 * DB saved on disk
24121:M 16 Dec 12:23:48.633 * DB saved on disk
24121:M 16 Dec 12:23:58.422 * DB saved on disk
24121:M 16 Dec 12:24:08.165 * DB saved on disk
24121:M 16 Dec 12:24:18.620 * DB saved on disk
24121:M 16 Dec 12:24:28.847 * DB saved on disk
24121:M 16 Dec 12:24:38.802 * DB saved on disk
24121:M 16 Dec 12:24:48.660 * DB saved on disk
24121:M 16 Dec 12:24:58.978 * DB saved on disk
24121:M 16 Dec 12:25:11.011 * DB saved on disk
24121:M 16 Dec 12:25:21.948 * DB saved on disk
24121:M 16 Dec 12:25:32.383 * DB saved on disk
24121:M 16 Dec 12:25:43.789 * DB saved on disk
24121:M 16 Dec 12:25:58.678 * DB saved on disk
24121:M 16 Dec 12:26:10.804 * DB saved on disk
24121:M 16 Dec 12:26:21.522 * DB saved on disk
24121:M 16 Dec 12:26:32.147 * DB saved on disk
24121:M 16 Dec 12:26:42.517 * DB saved on disk
24121:M 16 Dec 12:26:52.922 * DB saved on disk
24121:M 16 Dec 12:31:53.081 * 10 changes in 300 seconds. Saving...
24121:M 16 Dec 12:31:53.092 * Background saving started by pid 8671
8671:C 16 Dec 12:31:54.833 * DB saved on disk
8671:C 16 Dec 12:31:54.839 * RDB: 12 MB of memory used by copy-on-write
24121:M 16 Dec 12:31:54.898 * Background saving terminated with success

1 个答案:

答案 0 :(得分:0)

我想这FAQ为您的问题提供了答案:

  

Redis并没有随机丢失密钥。如果钥匙消失了,   那可能是由于以下原因之一:

     

到期:键上指定的TTL被点击,因此系统被删除   钥匙。有关Redis过期的更多详细信息,请参阅   Expires命令的文档。可以设置TTL值   SET,PSETEX或EXPIRE等操作。

     

INFO命令可用于获取有关键的数量的统计信息   使用STATS部分下的expired_keys条目过期。您可以   还可以看到具有TTL值的键数以及平均值   TSP值,在KEYSPACE部分。

# Stats
expired_keys:46583

# Keyspace 
db0:keys=3450,expires=2,avg_ttl=91861015336    
See related article with debugging tips
     

驱逐:   在内存压力下,系统将逐出钥匙以释放内存。当INFO中的used_memory或used_memory_rss值时   命令接近配置的maxmemory设置,系统将   根据配置的内存策略开始从内存中驱逐密钥   如此处所述。您可以监控使用的被驱逐的密钥数量   前面提到的相同INFO命令

# Stats
evicted_keys:13224