Redis configuration file reids.conf explained in detail

reids.conf explained in detail

unit

Insert picture description here
1. The configuration file unit is not case sensitive.

contain

Insert picture description here
Just like Spring, Improt, include

The internet

bind 127.0.0.1    //绑定的ip
protected-mode yes    //保护模式
port 6379     //端口设置

General GENERAL

daemonize 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 notice
logfile ""  //日志的文件位置名
databases 16    //数据库的数量,默认16个数据库
always-show-logo yes    //是否总是显示LOGO

Snapshot

Persistence, how many operations are performed within the specified time, will be persisted to the file. Rdb.aof
redis is an in-memory database, if there is no persistence, then the data will disappear after power failure.

#如果900s内,如果至少有一个1key进行了修改,就会进行持久化操作
save 900 1
#如果300s内,如果至少有10个key进行了修改,就会进行持久化操作
save 300 10 
#如果60s内,如果至少有10000key进行了修改,就会进行持久化操作
save 60 10000

stop-writes-on-bgsave-error yes   //持久化出错了,是否还继续工作

rdbcompression yes   //是否压缩rdb文件,需要消耗一些cpu资源!

rdbchecksum yes   //保存rdb文件的时候,进行错误的检查校验

dir ./    //rdb 文件保存的目录!

REPLICATION master-slave replication

SECURITY

You can set the redis password here, there is no password by default!

config set requirepass "123456"     //设置密码

[root@iZbp1ilygspotccpj3hnyaZ ~]# redis-cli -p 6379
127.0.0.1:6379> ping              //需要输入密码后才能连接
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456    //使用密码登录
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "123456"

CLIENTS restrictions

maxclients 10000    //设置能连接上reidsd的最大客户端的数量
maxmemory <bytes>    //redis配置最大的内存容量
maxmemory-policy noeviction    //内存到达上限之后的处理策略
			
1、volatile-lru:只对设置了过期时间的key进行LRU(默认值) 
2、allkeys-lru : 删除lru算法的key   
3、volatile-random:随机删除即将过期key   
4、allkeys-random:随机删除   
5、volatile-ttl : 删除即将过期的   
6、noeviction : 永不过期,返回错误

APPEND ONLY mode aof configuration

appendonly no  //默认是不开启aof模式的,默认使用rdb方式持久化的,在大部分所有的情况下,rdb完全够用!
appendfilename "appendonly.aof"     //持久化的文件的名字

# appendfsync always    //每次修改都会sync。消耗性能
appendfsync everysec    //每秒执行一次,可能会丢失这1s的数据!
# appendfsync no           //不执行sync,这个时候操作系统自己同步数据,速度最快!

Guess you like

Origin blog.csdn.net/yang13676084606/article/details/109863043