redis学习(二)redis配置文件redis.conf参数配置详解

1.redis-server --version

[root@localhost etc]# redis-server --version
Redis server v=3.2.12 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=7897e7d0e13773f

2.redis-cli --version  (redis客户端版本)

[root@localhost etc]# redis-cli --version
redis-cli 3.2.12

3.配置文件区域划分:

目录

(1)INCLUDES(加载其他)

(2) NETWORK(网络)

(3)GENERAL(常规基本选项)

(4)SNAPSHOTTING(快照/保存磁盘)

(5)REPLICATION(同步)

(6)SECURITY(安全) 

(7)LIMITS(限制)

(8)APPEND ONLY MODE(仅附加模式/纯累加模式

(9)LUA SCRIPTING(lua脚本))

(10) REDIS CLUSTER(CLUSTER) 

(11)SLOW LOG(慢查询日志)

(12)LATENCY MONITOR(延迟监控)

(13)EVENT NOTIFICATION(事件通知)

(14)ADVANCED CONFIG(高级配置)


 

3.配置文件

#e Redis configuration file example.(配置文件样本)
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
# (请注意,要读取配置文件,必须以文件路径作为第一个参数启动redis)
# ./redis-server /path/to/redis.conf

# Note on units: when memory size is needed, it is possible to specify
# (单位说明:当需要内存大小时,可以指定)
# 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.
# (单位不区分大小写,所以1GB 1Gb 1gB都是相同的)

################################## INCLUDES(加载其他) ###################################

# (大概意思:通过include可以加载其他的配置文件)
# Include one or more other config files here.  This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
# (在此处包含一个或多个其他配置文件。如果您有一个用于所有Redis服务器的标准模板,
# 但还需要为每个服务器自定义一些设置,则此模板非常有用。包含文件可以包含其他文件,
# 因此请明智地使用)
#
# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
# 注意选项“include”不会被命令“config rewrite”重写
# 从admin或redis sentinel。因为redis总是使用最后处理的行作为配置指令的值,
# 您最好将include在该文件的开头,以避免在运行时覆盖配置更改
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
# 如果您对使用include覆盖配置选项感兴趣,最好使用include作为最后一行
#
# include /path/to/local.conf
# include /path/to/other.conf

################################## NETWORK(网络) #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
# 默认情况下,如果未指定“bind”配置指令,则redis将侦听用于服务器上所有可用网络接口的连接,
# 可以使用“bind”配置指令只侦听一个或多个选定的接口,后跟一个或多个IP地址
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
# 如果运行redis的计算机直接暴露在Internet,绑定到所有接口是危险的,
# 将暴露互联网上的每个人都有这样的例子。因此,默认情况下,我们取消
# 遵循bind指令,这将强制redis只监听IPv4回望接口地址
# (这意味着Redis将能够只接受运行在同一台计算机上的客户端的连接正在运行)
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# 如果您确定希望实例监听所有接口  
# JUST COMMENT THE FOLLOWING LINE.
# (只需注释下面的一行)  
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 192.168.1.25

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
# 保护模式是一层安全保护,以避免在Internet上保持打开的Redis实例被访问和利用
# When protected mode is on and if:
# (当保护模式打开时,如果:
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 服务器没有使用“bind”指令显式绑定到一组地址   
# 2) No password is configured.
# 未配置密码
#   
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
# (服务器只接受来自从IPv4和IPv6环回地址127.0.0.1和::1连接的客户端以及来自Unix域套接字的连接)   
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
# 默认情况下启用保护模式。只有当您确定希望来自其他主机的客户机连接到redis时,您才应该禁用它,
# 即使没有配置身份验证,也没有使用“bind”指令显式列出特定的接口集   
protected-mode no 
# 保护模式(否)
#
# Accept connections on the specified port, default is 6379 (IANA #815344).
# 接受指定端口上的连接,默认值为6379(IANA 815344)   
# If port 0 is specified Redis will not listen on a TCP socket.
# 如果指定了端口0,Redis将不在TCP套接字上侦听   
port 6379

