我刚开始使用Redis。
在我的应用程序不使用10到12个小时之后,我看到了redis缓存中丢失的键。
这是一个非机密的暂存环境,因此没有在redis上获得任何安全性。
在两天内发生了两次。
注意: redis是独立运行的。
我尝试过从通配符应用服务器连接,当应用服务器在夜间停机时,会在早上观察到这个问题。
在redis保存到磁盘后,redis是否将键从内存中移除?
我试过得到统计数据,并检查了-1键的TTL。统计数据显示: expired_keys:0 evicted_keys:0最大内存增加到6GB,无法达到,这比作为CentOS上独立运行的Redis下面的输入大小统计值要高得多
127.0.0.1:6379> info
# Server
redis_version:3.2.12
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7897e7d0e13773f
redis_mode:standalone
os:Linux 3.10.0-957.12.2.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:20830
run_id:eea4f3ccc73fc20e16ef20441393b1189050fdb8
tcp_port:6379
uptime_in_seconds:208558
uptime_in_days:2
hz:10
lru_clock:3417026
executable:not shown
config_file:not shown
# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:814024
used_memory_human:794.95K
used_memory_rss:8163328
used_memory_rss_human:7.79M
used_memory_peak:1250632
used_memory_peak_human:1.19M
total_system_memory:8201187328
total_system_memory_human:7.64G
used_memory_lua:40960
used_memory_lua_human:40.00K
maxmemory:6442450944
maxmemory_human:6.00G
maxmemory_policy:noeviction
mem_fragmentation_ratio:10.03
mem_allocator:jemalloc-3.6.0
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1563697205
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
# Stats
total_connections_received:119
total_commands_processed:378
instantaneous_ops_per_sec:0
total_net_input_bytes:26750
total_net_output_bytes:115176
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:165
keyspace_misses:27
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:928
migrate_cached_sockets:0
# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:130.68
used_cpu_user:60.20
used_cpu_sys_children:0.26
used_cpu_user_children:0.04
# Cluster
cluster_enabled:0
Last action on Redis -valid hits from our application
14649:C 21 Jul 01:17:31.508 * RDB: 4 MB of memory used by copy-on-write
20830:M 21 Jul 01:17:31.605 * Background saving terminated with success
20830:M 21 Jul 01:32:32.018 * 1 changes in 900 seconds. Saving...
20830:M 21 Jul 01:32:32.019 * Background saving started by pid 14817
14817:C 21 Jul 01:32:32.021 * DB saved on disk
14817:C 21 Jul 01:32:32.021 * RDB: 4 MB of memory used by copy-on-write
20830:M 21 Jul 01:32:32.119 * Background saving terminated with success
20830:M 21 Jul 03:03:44.634 * 1 changes in 900 seconds. Saving...
20830:M 21 Jul 03:03:44.636 * Background saving started by pid 15843
15843:C 21 Jul 03:03:44.638 * DB saved on disk
15843:C 21 Jul 03:03:44.638 * RDB: 4 MB of memory used by copy-on-write
20830:M 21 Jul 03:03:44.736 * Background saving terminated with success
20830:M 21 Jul 03:18:45.076 * 1 changes in 900 seconds. Saving...
20830:M 21 Jul 03:18:45.079 * Background saving started by pid 16040
16040:C 21 Jul 03:18:45.080 * DB saved on disk
16040:C 21 Jul 03:18:45.081 * RDB: 4 MB of memory used by copy-on-write
20830:M 21 Jul 03:18:45.179 * Background saving terminated with success实际结果,即使在不使用redis的情况下,我也希望密钥能够出现。
发布于 2019-07-21 22:54:09
不,Redis保存到磁盘时不会从内存中删除键。
您的正常运行时间(因此在重新启动时不会丢失数据),因此它只剩下两种理论:
CLI检查您的Redis中的所有存储密钥。https://stackoverflow.com/questions/57131820
复制相似问题