前言

原有的内存淘汰机制没有设置导致redis持久化的时候,内存直接爆掉

步骤

修改配置 | 重启服务

修改redis.conf的配置文件,并重启redis服务

############################## MEMORY MANAGEMENT ################################

# Set a memory usage limit to the specified amount of bytes.

# When the memory limit is reached Redis will try to remove keys

# according to the eviction policy selected (see maxmemory-policy).

#

# If Redis can't remove keys according to the policy, or if the policy is

# set to 'noeviction', Redis will start to reply with errors to commands

# that would use more memory, like SET, LPUSH, and so on, and will continue

# to reply to read-only commands like GET.

#

# This option is usually useful when using Redis as an LRU or LFU cache, or to

# set a hard memory limit for an instance (using the 'noeviction' policy).

#

# WARNING: If you have replicas attached to an instance with maxmemory on,

# the size of the output buffers needed to feed the replicas are subtracted

# from the used memory count, so that network problems / resyncs will

# not trigger a loop where keys are evicted, and in turn the output

# buffer of replicas is full with DELs of keys evicted triggering the deletion

# of more keys, and so forth until the database is completely emptied.

#

# In short... if you have replicas attached it is suggested that you set a lower

# limit for maxmemory so that there is some free RAM on the system for replica

# output buffers (but this is not needed if the policy is 'noeviction').

#

maxmemory 32212254720

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory

# is reached. You can select among five behaviors:

#内存不足的情况下,有以下几种移除key的方式供你选择

# volatile-lru -> Evict using approximated LRU among the keys with an expire set.

# allkeys-lru -> Evict any key using approximated LRU.

# volatile-lfu -> Evict using approximated LFU among the keys with an expire set.

# allkeys-lfu -> Evict any key using approximated LFU.

# volatile-random -> Remove a random key among the ones with an expire set.

# allkeys-random -> Remove a random key, any key.

# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)

# noeviction -> Don't evict anything, just return an error on write operations.

#

# LRU means Least Recently Used

# LFU means Least Frequently Used

#

# Both LRU, LFU and volatile-ttl are implemented using approximated

# randomized algorithms.

#

# Note: with any of the above policies, Redis will return an error on write

# operations, when there are no suitable keys for eviction.

#

# At the date of writing these commands are: set setnx setex append

# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd

# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby

# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby

# getset mset msetnx exec sort

#

# The default is:

#volatile-ttl 移除设置过过期时间且最近要过期的key

maxmemory-policy volatile-ttl

# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated

# algorithms (in order to save memory), so you can tune it for speed or

# accuracy. For default Redis will check five keys and pick the one that was

# used less recently, you can change the sample size using the following

# configuration directive.

#

# The default of 5 produces good enough results. 10 Approximates very closely

# true LRU but costs more CPU. 3 is faster but not very accurate.

#

# maxmemory-samples 5

# Starting from Redis 5, by default a replica will ignore its maxmemory setting

# (unless it is promoted to master after a failover or manually). It means

# that the eviction of keys will be just handled by the master, sending the

# DEL commands to the replica as keys evict in the master side.

#

# This behavior ensures that masters and replicas stay consistent, and is usually

# what you want, however if your replica is writable, or you want the replica to have

# a different memory setting, and you are sure all the writes performed to the

# replica are idempotent, then you may change this default (but be sure to understand

# what you are doing).

#

# Note that since the replica by default does not evict, it may end using more

# memory than the one set via maxmemory (there are certain buffers that may

# be larger on the replica, or data structures may sometimes take more memory and so

# forth). So make sure you monitor your replicas and make sure they have enough

# memory to never hit a real out-of-memory condition before the master hits

# the configured maxmemory setting.

#

# replica-ignore-maxmemory yes

动态修改 | 无需重启

scrm:0>config set maxmemory 32212254720

"OK"

scrm:0>config get maxmemory

1) "maxmemory"

2) "32212254720"

scrm:0>config set maxmemory-policy volatile-ttl

"OK"

scrm:0>config gscrm-taibao:0>et maxmemory-policy

1) "maxmemory-policy"

2) "volatile-ttl"

