redis4的自動內存整理


redis4裏面自帶了內存整理,可以避免內存碎片率過大的問題。


使用命令: 

config set activedefrag yes


執行完上面的命令後,稍等片刻再查看碎片率:

redis-cli -p 6379 info | grep ratio



我們在線上遇到的問題:

127.0.0.1:7001> config set activedefrag yes

(error) ERR Active defragmentation cannot be enabled: it requires a Redis server compiled with a modified Jemalloc like the one shipped by default with the Redis source distribution

看這個報錯提示,貌似是jemalloc的版本與redis需要的不一致


查看下報錯機器的jemalloc的版本:

redis-cli -c -p 7000 | grep jemalloc 

mem_allocator:jemalloc-3.6.0

我們的機器的redis-server的版本是4.0.10的,和jemalloc的版本差異較大。



後續: 

    我們換一臺全新編譯的redis-server機器, 再次執行 config set activedefrag yes  發現不再報錯了。 






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章