如何从Redis中删除过期的密钥?
我正在具有8GB RAM的ubuntu机器上使用redis-cluster版本5。
Redis不会从群集中删除过期的密钥,群集正在达到最大内存并关闭,但不会删除过期的集合。运行Redis-cli命令并获取信息会提供以下信息,我认为这些信息已过期但尚未收回。
expired_keys:49665 evicted_keys:0
maxmemory策略设置为 maxmemory_policy:allkeys-lru 和 maxmemory设置为4GB 。
# Server
redis_version:5.0.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:f634bb8c4e23022d
redis_mode:cluster
os:Linux 4.4.0-134-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:5.4.0
process_id:9757
run_id:5e16e3b675e4a72e344a7dcbaf6a5a44f8db78fb
tcp_port:7000
uptime_in_seconds:12097
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:12095198
executable:/opt/redis-cluster/./src/redis-server
config_file:/opt/redis-cluster/7000/redis.conf
# Clients
connected_clients:75
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0
# Memory
used_memory:1793028184
used_memory_human:1.67G
used_memory_rss:1610657792
used_memory_rss_human:1.50G
used_memory_peak:3023105224
used_memory_peak_human:2.82G
used_memory_peak_perc:59.31%
used_memory_overhead:3445582
used_memory_startup:1463784
used_memory_dataset:1789582602
used_memory_dataset_perc:99.89%
allocator_allocated:1793088456
allocator_active:1814888448
allocator_resident:1828147200
total_system_memory:8371073024
total_system_memory_human:7.80G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:4294967296
maxmemory_human:4.00G
maxmemory_policy:allkeys-lru
allocator_frag_ratio:1.01
allocator_frag_bytes:21799992
allocator_rss_ratio:1.01
allocator_rss_bytes:13258752
rss_overhead_ratio:0.88
rss_overhead_bytes:-217489408
mem_fragmentation_ratio:0.90
mem_fragmentation_bytes:-182328144
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:1334694
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
# Persistence
loading:0
rdb_changes_since_last_save:3
rdb_bgsave_in_progress:0
rdb_last_save_time:1555599025
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:6
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:6467584
aof_enabled:1
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
aof_last_cow_size:0
aof_current_size:915758559
aof_base_size:859225894
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0
# Stats
total_connections_received:1205
total_commands_processed:44642
instantaneous_ops_per_sec:15
total_net_input_bytes:52355298
total_net_output_bytes:82818587
instantaneous_input_kbps:11.79
instantaneous_output_kbps:29.01
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:49890
expired_stale_perc:0.00
expired_time_cap_reached_count:102
evicted_keys:0
keyspace_hits:8617
keyspace_misses:9422
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:45068
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
# Replication
role:master
connected_slaves:0
master_replid:
master_replid2:
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:17.920000
used_cpu_user:20.200000
used_cpu_sys_children:17.972000
used_cpu_user_children:221.420000
# Cluster
cluster_enabled:1
# Keyspace
db0:keys=8063,expires=8063,avg_ttl=6141649942