# TCP listen() backlog.
#
# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
# (在每秒高请求数的环境中,您需要按顺序进行高积压工作,以避免客户机连接缓慢的问题。
# 注意Linux内核将自动将其截断为/proc/sys/net/core/somaxconn so的值 
# 确保提高somaxconn和tcp_max_syn_backlog的值为了达到预期的效果
# (仅供参考:默认值 511,此参数确定了TCP连接中已完成队列(完成三次握手之后)的长度,
# 当然此值必须不大于Linux系统定义的/proc/sys/net/core/somaxconn值,默认是511,
# 而Linux的默认参数值是128。当系统并发量大并且客户端速度缓慢的时候,可以将这二个参数一起参考设定。
# 修改somaxconn,该内核参数默认值一般是128,对于负载很大的服务程序来说大大的不够。
# 一般会将它修改为2048或者更大 )
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.
# 指定将用于侦听传入连接的Unix套接字的路径,
# 没有默认值,因此未指定时redis将不在unix套接字上侦听   
# unixsocket /tmp/redis.sock
# unixsocketperm 700

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
# 一个客户端空闲多少秒后关闭连接。(0代表禁用,永不关闭)   

# TCP keepalive.
# TCP保持连接
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
# 如果非零,则使用so-keepalive将TCP ACK发送到不存在的客户端通信,这有两个原因  
#
# 1) Detect dead peers.(检测死点)
# 2) Take the connection alive from the point of view of network
#    equipment in the middle.(从中间网络设备的角度进行连接)
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# 在Linux上,指定的值(以秒为单位)是用于发送ACK的时间段
# Note that to close the connection the double of the time is needed.
# 请注意,要关闭连接,需要双倍的时间
# On other kernels the period depends on the kernel configuration.
# 对于其他内核,周期取决于内核配置
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
# 此选项的合理值为300秒,这是从Redis 3.2.1开始的新Redis默认值
tcp-keepalive 300

################################# GENERAL(常规基本选项) #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# 默认情况下,redis不作为守护进程运行。如果需要,请使用“是
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# # 注意,redis会在后台监控时在/var/run/redis.pid中写入一个pid文件。daemonize为no
daemonize no

# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# (linux有3种初始化系统,按出现的时间依次为init ,upstart和systemd)
# 如果您从upstart和systemd运行Redis,Redis可以与您的监督树交互。选项:
#
#   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

# If a pid file is specified, Redis writes it where specified at startup
# and removes it at exit.
# 如果指定了PID文件,redis会将其写入启动时指定的位置,并在退出时将其删除
#
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
# is used even if not specified, defaulting to "/var/run/redis.pid".
# 当服务器运行非守护进程时,如果配置中未指定任何PID文件,则不会创建任何PID文件
# 当服务器被监视时,即使未指定PID文件,也会使用该文件,默认为“/var/run/redis.pid”

# Creating a pid file is best effort: if Redis is not able to create it
# 创建一个pid文件是最大的努力:如果redis无法创建它
# nothing bad happens, the server will start and run normally.
# 没有什么不好的事情发生,服务器将正常启动和运行
# (大概:当以守护进程方式运行的时候,Redis会把进程ID默认写到 /var/run/redis.pid。你可以在这里修改路径。)
pidfile /var/run/redis_6379.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

# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
# 指定日志文件名。此外,空字符串还可以用于强制redis登录标准输出。请注意,
# 如果使用标准输出进行日志记录,但使用后台监视,则日志将发送到/dev/null
logfile /var/log/redis/redis.log

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# 要启用系统日志记录程序的日志记录,只需将“Syslog enabled”设置为“Yes”
# and optionally update the other syslog parameters to suit your needs.
# 还可以根据需要更新其他系统日志参数
# syslog-enabled no
# 系统日志是否启动

# Specify the syslog identity.(指定系统日志标识)
# syslog-ident redis(标记符号)

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# 指定系统日志功能。必须是用户或介于local0-local7之间
# syslog-facility local0

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
# 设置数据库数。默认数据库为db 0,您可以使用select<dbid>在每个连接基础上选择不同的数据库,
# 其中dbid是介于0和“databases”1之间的数字
databases 16

