redis配置文件详解

Units

# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.

开头定义了一些基本的度量单位,只支持 bytes,不支持 bit。这些单位对大小写是不敏感的。

INCLUDES

################################## INCLUDES ###################################
# Include one or more other config files here.  This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
#
# Note that option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
#
# include /path/to/local.conf
# include /path/to/other.conf

和 Spring 配置文件类似,可以通过 include 包含,redis.conf 可以作为总文件,可以包含其他文件。

网络配置

# 绑定的 IP
bind 127.0.0.1 
# 保护模式
protected-mode yes 
# 默认端口
port 6379

GENERAL

# 默认情况下,Redis 不作为守护进程运行。需要开启的话,改为 yes
daemonize yes 
# 可通过 upstart 和 systemd 管理 Redis 守护进程
supervised no 
# 以后台进程方式运行 redis,则需要指定 pid 文件
pidfile /var/run/redis_6379.pid 
# 日志级别。可选项有:
# debug(记录大量日志信息,适用于开发、测试阶段);
# verbose(较多日志信息);
# notice(适量日志信息,使用于生产环境);
# warning(仅有部分重要、关键信息才会被记录)。
loglevel notice 
# 日志文件的位置,当指定为空字符串时,为标准输出
logfile "" 
# 设置数据库的数目。默认的数据库是 0
databases 16 
# 是否总是显示 logo
always-show-logo yes

快照
SNAPSHOPTING

# 900秒(15分钟)内至少 1 个 key 值改变(则进行数据库保存--持久化)
save 900 1
# 300秒(5分钟)内至少 10 个 key 值改变(则进行数据库保存--持久化)
save 300 10
# 60秒(1分钟)内至少 10000 个 key 值改变(则进行数据库保存--持久化)
save 60 10000
# 持久化出现错误后,是否依然进行继续进行工作
stop-writes-on-bgsave-error yes 
# 使用压缩 rdb 文件 yes:压缩,但是需要一些 cpu 的消耗;no:不压缩,需要更多的磁盘空间
rdbcompression yes 
# 是否校验 rdb 文件,更有利于文件的容错性,但是在保存 rdb 文件的时候,会有大概 10% 的性能损耗
rdbchecksum yes 
# dbfilenamerdb 文件名称
dbfilename dump.rdb 
# dir 数据目录,数据库的写入会在这个目录。rdb、aof 文件也会写在这个目录
dir ./
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值