Redis的配置文件

Redis的配置文件

1:持久化

  • 在规定的时间内,执行了多少次的操作,会持久化到文件rdb,aof

  • redis 是内存数据库

  • 如果在900 s 内,有一个key 进行了修改,我们会进行持久化的操作

  • 如果在300 s 内,有十个key进行了修改,我们也会进行持久化的操作

  • 如果是 60 s 内,有10000key进行了修改,我们也会进行持久化的操作

save 900 1
save 300 10
save 60 10000

2:数据库

# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
# 持久化如果出错,在硬盘上,是否还要继续工作
stop-writes-on-bgsave-error yes

# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
# 是否压缩rdb文件,需要消耗一些CPU的资源
rdbcompression yes

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
# 保存RDB文件的收,进行错误的检查校验
rdbchecksum yes

# The filename where to dump the DB
# 数据库的名字
dbfilename dump.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# 工作路径
dir ./

3:安全

  • 默认是没有密码的,需要自己去修改密码

在这里插入图片描述

4:内存满处理

**1、volatile-lru:**只对设置了过期时间的key进行LRU(默认值)

2、allkeys-lru : 删除lru算法的key

**3、volatile-random:**随机删除即将过期key

**4、allkeys-random:**随机删除

5、volatile-ttl : 删除即将过期的

6、noeviction : 永不过期,返回错误

# maxmemory-policy noeviction

# LRU 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 a bit more CPU. 3 is very fast but not very accurate.

AOF

  • 默认是 不开启的
  • 每秒执行一次
appendonly no

# The name of the append only file (default: "appendonly.aof")
appendfilename "appendonly.aof"
# appendfsync always
appendfsync everysec

5:RDB规则

  • save
  • flushall
  • 退出

优点

  • 适合于大规模的数据恢复
  • 对数据的完整性要求不要

缺点

  • 需要进行一定的时间间隔进程操作,如果redis意外宕机了,那么最后一次修改数据就没有了

  • fork进程的时候,会占用一定的内存空间

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值