################################ SNAPSHOTTING(快照/保存磁盘)  ################################
#
# Save the DB on disk:
# 将数据库保存到磁盘上
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#   如果给定的秒数和给定的对数据库的写入操作数同时发生,将保存数据库
#
#   In the example below the behaviour will be to save:
#   下面的例子将会进行把数据写入磁盘的操作:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   900秒(15分钟)之后,且至少1次变更 
#   300秒(5分钟)之后,且至少10次变更 
#   60秒之后,且至少10000次变更 
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#   注意:你要想不写磁盘的话就把所有 "save" 设置注释掉就行了。
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   还可以通过添加一个带有单个空字符串参数的save指令来删除以前配置的所有保存点
#
#   like in the following example:
#   就像下面的例子一样
#
#   save ""

save 900 1
save 300 10
save 60 10000

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# 默认情况下,如果启用了RDB快照(至少一个保存点),并且最新的后台保存失败,Redis将停止接受写操作
#
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
# (这将使用户(以硬的方式)意识到数据没有正确地保存在磁盘上,否则很可能没有人会注意到,
#  并且会发生一些灾难)
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
# 如果后台保存过程再次开始工作,Redis将自动允许再次写入
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
# 但是,如果已经设置了对redis服务器和持久性的适当监视,则可能需要禁用此功能,
#以便redis可以继续正常工作,即使磁盘权限有问题,等等
stop-writes-on-bgsave-error yes

# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
# 在dump.rdb数据库时使用lzf压缩字符串对象,默认设置为“yes”,因为如果要在保存子级中保存一些CPU,
# 如果你想节省CPU的话你可以把这个设置为 "no",但是如果你有可压缩的key的话,那数据文件就会更大了
rdbcompression yes

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
# 由于RDB的版本5在文件的末尾放置了一个CRC64校验和,这使得格式更容易被破坏,但是在保存和加载RDB文件时,
# 性能会受到影响(大约10%),因此您可以禁用它以获得最佳性能
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
# 禁用校验和创建的RDB文件的校验和为零,它将告诉加载代码跳过检查
rdbchecksum yes

# The filename where to dump the DB(数据库的文件名)
dbfilename dump.rdb

# The working directory.(工作目录)
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 数据库将写入此目录中,使用上面指定的文件名,并使用'db filename'配置指令
#
# The Append Only File will also be created inside this directory.
# 只附加的文件也将在此目录中创建
#
# Note that you must specify a directory here, not a file name.
# 请注意,必须在此处指定目录,而不是文件名
dir /var/lib/redis

################################# REPLICATION(同步) #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replication.
# 主从同步。通过 slaveof 配置来实现Redis实例的备份。
# (注意,这里是本地从远端复制数据。也就是说,本地可以有不同的数据库文件、绑定不同的IP、监听不同的端口)
# 关于redis复制的几点需要尽快了解
#
# 1) Redis replication is asynchronous, but you can configure a master to
#    stop accepting writes if it appears to be not connected with at least
#    a given number of slaves.
#    (redis复制是异步的,但是如果一个主服务器看起来至少没有与给定数量的从服务器连接,
#    那么您可以配置它停止接受写操作)
#
# 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.
#    如果复制链路丢失的时间相对较短,Redis从站可以与主机执行部分重新同步。根据需要,
#    您可能需要使用合理的值配置复制积压工作的大小(请参阅此文件的下一节)
# 3) Replication is automatic and does not need user intervention. After a
#    network partition slaves automatically try to reconnect to masters
#    and resynchronize with them.
#    复制是自动的,不需要用户干预。在网络分区从系统自动尝试重新连接到主系统并与其重新同步之后
#
# slaveof <masterip> <masterport>


# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
# 如果主服务器受密码保护(使用下面的“RequirePass”配置指令),则可以在启动复制同步过程之前通知
# 从服务器进行身份验证,否则主服务器将拒绝从服务器请求
# (大概:如果master设置了密码(通过下面的 "requirepass" 选项来配置),
   那么slave在开始同步之前必须进行身份验证,否则它的同步请求会被拒绝)
#
# masterauth <master-password>

