Redis动态配制,限内存,免重启

一、修改redis.conf。保证下次服务器或者Redis重启仍然生效

  # maxmemory <bytes>

  # 3.03GB

  # redis-cli>info

  #           >used_memory:3254690792

  maxmemory 3254857828

  maxmemory-policy allkeys-lru

 

  #过期key删除选项。建议开启

  lazyfree-lazy-expire yes

 

  # 设为9,消耗更多CPU及时回收内存

maxmemory-samples 9

 

# 减少slave节点flush操作时间

slave-lazy-flush yes

 

# 碎片整理总开关

activedefrag yes

 

  关闭服务:$> redis-cli shutdown

  启动:$> ./redis-server redis.conf

 
二、动态配制生效,免重启

  # redis-cli>CONFIG SET maxmemory 3254857828

       >CONFIG SET maxmemory-policy allkeys-lru

       >CONFIG SET maxmemory-samples 9

       >config set lazyfree-lazy-expire yes

       >config set activedefrag yes

posted @ 2020-01-11 10:20  风别鹤  阅读(297)  评论(0编辑  收藏  举报