单位

单位大小写不敏感

# 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.

INCLUDES 引入配置文件

可以引入多个配置文件组成一个Redis配置文件

# include /path/to/local.conf
# include /path/to/other.conf

MODULES 模块加载

# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so

NETWORK 网络

#可以访问的IP,若要远程访问,需要配置*或者访问者IP

# bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 addresses
# bind 127.0.0.1 ::1              # listens on loopback IPv4 and IPv6
# bind * -::*                     # like the default, all available interfaces
bind 127.0.0.1 -::1
#是否开启保护模式
protected-mode yes
#访问端口
port 6379

GENERAL 通用配置

#是否以守护进程启动
daemonize yes
#如果以守护进程启动,需要配置一个守护进程Pid文件
pidfile /var/run/redis_6379.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)
#默认notice,生产环境使用
loglevel notice
#日志输出位置
logfile ""
#数据库数量
databases 16
#是否展示logo
always-show-logo no

set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"

SNAPSHOTTING 快照 RDB配置

#每3600s修改1个数据,则更新快照
save 3600 1
#每300s修改100个数据,则更新快照
save 300 100
#每60s修改10000个数据,则更新快照
save 60 10000
#持久化发生错误是否继续持久化
stop-writes-on-bgsave-error yes
#是否对rdb文件进行压缩,会消耗一定CPU资源
rdbcompression yes
#保存文件的时候是否进行检查校验
rdbchecksum yes
#持久化文件名
dbfilename dump.rdb
#文件存放路径
dir ./

REPLICATION 主从配置

SECURITY 安全

设置密码
# requirepass foobared

CLIENTS 客户端限制

# 最大客户端连接数量
# maxclients 10000

APPEND ONLY MODE AppendOnly模式 AOF配置

#默认是不开启AOF模式的,默认使用的是RDB,在大部分情况下,RDB足够
appendonly no
#持久化的文件名
appendfilename "appendonly.aof"
#每次修改都会同步
# appendfsync always
#每秒执行一次同步,可能丢失1s的数据
appendfsync everysec
# 不进行同步
# appendfsync no