352262 发表于 2018-11-7 09:57:01

Redis 默认配置精简及注释说明

## Generated by install_server.sh ##  
# Redis configuration file example

  
# Note on units: when memory>  
# 1k => 1000 bytes1m1g
  
# 1kb => 1024 bytes 1mb1gb
  
# units are case insensitive so 1GB 1Gb 1gB are all the same.
  
daemonize yes ##是否以后台daemon方式运行
  
pidfile /var/run/redis_6379.pid ##守护进程模式下的 pid文件位置
  
port 6379 ##监听端口设置为0则不会监听TCP socket
  
# bind 127.0.0.1 ##绑定接口监听连接,不设置则监听所有连接
  
# unixsocket /tmp/redis.sock ##用于监听连接的 unix socket
  
# unixsocketperm 755 ##socket 文件权限
  
timeout 0 ##客户端闲置N秒后自动断开连接,0为不限制 #请求超时时间
  
tcp-keepalive 0 ##TCP 连接存活时间,0不限制, 60(秒)
  
loglevel notice ##日志级别 debug(调试,大量日志信息) verbose(详细) notice(适度详细) warning(仅记录严重的信息)
  
logfile /var/log/redis_6379.log ##日志文件,使用stdout,日志会发送到/dev/null
  
# syslog-enabled no ##开启系统日志
  
# syslog-ident redis ##系统日志标识
  
# syslog-facility local0 ##系统日志用户 USER 或 LOCAL0 - LOCAL7
  
databases 16 ##开启的数据库数量 ,默认使用的是 0使用SELECT 进行切换(从0开始)
  
save 900 1 ##跟进key变更次数,间期创建快照,保存数据到磁盘
  
save 300 10 ##大于10次key操作,300秒存一次盘
  
save 60 10000 ##大于10000次60秒;设置为 save "" 则实时存盘
  
stop-writes-on-bgsave-error yes ##存盘错误时禁止写入
  
rdbcompression yes ##使用LZF压缩存盘
  
rdbchecksum yes ##存盘校验 CRC64校验
  
dbfilename dump.rdb ##存盘数据库文件名
  
dir /var/lib/redis/6379##工作目录,(数据保存路径)
  
# slaveof    ##从服务器 上的主服务器信息
  
# masterauth##主服务器密码
  
slave-serve-stale-data yes ##从服务器可访问
  
slave-read-only yes #从服务器只读
  
# repl-ping-slave-period 10 ##从服务器发送ping信息间隔10秒
  
# repl-timeout 60 ##超时时间
  
repl-disable-tcp-nodelay no ##启用小的TCP 包(系统处理会消耗部分时间)
  
slave-priority 100 ##从服务器优先权越小越优先
  
# requirepass foobared ##使用密码,执行命令之前需要 AUTH验证
  
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 ##命令重命名
  
# rename-command CONFIG "" ##命令 移除##可能会导致从服务器有问题
  
# maxclients 10000 ##最大连接数默认10000
  
# maxmemory   ##内存限制
  
# maxmemory-policy volatile-lru ##(按近期最少用算法清理)清理规则具体如下
  
## volatile-lru -> remove the key with an expire set using an LRU algorithm
  
## allkeys-lru -> remove any key accordingly to the LRU algorithm
  
## volatile-random -> remove a random key with an expire set
  
## allkeys-random -> remove a random key, any key
  
## volatile-ttl -> remove the key with the nearest expire time (minor TTL)
  
## noeviction -> don't expire at all, just return an error on write operations
  
# maxmemory-samples 3 #LRU算法检查的key数量
  
appendonly no #启用AOF日志模式
  
# appendfilename appendonly.aof ##AOF模式 文件名
  
# appendfsync always ##记录全部操作
  
appendfsync everysec ##每秒记录一次
  
# appendfsync no ##不记录
  
no-appendfsync-on-rewrite no ##是否允许覆盖 AOF文件
  
auto-aof-rewrite-percentage 100 #AOF文件使用超过限制大小100%后自动覆盖
  
auto-aof-rewrite-min-size 64mb #AOF 文件大小限制
  
lua-time-limit 5000 ##Lua代码 最大执行时间 ,0为不限制
  
slowlog-log-slower-than 10000 ##慢执行记录
  
slowlog-max-len 128 ##慢执行记录最大长度
  
############################### 高级配置 ###############################
  
hash-max-ziplist-entries 512
  
hash-max-ziplist-value 64
  
list-max-ziplist-entries 512
  
list-max-ziplist-value 64
  
set-max-intset-entries 512
  
zset-max-ziplist-entries 128
  
zset-max-ziplist-value 64
  
activerehashing yes
  
## 客户端分类限制:
  
## normal -> normal clients
  
## slave-> slave clients and MONITOR clients
  
## pubsub -> clients subcribed to at least one pubsub channel or pattern
  
## client-output-buffer-limit   
  
client-output-buffer-limit normal 0 0 0
  
client-output-buffer-limit slave 256mb 64mb 60
  
client-output-buffer-limit pubsub 32mb 8mb 60
  
hz 10 ##键值使用频率分级
  
aof-rewrite-incremental-fsync yes ##间隔写入AOF文件
  
# include /path/to/local.conf##引入配置


页: [1]
查看完整版本: Redis 默认配置精简及注释说明