# When a slave loses its connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
#
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
#    still reply to client requests, possibly with out of date data, or the
#    data set may just be empty if this is the first synchronization.
#
# 2) if slave-serve-stale-data is set to 'no' the slave will reply with
#    an error "SYNC with master in progress" to all the kind of commands
#    but to INFO and SLAVEOF.
# 当一个slave失去和master的连接,或者同步正在进行中,slave的行为有两种可能:
# 1) 如果 slave-serve-stale-data 设置为 "yes" (默认值),slave会继续响应客户端请求,
#    可能是正常数据,也可能是还没获得值的空数据。 
# 2) 如果 slave-serve-stale-data 设置为 "no",slave会回复"正在从master同步
#   (SYNC with master in progress)"来处理各种请求,除了 INFO 和 SLAVEOF 命令。
#
slave-serve-stale-data yes

# You can configure a slave instance to accept writes or not. Writing against
# a slave instance may be useful to store some ephemeral data (because data
# written on a slave will be easily deleted after resync with the master) but
# may also cause problems if clients are writing to it because of a
# misconfiguration.
# 您可以将从属实例配置为接受写操作或不接受写操作。对从属实例进行写入可能有助于存储一些临时数据
#(因为在与主服务器重新同步之后,在从属服务器上写入的数据很容易被删除)
# 但如果客户端由于配置错误而向其写入数据,则也可能导致问题
#
# Since Redis 2.6 by default slaves are read-only.
# 因为redis 2.6默认情况下从服务器是只读的
#
# Note: read only slaves are not designed to be exposed to untrusted clients
# on the internet. It's just a protection layer against misuse of the instance.
# Still a read only slave exports by default all the administrative commands
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
# security of read only slaves using 'rename-command' to shadow all the
# administrative / dangerous commands.
# 注意:只读从服务器设计为不暴露于Internet上不受信任的客户端。它只是一个防止误用实例的保护层,
# 默认情况下还是一个只读的从系统导出所有的管理命令,如config、debug等。在一定程度上,您可以
# 使用“rename command”隐藏所有管理/危险命令来提高只读从属服务器的安全性
slave-read-only yes

# Replication SYNC strategy: disk or socket.(复制同步策略:磁盘或套接字)
#
# -------------------------------------------------------
# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY
# (警告:目前正在进行无盘复制实验)
# -------------------------------------------------------
#
# 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:
# (新的从服务器和重新连接的从服务器无法继续复制过程,只是接收到差异,需要执行所谓的“完全同步”。
#  RDB文件从主服务器传输到从服务器,可以通过两种不同的方式进行传输)
#
# 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.
# (磁盘备份:redis主机创建一个新进程,将RDB文件写入磁盘。稍后,父进程将文件增量传输到从进程)
# 2) Diskless: The Redis master creates a new process that directly writes the
#              RDB file to slave sockets, without touching the disk at all.
#(无盘:redis主进程创建一个新进程,该进程直接将RDB文件写入从套接字,而不接触al上的磁盘)
#
# 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.
# 使用磁盘备份复制,在生成RDB文件的同时,可以在生成RDB文件的当前子级完成工作后,
# 将更多的从服务器排队并与RDB文件一起使用。如果使用无盘复制,则一旦传输开始,
# 新的从机将进入队列,当当前的从机终止时,新的传输将开始
#
# 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.
# 当启用无盘复制时,可以配置服务器等待的延迟,以便生成通过套接字将RDB传输到从系统的子系统
#
# 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.
# 这一点很重要,因为一旦传输开始,就不可能为到达的新从属服务器提供服务,因为新从属服务器将排队等待
# 下一个RDB传输,因此服务器将等待一个延迟,以便让更多从属服务器到达
#
# 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.
# 延迟以秒为单位指定,默认为5秒。要完全禁用它,只需将其设置为0秒,传输将尽快开始
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.
# 从服务器以预先定义的间隔向服务器发送ping。可以使用repl-ping-u slave-period选项更改此间隔。
# 默认值为10秒
#
# 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-ping-slave-period指定的值非常重要,否则每次主站和从站之间的流量较低时都会检测到超时
#(大概:确保这个值比 repl-ping-slave-period 大,否则master和slave之间的传输过期时间比预想的要短)
# 默认值60秒。
# 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.
# 如果选择“是”,Redis将使用较少数量的TCP数据包和较少的带宽将数据发送到从设备。 
# 但这可能会增加数据在从属端出现的延迟,使用默认配置的Linux内核最多可达40毫秒。
#
# 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.
# 值为0表示永远不会释放积压
#
# repl-backlog-ttl 3600

