Redis.conf

单位

1
2
3
4
5
6
7
8
9
10
11
# Note on units: when memory size is needed, it is possible to specifiy
# 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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

类似于我们的mybatis和其他的类似于jsp的include标签,目的就是把他们连在一起;

网络配置

1
2
3
bind 127.0.0.1 
protected-mode yes
port 6379

通用配置

1
2
daemonize no #是否是守护进程
pidfile /var/run/redis_6379.pid #如果是后台进程,那么就需要有这个配置文件

日志配置

1
2
3
4
5
6
7
8
9
10
11
# Specify the server verbosity level.

# This can be one of:

# 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 日志的类型

1
2
3
4
5
6
7
8
9
# Specify the log file name. Also the empty string can be used to force

# Redis to log on the standard output. Note that if you use standard

# output for logging but daemonize, logs will be sent to /dev/null

logfile "" 日志生成的文件位置,如果是空,就默认输出
database 16 默认的数据库数量
always-show-logo yes 是否显示logo

SNAPSHOTTING 快照

1
2
3
4
5
6
7
8
9
对数据进行持久化的一种策略防止数据丢失
save 900 1 #如果再900s内至少有一个key被修改,那么就保存到持久化
save 300 10 #如果再300s内,至少有10个key被修改,他就会进行持久化操作
save 60 10000 #如果再60s内,有10000个key被修改,那么就是进行持久化操作

stop-writes-on-bgsave-error yes #持久化操作失败以后,是否再继续工作
rdbcompression yes #是否压缩我们的rdb文件
rdbchecksum yes #出错时,对rdb进行校验和修复
dir ./ #rdb文件保存的一个目录

安全

1
2
3
4
# requirepass foobared 密码,设置访问数据库的密码一般使用命令行进行配置

requirepass set password 设置密码
auth password 认证

客户端

1
2
3
4
5
# maxclients 10000 最大的客户端连接数

# maxmemory <bytes> 配置最大的内存容量

# maxmemory-policy noeviction 内存满了的处理策略

APPEND ONLY MODE aof

1
2
3
4
5
6
7
8
appendonly no 默认不开启aof 在大部分不使用,使用rdb就够用了
appendfilename "appendonly.aof" 持久化文件的名字

# appendfsync always 每一次修改都会同步,速度比较慢

appendfsync everysec 每一秒执行一次同步操作,可能会丢失一秒的数据

# appendfsync no 不同步 不执行同步操作