[TOC]
说明
先写个常用的,其他的以后用到在翻译吧……
欢迎纠错。
1 关于redis配置文件的说明
1.1 位置
理论上来讲,配置的位置可以随意放置。
在redis
启动的时候将配置文件的路径当做第一个参数
传递给redis-server即可。
./redis-server /path/to/redis.conf
1.2 内存单位
- 内存单位大小写不敏感
- 但是
k
和kb
,g
和gb
是不同的
1k => 1000 bytes
1kb => 1024 bytes
1m => 1000000 bytes
1mb => 1024*1024 bytes
1g => 1000000000 bytes
1gb => 1024*1024*1024 bytes
2 GENERAL-常规配置
################################# GENERAL #####################################
# 默认为no.
# 是否以守护进程的方式运行redis.
daemonize yes
# redis的进程描述符文件
# 启动的时候会在该位置创建文件,停止的时候会删除该文件.
#
# 如果redis不是以守护进程的方式运行,同时如果没有指定'pidfile',则不会创建该文件。
# 如果redis是以守护进程的方式运行的,即使是没有指定'pidfile',也会创建该进程描述符文件,默认位置为:"/var/run/redis.pid".
#
# redis会尽力创建pid文件: 如果Redis创建pidfile失败了,也不会有其他不良影响,redis会正常启动运行。
pidfile /var/run/redis_6379.pid
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
# They do not enable continuous liveness pings back to your supervisor.
supervised no
# 指定日志级别
# 可取值如下:
# 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
# 指定日志文件名.
# 在该值为空字符串的情况下:
# 1) 如果redis不是以后台进程的方式运行,日志会在标准输出设备上输出
# 2) 如果redi是一个后台进程的方式运行的,日志会被送到设备文件/dev/null
logfile ""
# 是否启用系统日志,如要启用改项,将值置为yes即可.
# syslog-enabled no
# 指定系统日志的前缀(redis.log).
# syslog-ident redis
# 指定syslog设备,值可以是USER或LOCAL0-LOCAL7
# syslog-facility local0
# 设置数据库的数量. 默认的数据库是0号库.
# 可以使用SELECT <dbid>来切换到对应的数据库,dbid 是一个0到'databases'-1的数字.
databases 16
3 NETWORK
################################## NETWORK #####################################
# 默认情况下,如果没有配置bind指令,Redis将监听在服务器所有可用的网络地址上.
# 可以使用bind指令来指定Redis监听在一个或多个特定的网络地址上.
#
# 示例:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~
# 如果运行Redis的服务器是直接暴露在Internet上的,绑定所有网络地址是很危险的,并且会将Redis实例暴露给Internet上的所有人.
# 所以,推荐你取消下面的bidn指令的注释,以强制使Redis监听在IPV4的本地回环地址(127.0.0.1).
# 这也就意味着Redis将只接受来自运行Redis服务的同一台电脑上的客户端的连接.
#
bind 127.0.0.1
# Protected mode 是一层安全保护层, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# 当 protected mode 开启时如果:
# 1) 如果Redis服务没有用bind指令明确指定一些列绑定的IP地址.
# 2) 没有配置密码.
# Redis将仅仅接受来自IPV4和IPV6的本地回环地址127.0.0.1和::1,还有Unix domain sockets的客户端连接.
#
# 默认情况下protected mode是启用的.
# 如果你确定即使是在你没有配置密码验证也没有用bind指令明确指定Redis监听的网络地址的情况下,
# 你也想来自其他主机的客户端连接Redis,你可以禁用该选项.
protected-mode yes
# 默认端口为6379
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
# TCP listen() backlog.
#
# 在高并发的环境下需要将该值调大以避免客户端连接缓慢的问题.
# 但是在Linux环境下,Linux内核将默默地将该值改变成/proc/sys/net/core/somaxconn的值.
# 所以要使该值生效,你还得同时更改somaxconn的值.
tcp-backlog 511
# Unix socket.
#
# Specify the path for the Unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 700
# 处于idle状态的客户端的超时时间(多少秒后端口该类"发呆"的客户端连接)
# 0表示禁用该功能
timeout 0
# TCP keepalive.
#
# 如果设置为一个非零值,在通信不稳定时会使用SO_KEEPALIVE发送TCP确认报文.
# 原因如下:
#
# 1) 探测已经"死亡的"(断开的)通信链路.
# 2) 从网络设备的角度确保连接还"活着".
#
# 在Linux上,指定的这个值(秒)将是发送ACK的时间间隔.
tcp-keepalive 300
4 SNAPSHOTTING
################################ SNAPSHOTTING ################################
#
# 将数据保存到磁盘:
#
# save <seconds> <changes>
#
# 当指定的秒数(seconds)和写操作的次数(changes)都满足的时候将会触发save操作.
#
# 比如以下三种情况将会触发save操作:
# after 900 sec --(15 min) 15分钟内至少有一个key改变
# after 300 sec --(5 min) 5分钟内至少10个key改变
# after 60 sec --60秒内至少10000个key改变
#
# Note: 可以注释掉所有save开头的行来彻底禁用save操作.
#
# 也可以添加一个值为空字符串的save指令来去除预先设定的一些save配置,比如像下面这样:
#
# save ""
save 900 1
save 300 10
save 60 10000
# 默认情况下,如果启用了RDB快照(至少有一个保存点)并且最近一次的备份操作失败了,Redis将停止处理写操作.
# 这样做是为了让用户意识到数据的持久化发生了异常.
#
# 如果后台的备份进程再次恢复正常,Redis将会继续处理写操作.
#
# 当然,你也可以禁用这个特性.
# 也就是说在磁盘异常,权限不足等原因导致save进程无法正常工作时可以继续处理写操作.指令如下:
stop-writes-on-bgsave-error yes
# 是否对.rdb文件使用LZF进行压缩?
# 默认情况下,该特性是启用的.并且几乎总是有用的.
# 如果你想节省CPU资源可以将该项置为no,当然同时数据文件的体积也会更大.
rdbcompression yes
# 从第5版开始,在rdb文件的末尾会有一个CRC64校验和.
# 当然这会影响性能,可以关闭该特性以最大化Redis的性能.
#
rdbchecksum yes
# 备份文件的文件名
dbfilename dump.rdb
# 工作目录.
#
# 以`dbfilename`指定的值为文件名(比如dump.rdb)的数据库文件将被存储在该指令(dir)指定的目录中.
#
# AOF文件也会被在此处被创建.
#
# 请注意:必须指定一个目录,而不是一个文件名.
dir ./
5 REPLICATION
################################# REPLICATION #################################
# 主从复制. 用 slaveof 命令可以是一个Redis实例成为另一个Redis实例的备份.
# 以下是一些关于主从复制的知识点:
#
# 1) Redis的复制是异步的,当某个主机(master)的备机(slave)数量达不到一个最小值时,
# 你可以配置主机(master)停止接受写请求.
# 2) Redis slaves are able to perform a partial resynchronization with the
# master if the replication link is lost for a relatively small amount of
# time. You may want to configure the replication backlog size (see the next
# sections of this file) with a sensible value depending on your needs.
# 3) 备份是自动的并且不需要用户交互的.
#
# slaveof <masterip> <masterport>
# 主机(master)的密码保护设置
# masterauth <master-password>
# 当某个备机(slave)失去了和主机(master)的连接,或者备份进程仍在运行中,备机(slave)可以有如下两种表现:
# 1) 如果slave-serve-stale-data被置为'yes'(默认值)备机(slave)将继续回应客户端请求,
# 返回给客户端的数据可能是过时的,或者是空的.
#
# 2) 如果slave-serve-stale-data被置为'no',
# 备机(slave)将回复给客户端一个"SYNC with master in progress"的错误.
slave-serve-stale-data yes
# 你可以配置一个备机是否接受写请求.
# 对一个备机写数据在保存一些临时数据的时候可能会有用(对salve的写操作会在一次主从同步后被覆盖掉).
#
# 从Redis 2.6 开始salve默认是只读的.
#
slave-read-only yes
# 主从同步策略: disk or socket.
#
# -------------------------------------------------------
# WARNING: DISKLESS 备份策略目前尚处于实验阶段(redis-3.2.8)
# -------------------------------------------------------
#
# New slaves and reconnecting slaves that are not able to continue the replication
# process just receiving differences, need to do what is called a "full
# synchronization". An RDB file is transmitted from the master to the slaves.
# The transmission can happen in two different ways:
#
# 1) Disk-backed: The Redis master creates a new process that writes the RDB
# file on disk. Later the file is transferred by the parent
# process to the slaves incrementally.
# 2) Diskless: The Redis master creates a new process that directly writes the
# RDB file to slave sockets, without touching the disk at all.
#
# With disk-backed replication, while the RDB file is generated, more slaves
# can be queued and served with the RDB file as soon as the current child producing
# the RDB file finishes its work. With diskless replication instead once
# the transfer starts, new slaves arriving will be queued and a new transfer
# will start when the current one terminates.
#
# When diskless replication is used, the master waits a configurable amount of
# time (in seconds) before starting the transfer in the hope that multiple slaves
# will arrive and the transfer can be parallelized.
#
# With slow disks and fast (large bandwidth) networks, diskless replication
# works better.
repl-diskless-sync no
# When diskless replication is enabled, it is possible to configure the delay
# the server waits in order to spawn the child that transfers the RDB via socket
# to the slaves.
#
# This is important since once the transfer starts, it is not possible to serve
# new slaves arriving, that will be queued for the next RDB transfer, so the server
# waits a delay in order to let more slaves arrive.
#
# The delay is specified in seconds, and by default is 5 seconds. To disable
# it entirely just set it to 0 seconds and the transfer will start ASAP.
repl-diskless-sync-delay 5
# Slaves send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_slave_period option. The default value is 10
# seconds.
#
# repl-ping-slave-period 10
# The following option sets the replication timeout for:
#
# 1) Bulk transfer I/O during SYNC, from the point of view of slave.
# 2) Master timeout from the point of view of slaves (data, pings).
# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings).
#
# It is important to make sure that this value is greater than the value
# specified for repl-ping-slave-period otherwise a timeout will be detected
# every time there is low traffic between the master and the slave.
#
# repl-timeout 60
# Disable TCP_NODELAY on the slave socket after SYNC?
#
# If you select "yes" Redis will use a smaller number of TCP packets and
# less bandwidth to send data to slaves. But this can add a delay for
# the data to appear on the slave side, up to 40 milliseconds with
# Linux kernels using a default configuration.
#
# If you select "no" the delay for data to appear on the slave side will
# be reduced but more bandwidth will be used for replication.
#
# By default we optimize for low latency, but in very high traffic conditions
# or when the master and slaves are many hops away, turning this to "yes" may
# be a good idea.
repl-disable-tcp-nodelay no
# Set the replication backlog size. The backlog is a buffer that accumulates
# slave data when slaves are disconnected for some time, so that when a slave
# wants to reconnect again, often a full resync is not needed, but a partial
# resync is enough, just passing the portion of data the slave missed while
# disconnected.
#
# The bigger the replication backlog, the longer the time the slave can be
# disconnected and later be able to perform a partial resynchronization.
#
# The backlog is only allocated once there is at least a slave connected.
#
# repl-backlog-size 1mb
# After a master has no longer connected slaves for some time, the backlog
# will be freed. The following option configures the amount of seconds that
# need to elapse, starting from the time the last slave disconnected, for
# the backlog buffer to be freed.
#
# A value of 0 means to never release the backlog.
#
# repl-backlog-ttl 3600
# 备机的优先级是一个整数.
# 它是给哨兵模式使用的(当master工作不正常时哨兵模式将选一个slave作为master.
#
# 优先级值越小越先会被考虑,比如三个salve的优先级为10, 100, 25.
# 哨兵将会选择优先级值最小的10.
#
# 但是,如果0这个特殊值被指定的话表示该slave将不会参加master选举.
#
# 默认的优先级为 100.
slave-priority 100
# It is possible for a master to stop accepting writes if there are less than
# N slaves connected, having a lag less or equal than M seconds.
# 对于一个master来说当他的slave数量在M秒小于等于N的时候可以停止接受写操作.
#
# 这 N 个slaves指的是 "online" 状态的.
#
# The lag in seconds, that must be <= the specified value, is calculated from
# the last ping received from the slave, that is usually sent every second.
#
# This option does not GUARANTEE that N replicas will accept the write, but
# will limit the window of exposure for lost writes in case not enough slaves
# are available, to the specified number of seconds.
#
# For example to require at least 3 slaves with a lag <= 10 seconds use:
#
# min-slaves-to-write 3
# min-slaves-max-lag 10
#
# Setting one or the other to 0 disables the feature.
#
# By default min-slaves-to-write is set to 0 (feature disabled) and
# min-slaves-max-lag is set to 10.
# Redis主机(master)可以通过不同的方式来列出连接到它的备机(slave)的IP和端口.
# 比如 "INFO replication" 可以列出这些信息.
# Redis 哨兵可以通过其他途径来获取相应的信息已发现slave实例.比如'role'命令.
#
# The listed IP and address normally reported by a slave is obtained
# in the following way:
#
# IP: The address is auto detected by checking the peer address
# of the socket used by the slave to connect with the master.
#
# Port: The port is communicated by the slave during the replication
# handshake, and is normally the port that the slave is using to
# list for connections.
#
# However when port forwarding or Network Address Translation (NAT) is
# used, the slave may be actually reachable via different IP and port
# pairs. The following two options can be used by a slave in order to
# report to its master a specific set of IP and port, so that both INFO
# and ROLE will report those values.
#
# There is no need to use both the options if you need to override just
# the port or the IP address.
#
# slave-announce-ip 5.5.5.5
# slave-announce-port 1234
6 SECURITY
################################## SECURITY ###################################
# 在Redis处理其他命令前,要求客户端使用 AUTH <PASSWORD> 来验证身份.
# 如果你不信任访问运行redis-server的其他访问者的情况下,该项可能会有用.
#
# requirepass foobared
# 命令重命名.
#
# 在一个共享的环境中,可以给命令重命名.
# 比如 CONFIG 命令可以被重命名为一些很难猜到的新名称.
#
# 示例:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# 可以将一个命令重命名为空字符,以彻底禁用该命令:
#
# rename-command CONFIG ""
#
# 不过请注意,命令重命名被记录在AOF文件里或传输到集群中可能会导致问题.
7 LIMITS
################################### LIMITS ####################################
# 设置同时连接的最大客户端数量. 默认值是 10000 .
# 当你无法设置进程文件句柄限制时,redis会设置为当前的文件句柄限制值减去32 (edis会为自身内部处理逻辑留一些句柄出来).
#
# 如果达到了此限制,redis则会拒绝新的连接请求,
# 并且向这些连接请求方发出“max number of clients reached”以作回应.
#
# maxclients 10000
# 设置redis可以使用的内存大小.
# 当内存使用达到上限时,Redis将根据设定的'maxmemory-policy'来移除一些'keys'.
#
# 如果Redis无法根据'maxmemory-policy'来移除数据或'maxmemory-policy'被设置为'noeviction',
# redis会针对那些需要申请内存的指令返回错误信息,比如SET、LPUSH等;
# 但是对于无内存申请的指令,仍然会正常响应,比如GET等.
#
#
# WARNING: 如果你的redis是主redis(说明你的redis有从redis),
# 那么在设置内存使用上限时,需要在系统中留出一些内存空间给同步队列缓存,
# 在你设置的是“noeviction”的情况下,不用考虑这个因素.
#
# maxmemory <bytes>
# MAXMEMORY POLICY(最大内存策略): 当内存到达最大上限时Redis该如何选择将要被移除的数据
# 有如下5种选项:
#
# volatile-lru -> 使用LRU算法来移除设置了过期时间的key (只针对于设置了过期时间的key)
# allkeys-lru -> 使用LRU算法来移除key (针对于所有的key)
# volatile-random -> 从设置了过期时间的key中随机选一个移除 (只针对于设置了过期时间的key)
# allkeys-random -> 随机选一个key来移除 (针对于所有的key)
# volatile-ttl -> 移除最快要过期的key (TTL最小的)
# noeviction -> 不移除任何key, 仅仅对写操作返回错误
#
# Note: with any of the above policies, Redis will return an error on write
# operations, when there are no suitable keys for eviction.
#
# At the date of writing these commands are: set setnx setex append
# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
# getset mset msetnx exec sort
#
# 默认配置:
# maxmemory-policy noeviction
# LRU和最小TTL算法都不是精确的算法而是一种估算.
# 默认情况下,Redis会从5个key中选一个最近未被使用的key来移除,你可以使用如下指令来设置样本的大小.
#
# 默认的5已经是个足够好的配置了. 10非常接近真正的LRU算法但是需要更多的CPU资源. 3非常快但不怎么准确.
#
# maxmemory-samples 5
8 APPEND ONLY MODE
############################## APPEND ONLY MODE ###############################
#
# 'Append Only File'是另一个可选的更加稳定的持久化方案.
# 在这种情况下,Redis使用默认的'fsync'策略,在服务器断电等情况下可能丢失一秒钟的数据.
#
# AOF 和 RDB 可以同时启用.
# 如果在Redis启动的时候AOF是启用的,Redis将加载AOF文件已保证更准确的数据.
#
appendonly no
# AOF的文件名. (默认为: "appendonly.aof")
appendfilename "appendonly.aof"
# fsync()的调用会通知操作系统将数据真正的写入到磁盘而不是在内存缓冲中等待更多的数据.
# 有些操作系统会真的将数据写入磁盘,也有些操作系统会尽可能快(ASAP)的写入磁盘.
#
# Redis 支持三种模式:
#
# no: 不执行fsync, 由操作系统自己将数据写入磁盘. (很快).
# always: 每一次写操作都将数据写入磁盘. (慢, 最安全).
# everysec: 每秒一次fsync,可能丢失一秒的数据. (折中方案).
#
# 默认的配置是 "everysec", 也是稳定性和性能的折中方案.
#
# appendfsync always
appendfsync everysec
# appendfsync no
# 当AOF的同步策略被设置成always或everysec时,后台用于保存数据或重写AOF文件的进程会占用大量IO.
# 在一些Linux系统上,Redis可能会在fsync()调用时阻塞很久.
#
# 为了减缓这个问题的代价,可以使用如下选项在BGSAVE或BGREWRITEAOF进行
no-appendfsync-on-rewrite no
# 自动重写AOF文件.
# 当AOF文件的大小超过了指定的大小的时候Redis会调用BGREWRITEAOF来重写AOF文件.
#
# 工作原理: Redis会记住上次重写时AOF文件的大小(如果还没发生过重写,那么会使用Redis启动时AOF文件的大小).
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered.
# AOF文件大小的增长率大于auto-aof-rewrite-percentage指定的值时,重写操作将被触发.
# 同时需要指定一个AOF文件大小的最小值,
# 这可以有效地避免在比例已经到了指定的值但是文件体积依然很小的情况下重写AOF文件.
#
# 可以将该值置为0以禁用AOF文件的自动重写.
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
# An AOF file may be found to be truncated at the end during the Redis
# startup process, when the AOF data gets loaded back into memory.
# This may happen when the system where Redis is running
# crashes, especially when an ext4 filesystem is mounted without the
# data=ordered option (however this can't happen when Redis itself
# crashes or aborts but the operating system still works correctly).
#
# Redis can either exit with an error when this happens, or load as much
# data as possible (the default now) and start if the AOF file is found
# to be truncated at the end. The following option controls this behavior.
#
# If aof-load-truncated is set to yes, a truncated AOF file is loaded and
# the Redis server starts emitting a log to inform the user of the event.
# Otherwise if the option is set to no, the server aborts with an error
# and refuses to start. When the option is set to no, the user requires
# to fix the AOF file using the "redis-check-aof" utility before to restart
# the server.
#
# Note that if the AOF file will be found to be corrupted in the middle
# the server will still exit with an error. This option only applies when
# Redis will try to read more data from the AOF file but not enough bytes
# will be found.
aof-load-truncated yes
9 INCLUDES
10 LUA SCRIPTING
################################ LUA SCRIPTING ###############################
# Max execution time of a Lua script in milliseconds.
#
# If the maximum execution time is reached Redis will log that a script is
# still in execution after the maximum allowed time and will start to
# reply to queries with an error.
#
# When a long running script exceeds the maximum execution time only the
# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
# used to stop a script that did not yet called write commands. The second
# is the only way to shut down the server in the case a write command was
# already issued by the script but the user doesn't want to wait for the natural
# termination of the script.
#
# Set it to 0 or a negative value for unlimited execution without warnings.
lua-time-limit 5000
11 REDIS CLUSTER
################################ REDIS CLUSTER ###############################
#
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however
# in order to mark it as "mature" we need to wait for a non trivial percentage
# of users to deploy it in production.
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Normal Redis instances can't be part of a Redis Cluster; only nodes that are
# started as cluster nodes can. In order to start a Redis instance as a
# cluster node enable the cluster support uncommenting the following:
#
# cluster-enabled yes
# Every cluster node has a cluster configuration file. This file is not
# intended to be edited by hand. It is created and updated by Redis nodes.
# Every Redis Cluster node requires a different cluster configuration file.
# Make sure that instances running in the same system do not have
# overlapping cluster configuration file names.
#
# cluster-config-file nodes-6379.conf
# Cluster node timeout is the amount of milliseconds a node must be unreachable
# for it to be considered in failure state.
# Most other internal time limits are multiple of the node timeout.
#
# cluster-node-timeout 15000
# A slave of a failing master will avoid to start a failover if its data
# looks too old.
#
# There is no simple way for a slave to actually have a exact measure of
# its "data age", so the following two checks are performed:
#
# 1) If there are multiple slaves able to failover, they exchange messages
# in order to try to give an advantage to the slave with the best
# replication offset (more data from the master processed).
# Slaves will try to get their rank by offset, and apply to the start
# of the failover a delay proportional to their rank.
#
# 2) Every single slave computes the time of the last interaction with
# its master. This can be the last ping or command received (if the master
# is still in the "connected" state), or the time that elapsed since the
# disconnection with the master (if the replication link is currently down).
# If the last interaction is too old, the slave will not try to failover
# at all.
#
# The point "2" can be tuned by user. Specifically a slave will not perform
# the failover if, since the last interaction with the master, the time
# elapsed is greater than:
#
# (node-timeout * slave-validity-factor) + repl-ping-slave-period
#
# So for example if node-timeout is 30 seconds, and the slave-validity-factor
# is 10, and assuming a default repl-ping-slave-period of 10 seconds, the
# slave will not try to failover if it was not able to talk with the master
# for longer than 310 seconds.
#
# A large slave-validity-factor may allow slaves with too old data to failover
# a master, while a too small value may prevent the cluster from being able to
# elect a slave at all.
#
# For maximum availability, it is possible to set the slave-validity-factor
# to a value of 0, which means, that slaves will always try to failover the
# master regardless of the last time they interacted with the master.
# (However they'll always try to apply a delay proportional to their
# offset rank).
#
# Zero is the only value able to guarantee that when all the partitions heal
# the cluster will always be able to continue.
#
# cluster-slave-validity-factor 10
# Cluster slaves are able to migrate to orphaned masters, that are masters
# that are left without working slaves. This improves the cluster ability
# to resist to failures as otherwise an orphaned master can't be failed over
# in case of failure if it has no working slaves.
#
# Slaves migrate to orphaned masters only if there are still at least a
# given number of other working slaves for their old master. This number
# is the "migration barrier". A migration barrier of 1 means that a slave
# will migrate only if there is at least 1 other working slave for its master
# and so forth. It usually reflects the number of slaves you want for every
# master in your cluster.
#
# Default is 1 (slaves migrate only if their masters remain with at least
# one slave). To disable migration just set it to a very large value.
# A value of 0 can be set but is useful only for debugging and dangerous
# in production.
#
# cluster-migration-barrier 1
# By default Redis Cluster nodes stop accepting queries if they detect there
# is at least an hash slot uncovered (no available node is serving it).
# This way if the cluster is partially down (for example a range of hash slots
# are no longer covered) all the cluster becomes, eventually, unavailable.
# It automatically returns available as soon as all the slots are covered again.
#
# However sometimes you want the subset of the cluster which is working,
# to continue to accept queries for the part of the key space that is still
# covered. In order to do so, just set the cluster-require-full-coverage
# option to no.
#
# cluster-require-full-coverage yes
# In order to setup your cluster make sure to read the documentation
# available at http://redis.io web site.
12 SLOW LOG
################################## SLOW LOG ###################################
# The Redis Slow Log is a system to log queries that exceeded a specified
# execution time. The execution time does not include the I/O operations
# like talking with the client, sending the reply and so forth,
# but just the time needed to actually execute the command (this is the only
# stage of command execution where the thread is blocked and can not serve
# other requests in the meantime).
#
# You can configure the slow log with two parameters: one tells Redis
# what is the execution time, in microseconds, to exceed in order for the
# command to get logged, and the other parameter is the length of the
# slow log. When a new command is logged the oldest one is removed from the
# queue of logged commands.
# The following time is expressed in microseconds, so 1000000 is equivalent
# to one second. Note that a negative number disables the slow log, while
# a value of zero forces the logging of every command.
slowlog-log-slower-than 10000
# There is no limit to this length. Just be aware that it will consume memory.
# You can reclaim memory used by the slow log with SLOWLOG RESET.
slowlog-max-len 128
13 LATENCY MONITOR
################################ LATENCY MONITOR ##############################
# The Redis latency monitoring subsystem samples different operations
# at runtime in order to collect data related to possible sources of
# latency of a Redis instance.
#
# Via the LATENCY command this information is available to the user that can
# print graphs and obtain reports.
#
# The system only logs operations that were performed in a time equal or
# greater than the amount of milliseconds specified via the
# latency-monitor-threshold configuration directive. When its value is set
# to zero, the latency monitor is turned off.
#
# By default latency monitoring is disabled since it is mostly not needed
# if you don't have latency issues, and collecting data has a performance
# impact, that while very small, can be measured under big load. Latency
# monitoring can easily be enabled at runtime using the command
# "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
latency-monitor-threshold 0
14 EVENT NOTIFICATION
############################# EVENT NOTIFICATION ##############################
# Redis can notify Pub/Sub clients about events happening in the key space.
# This feature is documented at http://redis.io/topics/notifications
#
# For instance if keyspace events notification is enabled, and a client
# performs a DEL operation on key "foo" stored in the Database 0, two
# messages will be published via Pub/Sub:
#
# PUBLISH __keyspace@0__:foo del
# PUBLISH __keyevent@0__:del foo
#
# It is possible to select the events that Redis will notify among a set
# of classes. Every class is identified by a single character:
#
# K Keyspace events, published with __keyspace@<db>__ prefix.
# E Keyevent events, published with __keyevent@<db>__ prefix.
# g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
# $ String commands
# l List commands
# s Set commands
# h Hash commands
# z Sorted set commands
# x Expired events (events generated every time a key expires)
# e Evicted events (events generated when a key is evicted for maxmemory)
# A Alias for g$lshzxe, so that the "AKE" string means all the events.
#
# The "notify-keyspace-events" takes as argument a string that is composed
# of zero or multiple characters. The empty string means that notifications
# are disabled.
#
# Example: to enable list and generic events, from the point of view of the
# event name, use:
#
# notify-keyspace-events Elg
#
# Example 2: to get the stream of the expired keys subscribing to channel
# name __keyevent@0__:expired use:
#
# notify-keyspace-events Ex
#
# By default all notifications are disabled because most users don't need
# this feature and the feature has some overhead. Note that if you don't
# specify at least one of K or E, no events will be delivered.
notify-keyspace-events ""
15 ADVANCED CONFIG
############################### ADVANCED CONFIG ###############################
# Hashes are encoded using a memory efficient data structure when they have a
# small number of entries, and the biggest entry does not exceed a given
# threshold. These thresholds can be configured using the following directives.
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
# Lists are also encoded in a special way to save a lot of space.
# The number of entries allowed per internal list node can be specified
# as a fixed maximum size or a maximum number of elements.
# For a fixed maximum size, use -5 through -1, meaning:
# -5: max size: 64 Kb <-- not recommended for normal workloads
# -4: max size: 32 Kb <-- not recommended
# -3: max size: 16 Kb <-- probably not recommended
# -2: max size: 8 Kb <-- good
# -1: max size: 4 Kb <-- good
# Positive numbers mean store up to _exactly_ that number of elements
# per list node.
# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
# but if your use case is unique, adjust the settings as necessary.
list-max-ziplist-size -2
# Lists may also be compressed.
# Compress depth is the number of quicklist ziplist nodes from *each* side of
# the list to *exclude* from compression. The head and tail of the list
# are always uncompressed for fast push/pop operations. Settings are:
# 0: disable all list compression
# 1: depth 1 means "don't start compressing until after 1 node into the list,
# going from either the head or tail"
# So: [head]->node->node->...->node->[tail]
# [head], [tail] will always be uncompressed; inner nodes will compress.
# 2: [head]->[next]->node->node->...->node->[prev]->[tail]
# 2 here means: don't compress head or head->next or tail->prev or tail,
# but compress all nodes between them.
# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
# etc.
list-compress-depth 0
# Sets have a special encoding in just one case: when a set is composed
# of just strings that happen to be integers in radix 10 in the range
# of 64 bit signed integers.
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
set-max-intset-entries 512
# Similarly to hashes and lists, sorted sets are also specially encoded in
# order to save a lot of space. This encoding is only used when the length and
# elements of a sorted set are below the following limits:
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
# HyperLogLog sparse representation bytes limit. The limit includes the
# 16 bytes header. When an HyperLogLog using the sparse representation crosses
# this limit, it is converted into the dense representation.
#
# A value greater than 16000 is totally useless, since at that point the
# dense representation is more memory efficient.
#
# The suggested value is ~ 3000 in order to have the benefits of
# the space efficient encoding without slowing down too much PFADD,
# which is O(N) with the sparse encoding. The value can be raised to
# ~ 10000 when CPU is not a concern, but space is, and the data set is
# composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
hll-sparse-max-bytes 3000
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# order to help rehashing the main Redis hash table (the one mapping top-level
# keys to values). The hash table implementation Redis uses (see dict.c)
# performs a lazy rehashing: the more operation you run into a hash table
# that is rehashing, the more rehashing "steps" are performed, so if the
# server is idle the rehashing is never complete and some more memory is used
# by the hash table.
#
# The default is to use this millisecond 10 times every second in order to
# actively rehash the main dictionaries, freeing memory when possible.
#
# If unsure:
# use "activerehashing no" if you have hard latency requirements and it is
# not a good thing in your environment that Redis can reply from time to time
# to queries with 2 milliseconds delay.
#
# use "activerehashing yes" if you don't have such hard requirements but
# want to free memory asap when possible.
activerehashing yes
# The client output buffer limits can be used to force disconnection of clients
# that are not reading data from the server fast enough for some reason (a
# common reason is that a Pub/Sub client can't consume messages as fast as the
# publisher can produce them).
#
# The limit can be set differently for the three different classes of clients:
#
# normal -> normal clients including MONITOR clients
# slave -> slave clients
# pubsub -> clients subscribed to at least one pubsub channel or pattern
#
# The syntax of every client-output-buffer-limit directive is the following:
#
# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#
# A client is immediately disconnected once the hard limit is reached, or if
# the soft limit is reached and remains reached for the specified number of
# seconds (continuously).
# So for instance if the hard limit is 32 megabytes and the soft limit is
# 16 megabytes / 10 seconds, the client will get disconnected immediately
# if the size of the output buffers reach 32 megabytes, but will also get
# disconnected if the client reaches 16 megabytes and continuously overcomes
# the limit for 10 seconds.
#
# By default normal clients are not limited because they don't receive data
# without asking (in a push way), but just after a request, so only
# asynchronous clients may create a scenario where data is requested faster
# than it can read.
#
# Instead there is a default limit for pubsub and slave clients, since
# subscribers and slaves receive data in a push fashion.
#
# Both the hard or the soft limit can be disabled by setting them to zero.
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
# Redis calls an internal function to perform many background tasks, like
# closing connections of clients in timeout, purging expired keys that are
# never requested, and so forth.
#
# Not all tasks are performed with the same frequency, but Redis checks for
# tasks to perform according to the specified "hz" value.
#
# By default "hz" is set to 10. Raising the value will use more CPU when
# Redis is idle, but at the same time will make Redis more responsive when
# there are many keys expiring at the same time, and timeouts may be
# handled with more precision.
#
# The range is between 1 and 500, however a value over 100 is usually not
# a good idea. Most users should use the default of 10 and raise this up to
# 100 only in environments where very low latency is required.
hz 10
# When a child rewrites the AOF file, if the following option is enabled
# the file will be fsync-ed every 32 MB of data generated. This is useful
# in order to commit the file to the disk more incrementally and avoid
# big latency spikes.
aof-rewrite-incremental-fsync yes
网友评论