目录
启动的时候,就通过配置文件来启动
存储单位
配置文件大小写不敏感
引用配置
网络
bind 127.0.0.1 #绑定的ip
protected-mode yes #保护模式
port 6379 #端口设置
通用
daemonize yes #以守护进程的方式运行,默认是no,我们需要自己开启为yes!
pidfile /var/run/redis_6379.pid # 如果以后台的方式运行,我们就需要指定一个pid文件!#日志
# Specify the server verbosity 1eve1.
# This can be one of:
# debug (a 1ot of information, usefu1 for development/testing)
# verbose (many rarely usefu1 info, but not a mess 1ike the debug 1eve1)
# notice (moderately verbose, what you want in production probab1y) 生产环境
# warning (only very important / critical messages are 1ogged)
loglevel notice
logfile "" #日志的文件位置名
databases 16 #数据库的数量,默认是16个数据库
always-show-logo yes # 是否总是显示LOGO
快照
持久化,在规定的时间内,执行了多少次操作,则会持久化到文件 .rdb .aof
安全——SECURITY
可以在这里设置redis的密码,默认是没有密码
限制——CLIENTS
maxclients 10000 #设置能连接上redis的最大客户端的数量
maxmemory <bytes> # redis配置最大的内存容量
maxmemory-policy noeviction #内存到达上限之后的处理策略
maxmemory-policy六种方式
- 1、volatile-1ru: 只对设置了过期时间的key进行LRU (默认值)
- 2、allkeys-1ru :删除1ru 算法的key
- 3、volatile-random: 随机删除即将过期key
- 4、allkeys-random: 随机删除
- 5、volatile-tt1 :删除即将 过期的
- 6、noeviction :永不过期,返回错误
AOF设置—— APPEND ONLY MODE
appendonly no
#默认是不开启aof模式的,默认是使用rdb方式持久化的,在大部分所有的情况下,rdb完全够用
appendfilename "appendonly.aof' # 持久化的文件的名字
# appendfsync always #每次修改都会sync。消耗性能
appendfsync everysec #每秒执行一次sync,可能会丢失这1s的数据!
# appendfsync no #不执行sync,这个时候操作系统自己同步数据,速度最快!