# The slave priority is an integer number published by Redis in the INFO output.
# It is used by Redis Sentinel in order to select a slave to promote into a
# master if the master is no longer working correctly.
# 从属优先级是Redis在INFO输出中发布的整数。如果主服务器不再正常工作,
# Redis Sentinel将使用它来选择要升级为主服务器的从服务器
#
# A slave with a low priority number is considered better for promotion, so
# for instance if there are three slaves with priority 10, 100, 25 Sentinel will
# pick the one with priority 10, that is the lowest.
# 具有低优先级编号的从站被认为更适合升级,因此,例如,如果有三个优先级为10,100的从站,
# 25 Sentinel将选择优先级为10的从站,即最低的
#
# However a special priority of 0 marks the slave as not able to perform the
# role of master, so a slave with priority of 0 will never be selected by
# Redis Sentinel for promotion.
# 但是,特殊优先级为0表示从站无法执行主站角色,因此Redis Sentinel永远不会选择优先级为0的从站进行升级
#
# By default the priority is 100.
# 默认情况下,优先级为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.
# 如果连接的连接少于N个,滞后小于或等于M秒,则主设备可以停止接受写入。
#
# The N slaves need to be in "online" state.
# N个slaves需要处于“在线”状态。
#
# 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.
# 以秒为单位的延迟(必须<=指定值)是根据从从站接收的最后一次ping计算的,通常每秒发送一次。
#
# 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.
# 此选项不保证N个副本将接受写入,但会限制丢失写入的窗口,以防有足够的从站可用,达到指定的秒数。
#
# For example to require at least 3 slaves with a lag <= 10 seconds use:
# 例如,要求至少3个具有滞后<= 10秒的从属使用:
#
# min-slaves-to-write 3
# min-slaves-max-lag 10
#
# Setting one or the other to 0 disables the feature.
# 将一个或另一个设置为0将禁用该功能。
#
# By default min-slaves-to-write is set to 0 (feature disabled) and
# min-slaves-max-lag is set to 10.
# 默认情况下,min-slaves-to-write设置为0(禁用功能),min-slaves-max-lag设置为10
#
# A Redis master is able to list the address and port of the attached
# slaves in different ways. For example the "INFO replication" section
# offers this information, which is used, among other tools, by
# Redis Sentinel in order to discover slave instances.
# Another place where this info is available is in the output of the
# "ROLE" command of a masteer.
# Redis主站能够以不同方式列出所连接从站的地址和端口。 例如,“INFO复制”部分提供此信息,
# Redis Sentinel使用该信息以及其他工具来发现从属实例。 此信息可用的另一个地方是在
# masteer的“ROLE”命令的输出中
#
# The listed IP and address normally reported by a slave is obtained
# in the following way:
# 通常由从站报告的列出的IP和地址通过以下方式获得
#
#   IP: The address is auto detected by checking the peer address
#   of the socket used by the slave to connect with the master.
#   (IP:通过检查从设备与主设备连接的套接字的对等地址,自动检测地址。)
#
#   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.
# 但是,当使用端口转发或网络地址转换(NAT)时,从站实际上可以通过不同的IP和端口对访问。
# 从站可以使用以下两个选项,以便向其主站报告一组特定的IP和端口,以便INFO和ROLE都报告这些值。 
#
# There is no need to use both the options if you need to override just
# the port or the IP address.
# 如果只需要覆盖端口或IP地址,则无需使用这两个选项。
#
# slave-announce-ip 5.5.5.5
# slave-announce-port 1234

################################## SECURITY(安全) ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
# 在处理任何其他命令之前,要求客户端发出AUTH <PASSWORD>
# (大概:要求客户端在处理任何命令时都要验证身份和密码)
# 这在您不信任其他人可以访问运行redis-server的主机的环境中可能很有用
# (大概:这在你信不过来访者时很有用。)
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
# 为了向后兼容的话,这段应该注释掉。而且大多数人不需要身份验证(例如:它们运行在自己的服务器上。)
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
# 警告:因为Redis太快了,所以居心不良的人可以每秒尝试150k的密码来试图破解密码。 
# 这意味着你需要一个高强度的密码,否则破解太容易了。

