Redis配置文件说明

Redis配置文件说明


  1. 单位

单位的大小写不影响

# 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.
  1. 包含

可以包含一些其他的配置文件,与当前配置文件一起生效

################################## 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.
#
# Notice 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
  1. 网络
bind 127.0.0.1 # 默认绑定本机,仅允许本机访问,若开放则可以设置为 0.0.0.0
protected-mode no # 是否受保护 默认yes
port 6379 # 端口号
  1. 通配
daemonize yes # 默认no 守护进程,可以后台运行
pidfile /var/run/redis_6379.pid # 开启守护进程后,给予的pid

# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel notice # 日志级别

# output for logging but daemonize, logs will be sent to /dev/null
logfile "" # 日志输出文件,默认控制台

databases 16 # 默认16个数据库

always-show-logo yes # 是否显示redis的logo
  1. 快照
save 900 1 # 900s中,有1次修改 持久化
save 300 10 # 300s中,有10次修改 持久化
save 60 10000 # 60s中,有10000次修改 持久化

stop-writes-on-bgsave-error yes # 持久化失败后是否需要继续工作

rdbcompression yes # 是否将rdb文件进行压缩

rdbchecksum yes # rdb文件持久化之前是否进行错误检查

dbfilename dump.rdb # rdb名字

dir ./ # rdb文件保存的目录
  1. 主从复制

  2. 安全

127.0.0.1:6379> config get requirepass # 获取当前密码,为空表示未设置密码
1) "requirepass"
2) ""
127.0.0.1:6379> config set requirepass "123456" # 设置密码
OK
127.0.0.1:6379> set name yorick # 设置密码后,未登录状态无法操作redis
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456 # 登录
OK
127.0.0.1:6379> ping # 可以正常操作redis
PONG
  1. 客户端
maxclients 10000 # 最大客户连接数
  1. 内存
maxmemory <bytes> # 最大内存容量

maxmemory-policy noeviction # 6种当达到内存容量限制后执行的策略
  1. aof配置
appendonly no # 是否开启aof

appendfilename "appendonly.aof" # aof名字

# appendfsync always
appendfsync everysec # 同步时机
# appendfsync no

参考地址:https://www.bilibili.com/video/BV1S54y1R7SB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

攻城老湿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值