redis配置
1.
# units are case insensitive so 1GB 1Gb 1gB are all the same.
大小写不敏感
2.
# include .\path\to\local.conf
# include c:\path\to\other.conf
包含其他的设置文件
3.
bind 127.0.0.1 #绑定的ip protected-mode yes #保护模式 port 6379 //端口设置
4.通用GENERAL
#By default Redis does not run as a daemon. Use 'yes' if you need it. daemonize yes #默认是no 需要开启为yes
pidfile /var/run/redis.pid #如果以后台方式运行,就需要指定一个pid文件
#日志 # Specify the server verbosity level. # This can be one of: #下面4个选项 (默认不用改) # 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 "server_log.txt" #文件名
databases 16 #默认数据库数量
5.快照SNAPSHOTTING
持久化,在规定的时间内,执行了多少次操作,则会持久化(持久化规则)
redis内存数据库,若没有持久化则数据断点及失
save 900 1 #900秒内,至少有一个key就行修改,就进行持久化操作 save 300 10 save 60 10000 #之后学习持久化会自己定义
stop-writes-on-bgsave-error yes #持久化人如果出错,是否还需要继续工作
rdbcompression yes #是否压缩rdb(持久化)文件
rdbchecksum yes #保存rgb文件时是否进行错误的校验
dbfilename dump.rdb
dir ./ #rgb文件保存的目录
5.REPLICATION 主从
# replicaof <masterip> <masterport> # masterauth <master-password>
6.SECURITY 安全
# requirepass foobared 默认是空密码
修改配置文件 # requirepass 123456 设置密码 .
通过命令设置密码 config set requirepass 123456
设置密码后登录 auth 123456
7.CLIENTS 限制
#maxclients 10000 设置最大客户端数量
8.MEMORY MANAGEMENT 内存
maxmemory <bytes> 配置最大内存容量 (一般都默认)
maxmemory-policy noeviction 内存到上限的处理策略 [移出过期的 key /报错 ... ]
1、volatile-lru:只对设置了过期时间的key进行LRU(默认值) 2、allkeys-lru : 删除lru算法的key 3、volatile-random:随机删除即将过期key 4、allkeys-random:随机删除 5、volatile-ttl : 删除即将过期的 6、noeviction : 永不过期,返回错误
8. APPEND ONLY MODE <aof配置>
appendonly no #默认不开启aof 默认使用rdb持久化
appendfilename "appendonly.aof" #持久化的文件名字
# appendfsync always #每次修改都会同步 消耗性能
appendfsync everysec #每秒执行一次(默认) 可能会丢失
# appendfsync no #不执行 ,这时候操作系统自己同步数据,速度最快
save 保存配置
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术