# requirepass foobared(要求通过foobared)
requirepass hdhaharedis

# Command renaming.(命令重命名)
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
# 可以在共享环境中更改危险命令的名称。 例如,可以将CONFIG命令重命名为难以猜测的内容,
# 以便它仍可用于内部使用工具,但不适用于一般客户端。
# (在共享环境下,可以为危险命令改变名字。比如,你可以为 CONFIG 改个其他不太容易猜到的名字,
#   这样你自己仍然可以使用,而别人却没法做坏事了。 )
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possible to completely kill a command by renaming it into
# an empty string:
# 也可以通过将命令重命名为空字符串来完全终止命令:
#(大概:甚至也可以通过给命令赋值一个空字符串来完全禁用这条命令:)
#
# rename-command CONFIG ""
#
# Please note that changing the name of commands that are logged into the
# AOF file or transmitted to slaves may cause problems.
# 请注意,更改登录到AOF文件或传输到从站的命令名称可能会导致问题。

################################### LIMITS(限制) ####################################

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
# 同时设置连接客户端的最大数量。 默认情况下,此限制设置为10000个客户端,
# 但是如果Redis服务器无法将进程文件限制配置为允许指定的限制,
# 则允许的最大客户端数将设置为当前文件限制减去32(因为Redis保留了 内部使用的文件描述符很少)
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
# 达到限制后,Redis将关闭所有发送错误“最大客户端数量”的新连接  
#
# maxclients 10000

# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
# according to the eviction policy selected (see maxmemory-policy).
# 不要使用超过指定字节数的内存。当达到内存限制时,Redis将尝试根据所选的逐出策略删除密钥(请参阅maxmemory-policy)。
# (大概:不要用比设置的上限更多的内存。一旦内存使用达到上限,Redis会根据选定的回收策略(参见:maxmemmory-policy)删除
# key)  
#   
# If Redis can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Redis will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
# 如果因为删除策略问题Redis无法删除key,或者策略设置为 "noeviction",Redis会回复需要更多内存的错误信息给命令。
#  例如,SET,LPUSH等等。但是会继续合理响应只读命令,比如:GET。    
#
# This option is usually useful when using Redis as an LRU cache, or to set
# a hard memory limit for an instance (using the 'noeviction' policy).
# 在使用Redis作为LRU缓存,或者为实例设置了硬性内存限制的时候(使用 "noeviction" 策略)的时候,这个选项还是满有用的。
#   
# WARNING: If you have slaves attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the slaves are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of slaves is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
# 警告:当一堆slave连上达到内存上限的实例的时候,响应slave需要的输出缓存所需内存不计算在使用内存当中。 
# 这样当请求一个删除掉的key的时候就不会触发网络问题/重新同步的事件,然后slave就会收到一堆删除指令,直到数据库空了为止。
#
# In short... if you have slaves attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
# 简而言之,如果你有slave连上一个master的话,那建议你把master内存限制设小点儿,确保有足够的系统内存用作输出缓存。
#   (如果策略设置为"noeviction"的话就不无所谓了 )。
# maxmemory <bytes>

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
# 内存策略:如果达到内存限制了,Redis如何删除key。你可以在下面五个策略里面选   
# 1.volatile-lru -> 根据LRU算法生成的过期时间来删除。
# 2.allkeys-lru -> 根据LRU算法删除任何key。 
# 3.volatile-random -> 根据过期设置来随机删除key。
# 4.allkeys->random -> 无差别随机删。
# 5.volatile-ttl -> 根据最近过期时间来删除(辅以TTL)
# noeviction -> 谁也不删,直接在写操作时返回错误。
#   
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key according 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
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
# 注意:对所有策略来说,如果Redis找不到合适的可以删除的key都会在写操作时返回一个错误。 
#    
#
#       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
# 在撰写之日,这些命令是:
#        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 and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can tune it for speed or
# accuracy. For default Redis will check five keys and pick the one that was
# used less recently, you can change the sample size using the following
# configuration directive.
# LRU和最小TTL算法的实现都不是很精确,但是很接近(为了省内存),所以你可以用样例做测试。 
# LRU和最小TTL算法不是精确的算法,而是近似算法(为了节省内存),因此您可以调整它以获得速度或精度。
# 默认情况下,Redis将检查五个键并选择最近使用的键,您可以使用以下配置指令更改样本大小你可以通过下
# 面的配置项来设置样本的个数。   
#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs a bit more CPU. 3 is very fast but not very accurate.
# 默认值为5会产生足够好的结果。 10近似非常接近真实的LRU但是花费更多的CPU。 3非常快但不是很准确。

