Redis配置文件
1.units are case insensitive so 1GB 1Gb 1gB are all the same. 大小写不敏感
2.包含include多个配置文件
3.网络
bind 127.0.0.1 #绑定的ip
protected yes #保护模式
pory 6379 #端口设置
4.通用general
dameonize yes #以守护进程的方式运行,默认是no,以后台方式启动需要打开设置为yes
pidfile /var/run/redis_6379.pid #如果以后台方式运行,需要指定一个pid文件!
日志级别
# 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 noticelogfile "" #生成文件名
databases 16 # 数据库数量
always-show-logo yes #是否显示log图
5.快照
持久化:在规定的时间内,执行了多少次操作,则会持久化文件 rdb aof
redis是内存数据库,如果没有持久化,那么数据断电就会丢失
save 900 1 900s内 至少有一个key被修改一次 就会持久化
save 300 10 300s内 至少有10个key被修改一次 就会持久化
save 60 10000 60s内 至少有10000key被修改一次 就会持久#我们也可以自己设置
stop-writes-on-bgsave-error yes #如果持久化失败了,redis是否继续运行
rdbcompression yes #是否需要压缩rdb文件,需要消耗一些cpu资源
rdbchecksum yes #保存rdb文件的时候,进行错误的校验检查
dir ./ #rdb文件保存的目录
6.主从复制
7.安全
SECURITY 安全
设置redis密码 123456:
config set requirepass 123456
获取redis密码:
config get requirepass
登录:
auth 123456
8.限制clients
maxclients 10000 #设置能连接redis的最大客户端数量
maxmemory <bytes> #配置最大的内存容量
maxmemory-policy noeviction #内存达到上限之后的处理策略
9.APPEND ONLY MODE(默认是不开窍aof的,默认是rdb持久化方式)
appendonly no :默认是不开启的
appendfilename "appendonly.aof" :持久化文件的名字
# appendfsync always #每次修改都会同步
appendfsync everysec #每秒钟执行一次
# appendfsync no #不同步