incrby redis 最大值_Redis——设置最大内存 | key淘汰机制相关推荐

  1. incrby redis 最大值_Redis 的 8 大数据类型,写得非常好!

    NoSQL 开发中或多或少都会用到,也是面试必问知识点.最近这几天的面试每一场都问到了.但是感觉回答的并不好,还有很多需要梳理的知识点. Redis-key 127.0.0.1:6379> ke ...

  2. incrby redis 最大值_redis incr incrby decr decrby命令

    incr.incrby.decr.decrby命令的作用和用法 redis中incr.incrby.decr.decrby属于string数据结构,它们是原子性递增或递减操作. incr递增1并返回递 ...

  3. 笔记【Redis数据结构、常用命令、key淘汰及持久化策略】

    文章目录 简要介绍 服务安装 数据结构 通用命令 字符串类型命令 散列类型命令 列表类型命令 集合类型命令 有序集合类型命令 HyperLogLog命令 GeoHash命令(地图坐标) 排序命令 事务 ...

  4. redis 用户订单缓存_Redis实战(12)-基于Key失效和定时任务实现订单支付超时自动失效...

    "商城平台用户下单"这一业务场景相信很多小伙伴并不陌生,在正常的情况下,用户在提交完订单/下完单之后,应该是前往"收银台"选择支付方式进行支付,之后只需要提供相 ...

  5. Redis内存淘汰机制

    Redis内存淘汰机制 网趣科技 2016-09-06 13:26 摘要 Redis是一款优秀的.开源的内存数据库,我在阅读Redis源码实现的过程中,时时刻刻能感受到Redis作者为更好地使用内存而 ...

  6. c# redis hashid如何设置过期时间_Redis中Key过期策略amp;淘汰机制

    1. Redis中设置Key过期时间 我们有两种方式设置过期时间 1.1 设置多久后过期 设置一个 key 10s 过期,可以这样 127.0.0.1:6379> SET key value E ...

  7. redis value最大值_Redis基础知识整理

    Redis安装和使用 使用Docker安装Redis docker run --name redis -p 6379:6379 --restart always -d redis 使用redis-cl ...

  8. redis value最大值_Redis value的5种类型及常见操作

    Redis本身存储就是一个hash表,实际实࣫比hash表更复一些,后续讲存储结构时会细讲 Key只有String类型 Value包括String ,Set,List,Hash,Zset五中类型 ST ...

  9. redis value最大值_Redis 的 maxmemory 和 dbnum 默认值都是多少?对于最大值会有限制吗?...

    一.Redis 的默认配置 了解 Redis 的都知道,Redis 服务器状态有很多可配置的默认值. 例如:数据库数量,最大可用内存,AOF 持久化相关配置和 RDB 持久化相关配置等等.我相信,关于 ...

最新文章

  1. 240个jquery插件
  2. 安卓samba软件_Android Samba Client
  3. .NET Core开发实战(第5课:依赖注入:良好架构的起点)--学习笔记(下)
  4. 这篇文章绝对让你深刻理解java类的加载以及ClassLoader源码分析
  5. 如何让DevExpress.TreeList单元格中的自定义控件包含标签
  6. DisplayTag1.2
  7. AI,机器学习(模式识别),深度学习的区别与联系
  8. 动态网络社区检测概述
  9. 编程不是一种知识,而是一门手艺。
  10. 应对个人信息保护法律合规,妥善管理个人隐私数据
  11. python阈值计算_基于Python的阈值分割算法实现(二)
  12. throw er; // Unhandled ‘error’ event
  13. 重拾Java基础知识:IO流
  14. Flyme 6将于30日公测 魅蓝Note5有望率先尝鲜
  15. 2016年全国高中数学联合竞赛试题及详细解答
  16. Java 八种排序算法比较实践
  17. cobbler一键装机流程
  18. zk 有一个节点报 It is probably not running且日志无明显报错
  19. MATLAB中不用循环生成圆盘(圆形)/圆环掩膜矩阵
  20. Unity3d C#通过使用大华SDK控制大华摄像头旋转、变焦等云台操作和预置点等控制操作(含源码)

热门文章

  1. java定义一个盒子类box_定义一个Box(盒子)类,在该类定义中包括数据成员: length(长),width(宽)和height(...
  2. 返回列表结果数据再请求详情
  3. 获取全球各大证券交易所的全部股票交易信息
  4. 自媒体的现状是非常火爆,自媒体的未来是怎样呢?
  5. 寻找SQL执行线索的武器库
  6. 我的100个工作基本
  7. gta5怎么设置画质最好_《GTA5》怎么设置才能流畅运行_Intel Xeon E3-1231 v3_CPUCPU评测-中关村在线...
  8. 日常小结-RSA加密算法、数字签名和数字证书及其java实现
  9. [译文]Qt自定义主题或使用外部主题(Qt Creator Themes)
  10. java swarm有什么用,Docker Swarm的使用总结