因为一些意外的意外,redis内存增加了很多,我们删除了很多不用的key,但是内存没有释放,有没有办法手动释放,除了重启redis。
redis信息
# Memory used_memory:14166381000 used_memory_human:13.19G used_memory_rss:41278218240 used_memory_peak:50044293760 used_memory_peak_human:46.61G used_memory_lua:31744 mem_fragmentation_ratio:2.91 mem_allocator:jemalloc-3.2.0
纳米吨
│ Top Processes Procs=288 mode=3 (1=Basic, 3=Perf 4=Size 5=I/O)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ │ PID %CPU Size Res Res Res Res Shared Faults Command │ │ Used KB Set Text Data Lib KB Min Maj │ │ 1732 15.9 58932952 40309580 756 58921404 0 944 9 0 redis-server
free -m total used free shared buffers cached Mem: 64378 61914 2464 0 11 22 -/+ buffers/cache: 61879 2498 Swap: 32255 16710 15545
最佳答案
根据 antirez https://groups.google.com/forum/#!topic/redis-db/ibhYDLT_n68 (第一个答案)Redis 总是使用used_memory_peak 作为它可能需要多少内存(以及它想要分配多少内存)的引用。
如果您确实需要以零停机时间释放该内存 - 您可以设置一个从站,使其可读写CONFIG SET Slave-read-only no
将您的应用程序流量重新路由到从站并重新启动大师。或者继续使用从属设备(通过使其成为主设备SLAVEOF NO ONE
)
关于redis 2.8如何释放 "human peak"内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24276064/