Redis 配置文件
当配置中需要配置内存大小时,可以使用 1k, 5GB, 4M 等类似的格式,其转换方式如下(不区分大小写)
1k => 1000 bytes
1kb => 1024 bytes
1m => 1000000 bytes
1mb => 1024*1024 bytes
1g => 1000000000 bytes
1gb => 102410241024 bytes
内存配置大小写是一样的.比如 1gb 1Gb 1GB 1gB
daemonize no 默认情况下,redis不是在后台运行的,如果需要在后台运行,把该项的值更改为yes
daemonize yes
当redis在后台运行的时候,Redis默认会把pid文件放在/var/run/redis.pid,你可以配置到其他地址。
当运行多个redis服务时,需要指定不同的pid文件和端口
pidfile /var/run/redis.pid
指定redis运行的端口,默认是6379
port 6379
指定redis只接收来自于该IP地址的请求,如果不进行设置,那么将处理所有请求,
在生产环境中最好设置该项
bind 127.0.0.1
Specify the path for the unix socket that will be used to listen for
incoming connections. There is no default, so Redis will not listen
on a unix socket when not specified.
unixsocket /tmp/redis.sock
unixsocketperm 755
设置客户端连接时的超时时间,单位为秒。当客户端在这段时间内没有发出任何指令,那么关闭该连接
0是关闭此设置
timeout 0
指定日志记录级别
Redis总共支持四个级别:debug、verbose、notice、warning,默认为verbose
debug 记录很多信息,用于开发和测试
varbose 有用的信息,不像debug会记录那么多
notice 普通的verbose,常用于生产环境
warning 只有非常重要或者严重的信息会记录到日志
loglevel debug
配置log文件地址
默认值为stdout,标准输出,若后台模式会输出到/dev/null
#logfile stdout
logfile /var/log/redis/redis.log
To enable logging to the system logger, just set ‘syslog-enabled’ to yes,
and optionally update the other syslog parameters to suit your needs.
syslog-enabled no
Specify the syslog identity.
syslog-ident redis
Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
syslog-facility local0
可用数据库数
默认值为16,默认数据库为0,数据库范围在0-(database-1)之间
databases 16
################################ 快照 #################################
保存数据到磁盘,格式如下:
save
指出在多长时间内,有多少次更新操作,就将数据同步到数据文件rdb。
相当于条件触发抓取快照,这个可以多个条件配合
比如默认配置文件中的设置,就设置了三个条件
save 900 1 900秒内至少有1个key被改变
save 300 10 300秒内至少有300个key被改变
save 60 10000 60秒内至少有10000个key被改变
save 900 1
save 300 10
save 60 10000
存储至本地数据库时(持久化到rdb文件)是否压缩数据,默认为yes
rdbcompression yes
本地持久化数据库文件名,默认值为dump.rdb
dbfilename dump.rdb