Redis 2 redis 配置文件redis.conf

在对redis 配置文件进行修改的时候要进行备份

https://raw.githubusercontent.com/antirez/redis/3.0/redis.conf

一: 对单位的定义

# Redis配置文件样例

# 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.

首先是对单位的介绍 对大小写不敏感, 支持的bytes,不支持bit

二:INCLUDES

# Include one or more other config files here.
...
# include /path/to/local.conf
# include /path/to/other.conf

通过includes 包含,redis.conf 作为总闸,可以包含其他的配置文件

三:GENERAL

通用的标准化配置

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no  		 # 在自己使用的时候要将no 改为yes 

#默认情况下,redis不作为守护进程运行。如果需要,请使用“是”。
#注意redis会在后台监控时在/var/run/redis.pid中写入一个pid文件
在使用的时候将 no 变为yes,使redis 编程一个守护进程运行
port 6379
默认运行接口
tcp-backlog 511
设置tcp 的backlog ,backlog 是一个链接队列(连接总和),在高并发的情况下需要一个高的backlog 值 来避免客户端的链接问题
backlog 队列总和= 为未完成三次握手队列+已经完成三次握手队列

在自己的单机测试,学习的过程中不用管他(自己学习也不需要一个千万级的连接数)
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
当客户端空闲多少时间之后将客户端域redis 的链接断开,0 表示不关闭一直保持链接
TCP-keepalive 0
单位为秒,表示一段时间间隔对链接情况进行检测,查看是否keepalive ,0 表示一直不检测
# 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

redis 的日志级别 : development/testing 使用debug 四个日志级别 往下级别越高,打印的信息越少,产品投入生产
之后建议使用notic/warning
logfile ""
日志文件的名字,可以是空的字符串,redis 就会在控制台有一个标准的输出
# syslog-enabled no
是否把redis 的日志输入到系统日志 默认 no 

# syslog-ident redis
指定系统中redis 的日志标识 默认为redis 

四:snapshoptting(快照)

五:replication(复制)

六:security(安全)

在linux 环境下是直接进入redis ,并不需要密码登录
redis 是架在linux 服务器上的,你进入linux 就表示你的安全级别是够的,所以就认为是可以直接用的,不用密码


#查看密码 : 默认密码为空
config get requirepass

#设置密码
config set requirepass "密码"

# Require clients to issue AUTH <PASSWORD> before processing any other
# 如果设置了密码,那么在进行操作之前 就要 进行密码输入
auth <PASSWORD>

七: limits 限制

一些连接,缓存,内存的大小限制

#连接限制
# maxclients 10000    
#内存分配
# maxmemory <bytes>
#过期清除策略
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#内存大小是有限的,当你的内存达到最大之后,你将采取那种方式对内存进行移除管理(移除那些数据):

# The default is:
# 默认设置: 永不过期 (实际的生产过程中,不可用)
# maxmemory-policy noeviction

数据清除策略:

  1. volatile-lru : 使用lru (最近最少使用策略) 删除数据。但是只针对设置了过期时间的key
  2. allkeys-lru : 使用lru 策略删除数据,对于任何键
  3. volatile-random : 随机删除。只针对设置了过期时间的key
  4. allkeys-random :随机删除,针对任何键
  5. volatile-ttl : 删除ttl 最小的键(删除快过期的键)。但是只针对设置了过期时间的key
  6. noeviction : 永不过期(在实际的生产中不会使用),针对写操作,无法写入就会返回错误。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值