# maxmemory-samples 5

############################## APPEND ONLY MODE(仅附加模式/纯累加模式)###############################

# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
# 默认情况下,Redis以异步方式将数据集转储到磁盘上。 此模式在许多应用程序中都足够好,
# 但Redis进程或停电的问题可能导致几分钟的写入丢失(取决于配置的保存点)   
# (大概:默认情况下,Redis是异步的把数据导出到磁盘上。这种情况下,当Redis挂掉的时候,最新的数据就丢了)
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
# 仅附加文件是一种备用持久性模式,可提供更好的持久性。 例如,使用默认数据fsync策略(请参阅配置文件中的后续内容)
# Redis在服务器断电等戏剧性事件中只会丢失一秒写入,如果Redis进程本身出现问题,则会丢失一次,但是 操作系统仍然正常运行。  
# 
#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
# 可以同时启用AOF和RDB持久性而不会出现问题。如果在启动时启用AOF,Redis将加载AOF,即具有更好耐久性保证的文件。   
#
# (如果不希望丢掉任何一条数据的话就该用纯累加模式:一旦开启这个模式,Redis会把每次写入的数据在接收后都写入      #appendonly.aof 文件。 每次启动时Redis都会把这个文件的数据读入内存里。 )   
#   
# Please check http://redis.io/topics/persistence for more information.
# 请查看http://redis.io/topics/persistence以获取更多信息。
appendonly no

# The name of the append only file (default: "appendonly.aof")
# 仅附加文件的名称(默认值:“appendonly.aof”)
appendfilename "appendonly.aof"

# The fsync() call tells the Operating System to actually write data on disk
# instead of waiting for more data in the output buffer. Some OS will really flush
# data on disk, some other OS will just try to do it ASAP.
#  fsync() 请求操作系统马上把数据写到磁盘上,不要再等了
#  有些操作系统会真的把数据马上刷到磁盘上;有些则要磨蹭一下,但是会尽快去做。 
#    
# Redis supports three different modes:
# Redis支持三种不同的模式:  
# 1.no:不要立刻刷,只有在操作系统需要刷的时候再刷。比较快。
# 2.always:每次写操作都立刻写入到aof文件。慢,但是最安全。
# 3.everysec:每秒写一次。折衷方案。  
#   
#   
#   
#   
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log. Slow, Safest.
# everysec: fsync only one time every second. Compromise.
#
# The default is "everysec", as that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
# "no" that will let the operating system flush the output buffer when
# it wants, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting),
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
#
# More details please check the following article:
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec".
# 默认的 "everysec" 通常来说能在速度和数据安全性之间取得比较好的平衡。 
# 如果你真的理解了这个意味着什么,那么设置"no"可以获得更好的性能表现(如果丢数据的话,则只能拿到一个不是很新的快照); 
# 或者相反的,你选择 "always" 来牺牲速度确保数据安全、完整。 
# 如果拿不准,就用 "everysec"                                      

# appendfsync always
appendfsync everysec
# appendfsync no

# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
# 如果AOF的同步策略设置成 "always" 或者 "everysec",那么后台的存储进程
#(后台存储或写入AOF日志)会产生很多磁盘I/O开销。 
# 某些Linux的配置下会使Redis因为 fsync() 而阻塞很久。 
# 注意,目前对这个情况还没有完美修正,甚至不同线程的 fsync() 会阻塞我们的 write(2) 请求。
                                     
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
# 为了缓解这个问题,可以用下面这个选项。它可以在 BGSAVE 或 BGREWRITEAOF 处理时阻止 fsync()。
#
# This means that while another child is saving, the durability of Redis is
# the same as "appendfsync none". In practical terms, this means that it is
# possible to lose up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
# 这就意味着如果有子进程在进行保存操作,那么Redis就处于"不可同步"的状态。 
# 这实际上是说,在最差的情况下可能会丢掉30秒钟的日志数据。(默认Linux设定) 
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.
# 如果你有延迟的问题那就把这个设为 "yes",否则就保持 "no",这是保存持久数据的最安全的方式。 
no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size grows by the specified percentage.
# 自动重写AOF文件 
# 如果AOF日志文件大到指定百分比,Redis能够通过 BGREWRITEAOF 自动重写AOF日志文件。
#
#
#
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (if no rewrite has happened since the restart, the size of
# the AOF at startup is used).
# 工作原理:Redis记住上次重写时AOF日志的大小(或者重启后没有写操作的话,那就直接用此时的AOF文件), 
# 基准尺寸和当前尺寸做比较。如果当前尺寸超过指定比例,就会触发重写操作。 
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
# (大概:你还需要指定被重写日志的最小尺寸,这样避免了达到约定百分比但尺寸仍然很小的情况还要重写。 
# 指定百分比为0会禁用AOF自动重写特性。)
#
# Specify a percentage of zero in order to disable the automatic AOF
# rewrite feature.
# 指定零的百分比以禁用自动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).
# 当AOF数据被加载回内存时,可能会发现在Redis启动过程中最后截断AOF文件。 
# 当Redis运行崩溃的系统时,尤其是在没有data = ordered选项的情况下挂载ext4文件系统时,
# 可能会发生这种情况(但是当Redis本身崩溃或中止但操作系统仍能正常工作时,这种情况不会发生)。
#
#
# 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.
# 发生这种情况时Redis可以退出,或者加载尽可能多的数据(现在是默认值),如果发现AOF文件在结尾被截断
# ,则启动。 以下选项控制此行为。
#
# 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.
# 如果将aof-load-truncated设置为yes,则会加载截断的AOF文件,并且Redis服务器会开始
# 发出日志以通知用户该事件。 否则,如果该选项设置为no,则服务器将中止并显示错误并拒绝启动。
# 当该选项设置为no时,用户需要使用“redis-check-aof”实用程序修复AOF文件,然后才能重新启动服务器。
#
# 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文件在中间被破坏,服务器仍将退出并显示错误。
# 此选项仅在Redis尝试从AOF文件中读取更多数据但不会找到足够的字节时适用。
aof-load-truncated yes

################################ LUA SCRIPTING(lua脚本))  ###############################

# 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

################################ REDIS CLUSTER(CLUSTER)  ###############################
#redis3.0版本之后才有redis集群,在服务端做的(jedis客户端)
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 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.
# 警告实验:Redis Cluster被认为是稳定的代码,但为了将其标记为“成熟”,我们需要等待一小部分用户将其部署到生产环境中。
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# 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:
# 普通Redis实例不能是Redis群集的一部分; 只有作为集群节点启动的节点才可以。
# 要将Redis实例作为群集节点启动,请启用群集支持,取消注释以下内容:
# 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.
# 每个群集节点都有一个群集配置文件。 此文件无意手动编辑。 它由Redis节点创建和更新。
# 每个Redis群集节点都需要不同的群集配置文件。 确保在同一系统中运行的实例没有重叠的群集配置文件名。
#
# 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:
# slave没有简单的方法来实际测量其“数据年龄”,因此执行以下两项检查:
#
# 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.

################################## 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).
# Redis Slow Log是一个记录超过指定执行时间的查询的系统。 执行时间不包括I / O操作,
# 例如:连接客户端,发送响应数据等。只计算命令运行的实际时间
#(这是唯一一种命令运行线程阻塞而无法同时为其他请求服务的场景) 
# 
#
# 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.
# 下面的时间单位是微秒,所以1000000就是1秒。注意,负数时间会禁用慢查询日志,而0则会强制记录所有命令。 

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 RESET回收慢速日志使用的内存。
# 这个长度没有限制。只要有足够的内存就行。你可以通过 SLOWLOG RESET 来释放内存。(译者注:日志居然是在内存里的Orz) 
slowlog-max-len 128

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

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

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我先来一碗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值