Redis 似乎丢失了我的一些数据,但服务器进程没有死掉。第一个持续存在的新数据似乎是在 12:26。来自 Redis 的日志如下。 redis-cli 信息统计显示进程正常运行时间为 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
最佳答案
我猜这个FAQ为您的问题提供答案:
Redis doesn't really lose keys randomly. If the keys have disappeared, then it is likely because of one of the following reasons:
Expiration: The TTL specified on a key was hit, so the system removed the key. More details around Redis expiration can be found in the documentation for the Expires command. TTL values can be set through operations like SET, PSETEX or EXPIRE.
The INFO command can be used to get stats about how many keys have expired using the expired_keys entry under the STATS section. You can also see the number of keys with a TTL value, as well as the average TTL value, in the KEYSPACE section.
# Stats expired_keys:46583 # Keyspace db0:keys=3450,expires=2,avg_ttl=91861015336 See related article with debugging tips
Eviction: Under memory pressure, the system will evict keys to free up memory. When the used_memory or used_memory_rss values in the INFO command approach the configured
maxmemory
setting, the system will start evicting keys from memory based on your configured memory policy as described here. You can monitor the number of keys evicted using the same INFO command mentioned previously# Stats evicted_keys:13224
关于redis - 使用 Redis 无需停机即可丢失数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47846443/