redis 6.0.9配置文件详解

以下为博主使用redis时,抽空做的配置文件翻译,水平有限,可能存在错误理解。发现了请通知博主修改,毕竟知识这东西不能糊涂,没人看还好,就怕误导新人。

redis.conf

启动方式

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

INCLUDES


################################## INCLUDES ###################################

# 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.
#
# Note that 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.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
# 设置启动指令前的配置文件、后加载的配置文件会覆盖先加载的配置文件配置
# include /path/to/local.conf
# include /path/to/other.conf

MODULES


################################## MODULES #####################################

# Load modules at startup. If the server is not able to load modules
# it will abort. It is possible to use multiple loadmodule directives.
# 在启动时加载模块。如果服务器无法加载模块它将中止。可以使用多个loadmodule指令。
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so

网络

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all available network interfaces on the host machine.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
# 
# 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 on the
# IPv4 loopback interface address (this means Redis will only be able to
# accept client connections from the same host that it is running on).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT OUT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 允许该ip端口连接到redis服务、可配置多个。bind 0.0.0.0设置允许通过所有IP地址连接。
# 一台服务器在不同的网段的ip地址是不同的,如果我们只设置了允许在A网段下的ip地址,那么在B网段
# 下的所有服务器即使拥有正确的账号密码也是无法连接redis服务的,生产环境必须设定死ip
bind 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 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.
#
# 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.
#是否开启保护模式,默认开启。要是配置里没有指定bind和密码。开启该参数后,redis只会本地进行访问,拒绝外部访问
protected-mode yes

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
# 启动端口
port 6379

# TCP listen() backlog.
#
# In high requests-per-second environments you need a high backlog in order
# to avoid slow clients connection 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.
# tcp积压工作数(默认511)、会被linux的内核/proc/sys/net/core/somaxconn参数
#(默认:128)强行限制(即该值不会大于somaxconn值)
tcp-backlog 128

# 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 套接字支持
# unixsocket /tmp/redis.sock
# unix 套接字权限
# unixsocketperm 700

# Close the connection after a client is idle for N seconds (0 to disable)
# 当连接空闲时间超过N秒后关闭连接(设置为0,标识服务端永不主动关闭客户端连接)
timeout 160

# TCP keepalive.
# 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 ACKs(确认消息) 向掉线客户端沟通,这有两个好处
#
# 1) Detect dead peers.
# 及时发现宕机的客户端
# 2) Force network equipment in the middle to consider the connection to be
#    alive.
# 确保连接设备存活,
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# 在linux设备上,该配置周期单位为秒,需要注意的是关闭一个连接需要两个周期。)
# 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.
tcp-keepalive 300

TLS/SSL配置

################################# TLS/SSL #####################################

# By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration
# directive can be used to define TLS-listening ports. To enable TLS on the
# default port, use:
# 默认情况下,TLS/SSL 是关闭的。如果开启,则tls-port配置的端口会用作TLS默认端口(意思应该是配
# 置了tls-port的端口,同时就打开了TLS/SSL服务)
# port 0
# tls-port 6379

# Configure a X.509 certificate and private key to use for authenticating the
# server to connected clients, masters or cluster peers.  These files should be
# PEM formatted.
# 使用一个 X.509 证书与密钥来实现客户端连接主节点或者集群的认证过程。这些文件应该是PEM格式
#
# tls-cert-file redis.crt 
# 证书
# tls-key-file redis.key
# 密钥

# Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange:
# 配置DHfile文件来启动DH密钥交换
#
# tls-dh-params-file redis.dh

# Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL
# clients and peers.  Redis requires an explicit configuration of at least one
# of these, and will not implicitly use the system wide configuration.
# 配置一个CA文件或者包含CA文件的文件夹来认证客户端的TLS/SSL连接。这两项配置
# 你至少需要配置一个,因为redis没有为这个做系统默认配置
#
# tls-ca-cert-file ca.crt
# CA文件
# tls-ca-cert-dir /etc/ssl/certs
# CA文件夹地址

# By default, clients (including replica servers) on a TLS port are required
# to authenticate using valid client side certificates.
# 默认情况下,客户端(包含从节点)使用TLS的时候必须进行证书认证
#
# If "no" is specified, client certificates are not required and not accepted.
# 如果配置为no,则客户端证书不是必要的
# If "optional" is specified, client certificates are accepted and must be
# valid if provided, but are not required.
# 如果配置为 optional 则客户端证书有则必须校验通过,或者没有。
#
# tls-auth-clients no
# tls-auth-clients optional

# By default, a Redis replica does not attempt to establish a TLS connection
# with its master.
# 默认情况下,从节点不会以TLS的方式连接主节点
#
# Use the following directive to enable TLS on replication links.
# 从节点同步数据使用TLS
#
# tls-replication yes

# By default, the Redis Cluster bus uses a plain TCP connection. To enable
# TLS for the bus protocol, use the following directive:
# 默认情况下,redis集群使用TCP连接,要启用TLS连接的话,配置为yes
#
# tls-cluster yes

# Explicitly specify TLS versions to support. Allowed values are case insensitive
# and include "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3" (OpenSSL >= 1.1.1) or
# any combination. To enable only TLSv1.2 and TLSv1.3, use:
# 明确指定TLS版本,可以同时指定多个版本(版本大于1.1.1)
# 
# tls-protocols "TLSv1.2 TLSv1.3"

# Configure allowed ciphers.  See the ciphers(1ssl) manpage for more information
# about the syntax of this string.
# 配置允许访问的密钥,关于更多的密钥信息请参考 ciphers(1ssl) 手册
#
# Note: this configuration applies only to <= TLSv1.2.
#
# tls-ciphers DEFAULT:!MEDIUM

# Configure allowed TLSv1.3 ciphersuites.  See the ciphers(1ssl) manpage for more
# information about the syntax of this string, and specifically for TLSv1.3
# ciphersuites.
#
# tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256

# When choosing a cipher, use the server's preference instead of the client
# preference. By default, the server follows the client's preference.
#
# tls-prefer-server-ciphers yes

# By default, TLS session caching is enabled to allow faster and less expensive
# reconnections by clients that support it. Use the following directive to disable
# caching.
#
# tls-session-caching no

# Change the default number of TLS sessions cached. A zero value sets the cache
# to unlimited size. The default size is 20480.
#
# tls-session-cache-size 5000

# Change the default timeout of cached TLS sessions. The default timeout is 300
# seconds.
#
# tls-session-cache-timeout 60

GENERAL 基础设置

################################# GENERAL #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# 是否后台运行
daemonize no

# 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
#                        requires "expect stop" in your upstart job config
#   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 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.
#
# 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".
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
# pid文件,redis启动创建,关闭删除。指定不指定无所谓,不指定的话依然能够正常运行(因为会创建默认文件)/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 debug

# 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
# 指定日志文件、默认是 /dev/null
logfile ""

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# 系统日志是否启动,就是redis核心进程日志
# 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
# 数据库数量,默认选择数据库0,可以用 select 0/dbid 选择数据库。dbid取值范围为 [0,database-1] 间取整数
databases 16

# By default Redis shows an ASCII art logo only when started to log to the
# standard output and if the standard output is a TTY. Basically this means
# that normally a logo is displayed only in interactive sessions.
# 
# However it is possible to force the pre-4.0 behavior and always show a
# ASCII art logo in startup logs by setting the following option to yes.
# redis的log显示与否。这里没整明白说的是什么。唯一知道的就是不管你怎么设置,启动日志必定显示logo。
 always-show-logo yes

SNAPSHOTTING快照设置

################################ 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 behavior will be to save:  
#   以下配置是基于一个整体配置(3个小配置)来说明的没有照原文翻译,便于理解   在进行一次数据持久化后的第一个键产生开始
#   after 900 sec (15 min) if at least 1 key changed         如果只有1-9个键产生,15分钟后进行一次数据持久化
#   after 300 sec (5 min) if at least 10 keys changed        如果有10-50个键产生,5分钟后进行一次数据持久化
#   after 60 sec if at least 10000 keys changed              如果有10000-(+inf)正无穷个键产生,60秒进行一次数据持久化。  每次数据持久化会刷新所有小配置的⏲计时
#															正常的关闭reids是会进行数据持久化操作的,所以严禁通过杀死进程的方式进行关闭操作
# 
#   Note: you can disable saving completely by commenting out all "save" lines.
#	你可以通过注释掉所有保存来使得redis不进行磁盘保存,不建议。这样的话redis一死数据完全丢失。一般还是需要维持数据持久化的
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#	可以通过手动使用指令的方式进行数据持久化操作,直接输入 save 。后面不用加东西,save "" 指令是错误的
#   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.
# 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.
#
# 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写操作,(这样会保证redis持久化出问题不会造成大量数据丢失,因为一旦出现问题,不会再产生新数据入库,一旦入库对于用户而言就是正常的服务。)
stop-writes-on-bgsave-error yes

# Compress string objects using LZF when dump .rdb databases?
# By default compression is enabled 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.
# rdb持久化的时候启动压缩
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.
# 从版本5开始,每个rdb文件末尾会附加 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
# rdb文件
dbfilename dump.rdb

# Remove RDB files used by replication in instances without persistence
# enabled. By default this option is disabled, however there are environments
# where for regulations or other security concerns, RDB files persisted on
# disk by masters in order to feed replicas, or stored on disk by replicas
# in order to load them for the initial synchronization, should be deleted
# ASAP. Note that this option ONLY WORKS in instances that have both AOF
# and RDB persistence disabled, otherwise is completely ignored.
# 开启删除同步rdb文件,默认关闭。大致意思是采用磁盘文件缓冲数据同步时产生的RDB文件是否删除。一般
# 不建议删除。有些场景下,出于服务器安全的考虑需要删除。
#
# An alternative (and sometimes better) way to obtain the same effect is
# to use diskless replication on both master and replicas instances. However
# in the case of replicas, diskless is not always an option.
# 还有一种办法就是直接采用内存同步,不经过RDB文件中间缓冲数据。这样就不会产生RDB同步文件,那么这个配置也将失去意义
rdb-del-sync-files no

# The working directory.
# 
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 数据文件会以指定文件名保存在这个文件夹里面
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# 工作空间文件夹,redis的AOF文件与RDB文件保存地址
dir /data/redis

REPLICATION复制、主从设置

################################# REPLICATION #################################
################################# 复制---主从 #################################

# Master-Replica replication. Use replicaof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replication.
#
#   +------------------+      +---------------+
#   |      Master      | ---> |    Replica    |
#   | (receive writes) |      |  (exact copy) |
#   +------------------+      +---------------+
#   主体(主节点)     ----->     副本(从节点)
#####以下说明,采用主节点、从节点说明##########################################
# 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 replicas.
# 1) 主从复制是异步的。后面这个但是搞得我一脸懵逼
# 2) Redis replicas 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) Replication is automatic and does not need user intervention. After a
#    network partition replicas automatically try to reconnect to masters
#    and resynchronize with them.
#    复制是自动的,不需要用户再次手动的干预(就是内部代码写死的)
# 从什么ip:port下复制数据(就是设置主节点的ip端口)
# replicaof <masterip> <masterport>

# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the replica to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the replica request.
# 大致意思就是如果主节点需要密码校验,你个从节点就必须输入密码,不然主节点就不带你玩,就无法复制主节点数据
# #主节点认证密钥:
# masterauth <master-password>
#
# However this is not enough if you are using Redis ACLs (for Redis version
# 6 or greater), and the default user is not capable of running the PSYNC
# command and/or other commands needed for replication. In this case it's
# better to configure a special user to use with replication, and specify the
# masteruser configuration as such:
# 如果使用的ACLs版本的redis(redis6以后的)。默认用户没有PSYNC权限,所以最好配置一个专门的用户用来做数据复制
# 拥有复制权限的用户
# masteruser <username>
#
# When masteruser is specified, the replica will authenticate against its
# master using the new AUTH form: AUTH <username> <password>.
# 当配置了masteruser账户是,从节点将使用这个账号进行认证,(不明白这句话放在这里的意义是什么)
#
# When a replica loses its connection with the master, or when the replication
# is still in progress, the replica can act in two different ways:
# 当从节点失去与主节点的连接时,或者当从节点正在复制的时候。这个从节点有两种运行方案

#
# 1) if replica-serve-stale-data is set to 'yes' (the default) the replica 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.
#    如果设置为yes、那么从节点会响应客户端请求。如果这是第一次同步数据,数据集可能为空
#
# 2) If replica-serve-stale-data is set to 'no' the replica will reply with
#    an error "SYNC with master in progress" to all commands except:
#    INFO, REPLICAOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG, SUBSCRIBE,
#    UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, COMMAND, POST,
#    HOST and LATENCY.
#   如果设置为no,那么从节点会回复"SYNC with master in progress",当除了《INFO, REPLICAOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG, SUBSCRIBE,
#    UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, COMMAND, POST,
#    HOST and LATENCY》指令外的所有指令,就是只能做配置,调试之类的操作,数据操作就别想了
#
replica-serve-stale-data yes

# You can configure a replica instance to accept writes or not. Writing against
# a replica instance may be useful to store some ephemeral data (because data
# written on a replica 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 replicas are read-only.
# 从redis 2.6版本开始从节点设置为只读
#
# Note: read only replicas 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 replica 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 replicas using 'rename-command' to shadow all the
# administrative / dangerous commands.
# 大致意思是:从节点只读设置不是为了向未授权的客户端公开数据,主要是为了防止实例滥用的保护层
#(说读写分离主要是为了提高性能的打脸了,读写分离很重要。但官方可不是为了提高性能而设计的只读、主要是为了安全性)
# 由于默认情况下从节点依然可以使用部分配置、调试指令。故可以采用重命名指令名字的方式提高从节点的安全性
# 
# 从节点配置只读
replica-read-only yes

# Replication SYNC strategy: disk or socket.
# 复制同步策略:磁盘或者套接字
#
# New replicas and reconnecting replicas 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
# replicas.
# 如果是新连接的从节点,或者断线重连的从节点无法使用部分同步(因为存在严重数据丢失的风险)就会执行
# 全量同步,主节点会生产RDB文件
#
# 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 replicas incrementally.
# 方案一:磁盘复制:主节点创建一个新进程在磁盘将数据写入RDB文件,再由主节点发送给从节点进行输入同步
# 2) Diskless: The Redis master creates a new process that directly writes the
#   无磁盘方式 RDB file to replica sockets, without touching the disk at all.
#
# 方案二:主节点直接将数据写进套接字发送给从节点进行数据同步
# With disk-backed replication, while the RDB file is generated, more replicas
# 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 replicas arriving will be queued and a new
# transfer will start when the current one terminates.
# 如果使用磁盘复制的话,主节点能够在一个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
# replicas will arrive and the transfer can be parallelized.
# 如果使用无磁盘方式的话、主节点会等所有的从节点都连接上再同步数据
#
# With slow disks and fast (large bandwidth) networks, diskless replication
# works better.
# 网络快磁盘慢的就用无磁盘复制、一般多个redis部署在一个局域网络。相互之间的网络通信速度都很快
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 replicas.
# 当使用无磁盘复制的时候,可以合理的配置等待时间以便通过套接字的方式复制数据给从节点
#
# This is important since once the transfer starts, it is not possible to serve
# new replicas arriving, that will be queued for the next RDB transfer, so the
# server waits a delay in order to let more replicas 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.
# 传输延迟单位是秒,默认5秒,设置为0,则标识无等待直接同步数据
#(这里最好建议别设置为0,因为一旦进行数据传输的话,新的同步请求会等待这一次完成后再进行,几乎永远不会有多个子节点同步同步数据)
repl-diskless-sync-delay 5

# -----------------------------------------------------------------------------
# WARNING: RDB diskless load is experimental. Since in this setup the replica
# does not immediately store an RDB on disk, it may cause data loss during
# failovers. RDB diskless load + Redis modules not handling I/O reads may also
# cause Redis to abort in case of I/O errors during the initial synchronization
# stage with the master. Use only if your do what you are doing.
# 警告:无磁盘数据同步是实验性的。由于这中设置中,从节点不会立即将数据存在磁盘上,如果此时发生故障会导致数据的丢失。
# redis无磁盘同步与redis无I/O读也会在reids发生I/O错误的时候终止数据同步,因此你最好再三确认你的选择。
# -----------------------------------------------------------------------------
#
# Replica can load the RDB it reads from the replication link directly from the
# socket, or store the RDB to a file and read that file after it was completely
# received from the master.
# 从节点可以直接从网络套接字中获取数据,也可以先将所有套接字里面的数据存在本地文件后再从文件读取
#
# In many cases the disk is slower than the network, and storing and loading
# the RDB file may increase replication time (and even increase the master's
# Copy on Write memory and salve buffers).
# 通常情况下,磁盘比网络慢,RDB写入磁盘和加载磁盘获取RDB都会增加复制时间。
# 甚至会增加主节点在内存和缓冲区上复制和写入的时间
# However, parsing the RDB file directly from the socket may mean that we have
# to flush the contents of the current database before the full rdb was
# received. For this reason we have the following options:
# 然而直接从网络获取RDB文件再复制数据意味着我们必须在接收到完整的RDB文件之前先刷新当前redis数据
#
# "disabled"    - Don't use diskless load (store the rdb file to the disk first) 不使用无磁盘接收,先将数据保存成RDB文件进磁盘
# "on-empty-db" - Use diskless load only when it is completely safe.  当完全安全的情况下可以使用无磁盘接收
# "swapdb"      - Keep a copy of the current db contents in RAM while parsing 直接从套接字获取数据读取,在内存中保留数据副本,需要注意的是,一旦内存不够了,可能
#                 the data directly from the socket. note that this requires  面临OOM(内存溢出)异常导致redis宕机
#                 sufficient memory, if you don't have it, you risk an OOM kill.
repl-diskless-load disabled

# Replicas send PINGs to server in a predefined interval. It's possible to
# change this interval with the repl_ping_replica_period option. The default
# value is 10 seconds.
# 从节点可以根据指定是时间间隔发送ping请求确认网络通信正常。这个间隔时间可以通过 repl_ping_replica_period 设置,默认值是10秒
# repl-ping-replica-period 10

# The following option sets the replication timeout for:
#
# 1) Bulk transfer I/O during SYNC, from the point of view of replica.  对于从节点,一次数据同步I/O操作是一个过程。
# 2) Master timeout from the point of view of replicas (data, pings).   对于从节点有主节点超时
# 3) Replica 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-replica-period otherwise a timeout will be detected
# every time there is low traffic between the master and the replica. The default
# value is 60 seconds.
# 复制连接超时时间。这个值必须大于从节点的确认通信间隔时间,否则当主从之间没有数据同步操作的时候,会检测连接超时(既没有数据同步,定期ping的时间间隔又没到,超时时间一过,就认为连接超时了)
# repl-timeout 60

# Disable TCP_NODELAY on the replica socket after SYNC?
# 是否禁止复制tcp链接的 TCP_NODELAY 参数(大致就是带宽、内存消耗与速度的取舍,舍得用带宽与内存速度就快)。
#
# If you select "yes" Redis will use a smaller number of TCP packets and
# less bandwidth to send data to replicas. But this can add a delay for
# the data to appear on the replica 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 replica side will
# be reduced but more bandwidth will be used for replication.
# 如果你选择no,这个数据发送到从节点的时间会更小,但是会使用更多的带宽用作复制操作
#
# By default we optimize for low latency, but in very high traffic conditions
# or when the master and replicas are many hops away, turning this to "yes" may
# be a good idea.
# 默认情况下我们选择优化延迟,但是如果数据量很大的情况下或者当主节点与从节点经过多层跳转的情况下,建议开启。
#(这里不好说,首先要吐槽的是这个配置是反着来的,nodelay:无延迟选择yes,延迟更高。选择no,延迟更低)
# 而且yes的场景下,本来数据量就大了,有时候人家就是要尽快看到效果,你还建议选择yes,加高延迟,不讲道理。个人的观点是在生产过程中,根据自己的服务启具体运行情况设置
repl-disable-tcp-nodelay no

# Set the replication backlog size. The backlog is a buffer that accumulates
# replica data when replicas are disconnected for some time, so that when a
# replica wants to reconnect again, often a full resync is not needed, but a
# partial resync is enough, just passing the portion of data the replica
# missed while disconnected.
# 设置从节点 backlog 大小,这个东西是一个用作缓存的东西,当从节点下线后(假设宕机了一段时间)
# 这个 backlog 会一直保存从节点没有同步的数据,这样的话从节点一旦重新上线,只要复制这里面保存的数据就够了。
#
# The bigger the replication backlog, the longer the replica can endure the
# disconnect and later be able to perform a partial resynchronization.
# 这个值设置的越大,能够容忍从节点的下线时间就越长。
#
# The backlog is only allocated if there is at least one replica connected.
# 只有在至少有一个从节点连接的时候才会产生 backlog 文件
#
# repl-backlog-size 1mb

# After a master has no connected replicas 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 replica disconnected, for the backlog
# buffer to be freed.
# 当从节点下线超过一定时间后,这个 backlog 文件将会被清除。下面的配置就是配置这个时间的
#
# Note that replicas never free the backlog for timeout, since they may be
# promoted to masters later, and should be able to correctly "partially
# resynchronize" with other replicas: hence they should always accumulate backlog.
# 注意,副本永远不会因为超时而释放backlog,因为它们以后可能会被提升到主版本,并且应该能够正确地与其他副本“部分重新同步”:因此,它们应该始终积累 backlog。
#
# A value of 0 means to never release the backlog.
#
# repl-backlog-ttl 36000

# The replica priority is an integer number published by Redis in the INFO
# output. It is used by Redis Sentinel in order to select a replica to promote
# into a master if the master is no longer working correctly.
# 副本优先级,就是哨兵模式下,主节点宕机,从节点升级为主节点的优先级
#
# A replica with a low priority number is considered better for promotion, so
# for instance if there are three replicas with priority 10, 100, 25 Sentinel
# will pick the one with priority 10, that is the lowest.
# 优先级数字是越小的优先级越高, 10>25>100
#
# However a special priority of 0 marks the replica as not able to perform the
# role of master, so a replica with priority of 0 will never be selected by
# Redis Sentinel for promotion.
# 例外的是如果优先级别设置为0,则表示该从节点不适合作为主节点,则该从节点永远不会被哨兵选举成为父节点
#
# By default the priority is 100.
# 默认情况下,优先级是100
replica-priority 100

# It is possible for a master to stop accepting writes if there are less than
# N replicas connected, having a lag less or equal than M seconds.
# 当连接的从节点小于N个的时候,延迟M秒后,主节点停止写入操作,这样可以避免没有足够健康的从节点作为数据分压,数据持久性保护。
#
# The N replicas need to be in "online" state.
# 需要N个从节点保持在线状态
#
# The lag in seconds, that must be <= the specified value, is calculated from
# the last ping received from the replica, that is usually sent every second.
# 这个延迟时间以秒为单位。这个健康的从节点的ping延迟必须小于这个值才是正常的。
# 从从节点最后一个ping开始计算,这个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 replicas
# are available, to the specified number of seconds.
# 大致意思就是这个配置并不保证有这么多个认为健康的从节点了就一定能成功的进行写操作
# 但是在没有这么多健康从节点的情形下就会在指定延时后限制主节点的写操作。
#
# For example to require at least 3 replicas with a lag <= 10 seconds use:
# 主节点至少有3个ping延时小于10秒的从节点就能进行正常的写操作
#
# min-replicas-to-write 3
# min-replicas-max-lag 10
#
# Setting one or the other to 0 disables the feature.
# 设置1或另一个设置为0禁用这个特性。
#
# By default min-replicas-to-write is set to 0 (feature disabled) and
# min-replicas-max-lag is set to 10.
# 默认情况下,min-replicas-to-write设置为0,min-replicas-max-lag设置为10

# A Redis master is able to list the address and port of the attached
# replicas 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 replica instances.
# Another place where this info is available is in the output of the
# "ROLE" command of a master.
# 主节点可以以各种方式列出从节点列表。例如"INFO replication"指令就可以列出部分信息。哨兵就是通过主节点发现从节点的、
# 同时ROLE指令也可以显示从节点信息
#
# The listed IP address and port normally reported by a replica is
# obtained in the following way:
# 副本报告的所列的IP地址和端口通常可以通过以下方式获得
#
#   IP: The address is auto detected by checking the peer address
#   of the socket used by the replica to connect with the master.
#      地址自动检测的时候从节点会发送套接字给主节点
#
#   Port: The port is communicated by the replica during the replication
#   handshake, and is normally the port that the replica is using to
#   listen for connections.
#
# However when port forwarding or Network Address Translation (NAT) is
# used, the replica may actually be reachable via different IP and port
# pairs. The following two options can be used by a replica in order to
# report to its master a specific set of IP and port, so that both INFO
# and ROLE will report those values.
# 然而当使用了端口转发或者网络地址转换(NET)的时候,从节点可以使用下面这两个配置向主节点发送一组特定的IP:port
# 告诉主节点可以通过这组IP端口连接到从节点
#
# There is no need to use both the options if you need to override just
# the port or the IP address.
# 这两个参数都可以单独使用
#
# replica-announce-ip 5.5.5.5
# replica-announce-port 1234

KEYS TRACKING 键 跟踪

############################### KEYS TRACKING #################################
############################### 键 跟踪 #################################

# Redis implements server assisted support for client side caching of values.
# This is implemented using an invalidation table that remembers, using
# 16 millions of slots, what clients may have certain subsets of keys. In turn
# this is used in order to send invalidation messages to clients. Please
# check this page to understand more about the feature:
# Redis实现了对客户端值缓存的服务器辅助支持。这是使用一个失效表来实现的,
# 该表使用1600万个插槽来记住哪些客户机可能具有某些密钥子集。反过来,
# 它用于向客户端发送无效消息。请查看此页以了解有关该功能的更多信息:
#
#   https://redis.io/topics/client-side-caching
#
# When tracking is enabled for a client, all the read only queries are assumed
# to be cached: this will force Redis to store information in the invalidation
# table. When keys are modified, such information is flushed away, and
# invalidation messages are sent to the clients. However if the workload is
# heavily dominated by reads, Redis could use more and more memory in order
# to track the keys fetched by many clients.
# Redis实现了对客户端值缓存的服务器辅助支持。这是使用一个失效表来实现的,
# 该表使用1600万个插槽来记住哪些客户机可能具有某些密钥子集。
# 反过来,它用于向客户端发送无效消息。请查看此页以了解有关该功能的更多信息:
#
# For this reason it is possible to configure a maximum fill value for the
# invalidation table. By default it is set to 1M of keys, and once this limit
# is reached, Redis will start to evict keys in the invalidation table
# even if they were not modified, just to reclaim memory: this will in turn
# force the clients to invalidate the cached values. Basically the table
# maximum size is a trade off between the memory you want to spend server
# side to track information about who cached what, and the ability of clients
# to retain cached objects in memory.
# 因此,可以为失效表配置最大填充值。默认情况下,它被设置为1M的键,一旦达到这个限制,
# Redis将开始逐出失效表中的键,即使它们没有被修改,只是为了回收内存:这反过来会迫使客户端使缓存的值失效。
# 表的最大大小基本上是在服务器端跟踪谁缓存了什么内容的信息所需的内存和客户端在内存中保留缓存对象的能力之间的权衡。
#
# If you set the value to 0, it means there are no limits, and Redis will
# retain as many keys as needed in the invalidation table.
# In the "stats" INFO section, you can find information about the number of
# keys in the invalidation table at every given moment.
# 如果将该值设置为0,则表示没有限制,Redis将根据需要在失效表中保留尽可能多的键。在“stats”INFO部分,您可以找到关于每个给定时刻失效表中的键数的信息。
#
# Note: when key tracking is used in broadcasting mode, no memory is used
# in the server side so this setting is useless.
# 注意:当在广播模式下使用密钥跟踪时,服务器端没有使用内存,因此此设置无效。
# 
# tracking-table-max-keys 1000000

################################## SECURITY ###################################

# Warning: since Redis is pretty fast, an outside user can try up to
# 1 million passwords per second against a modern box. This means that you
# should use very strong passwords, otherwise they will be very easy to break.
# Note that because the password is really a shared secret between the client
# and the server, and should not be memorized by any human, the password
# can be easily a long string from /dev/urandom or whatever, so by using a
# long and unguessable password no brute force attack will be possible.
# 就是警告redis速度非常快,所以很方便执行暴力密码破解指令,所以redis的密码应该尽可能的复杂。(即使做了网络限制,还是建议设置一个复杂的密码)

# Redis ACL users are defined in the following format:
# redis ACL 用户定义格式如下
#   user <username> ... acl rules ...
#
# For example:
#
#   user worker +@list +@connection ~jobs:* on >ffa9203c493aa99
#
# The special username "default" is used for new connections. If this user
# has the "nopass" rule, then new connections will be immediately authenticated
# as the "default" user without the need of any password provided via the
# AUTH command. Otherwise if the "default" user is not flagged with "nopass"
# the connections will start in not authenticated state, and will require
# AUTH (or the HELLO command AUTH option) in order to be authenticated and
# start to work.
# 特殊用户"default"用作新连接使用,如果这个用户拥有跳过密码权限,那么可以不进行认证直接登录使用
#
# The ACL rules that describe what a user can do are the following:
# 描述用户可以执行的操作的ACL规则如下:
#
#  on           Enable the user: it is possible to authenticate as this user. 					启用用户:可以为这个用户进行身份认证
#  off          Disable the user: it's no longer possible to authenticate  						关闭用户,无法再使用此用户进行身份验证,但是已经通过身份验证的连接仍然有效。
#               with this user, however the already authenticated connections
#               will still work.
#  +<command>   Allow the execution of that command          									允许执行该命令
#  -<command>   Disallow the execution of that command											不允许执行该命令
#  +@<category> Allow the execution of all the commands in such category  						允许执行该类命令
#               with valid categories are like @admin, @set, @sortedset, ...
#               and so forth, see the full list in the server.c file where
#               the Redis command table is described and defined.
#               The special category @all means all the commands, but currently
#               present in the server, and that will be loaded in the future
#               via modules.
#  +<command>|subcommand    Allow a specific subcommand of an otherwise
#                           disabled command. Note that this form is not
#                           allowed as negative like -DEBUG|SEGFAULT, but
#                           only additive starting with "+".    								允许禁用命令的特定子命令。请注意,此表单不允许为负数,如-DEBUG | SEGFAULT,而只能是以“+”开头的加法形式。
#  allcommands  Alias for +@all. Note that it implies the ability to execute 
#               all the future commands loaded via the modules system.    						+@all的别名它意味着能够执行通过模块系统加载的所有未来命令。
#  nocommands   Alias for -@all.										  						-@all的别名
#  ~<pattern>   Add a pattern of keys that can be mentioned as part of        					添加能匹配到的命令作为拥有的权限
#               commands. For instance ~* allows all the keys. The pattern
#               is a glob-style pattern like the one of KEYS.
#               It is possible to specify multiple patterns.
#  allkeys      Alias for ~*																	~*的别名				
#  resetkeys    Flush the list of allowed keys patterns.										刷新允许的指令列表
#  ><password>  Add this password to the list of valid password for the user.					为用户设置密码
#               For example >mypass will add "mypass" to the list.
#               This directive clears the "nopass" flag (see later).
#  <<password>  Remove this password from the list of valid passwords.							将密码用有效密码列表中移除
#  nopass       All the set passwords of the user are removed, and the user						设置用户跳过密码校验,如果设置默认用户跳过密码校验。所有的新连接都将直接使用默认用户直接连接,安全认证直接失效
#               is flagged as requiring no password: it means that every						"resetpass" 指令可以清楚该设置
#               password will work against this user. If this directive is
#               used for the default user, every new connection will be
#               immediately authenticated with the default user without
#               any explicit AUTH command required. Note that the "resetpass"
#               directive will clear this condition.
#  resetpass    Flush the list of allowed passwords. Moreover removes the       				刷新密码:刷新密码列表。此外,删除“nopass”状态。
#               "nopass" status. After "resetpass" the user has no associated  					在“resetpass”之后,用户没有关联的密码,
#               passwords and there is no way to authenticate without adding   					并且没有办法在不添加密码(或稍后将其设置为“nopass”)的情况下进行身份验证。
#               some password (or setting it as "nopass" later).  
#  reset        Performs the following actions: resetpass, resetkeys, off,     					相当于执行了resetpass, resetkeys, off, -@all操作,这个用户立即恢复为初始创建状态
#               -@all. The user returns to the same state it has immediately
#               after its creation.
#
# ACL rules can be specified in any order: for instance you can start with
# passwords, then flags, or key patterns. However note that the additive
# and subtractive rules will CHANGE MEANING depending on the ordering.
# For instance see the following example:
# ACL规则可以按任何顺序指定:例如,可以从密码开始,然后是标志或密钥模式。但是请注意,加法和减法规则将根据顺序改变含义。
#
#   user alice on +@all -DEBUG ~* >somepassword
#
# This will allow "alice" to use all the commands with the exception of the
# DEBUG command, since +@all added all the commands to the set of the commands
# alice can use, and later DEBUG was removed. However if we invert the order
# of two ACL rules the result will be different:
# 上面这个案例的含义就是允许alice用户使用除了DEBUG外的所有指令,由于配置是一步一步来,后面的覆盖前面的,
# 如果上面的”+@all“与” -DEBUG“颠倒了位置,结果就是允许alice用户使用所有指令,下面这个案例的说明就是这个意思
#   user alice on -DEBUG +@all ~* >somepassword
#
# Now DEBUG was removed when alice had yet no commands in the set of allowed
# commands, later all the commands are added, so the user will be able to
# execute everything.
# 现在,当alice在允许的命令集中还没有命令时,DEBUG被删除了,稍后所有的命令都被添加,这样用户就可以执行所有的命令了。
#
# Basically ACL rules are processed left-to-right.
# ACL规则是从左向右处理的。
#
# For more information about ACL configuration please refer to
# 更多的关于ACL配置的信息请参阅官方网址
# the Redis web site at https://redis.io/topics/acl

# ACL LOG
#
# The ACL Log tracks failed commands and authentication events associated
# with ACLs. The ACL Log is useful to troubleshoot failed commands blocked 
# by ACLs. The ACL Log is stored in memory. You can reclaim memory with 
# ACL LOG RESET. Define the maximum entry length of the ACL Log below.
# ACL日志跟踪与ACL关联的失败命令和身份验证事件。ACL日志对于排除ACL阻止的失败命令非常有用。ACL日志存储在内存中。您可以使用ACL日志重置来回收内存。在下面定义ACL日志的最大条目长度。
acllog-max-len 128

# Using an external ACL file
# 使用外部ACL文件配置
#
# Instead of configuring users here in this file, it is possible to use
# a stand-alone file just listing users. The two methods cannot be mixed:
# if you configure users here and at the same time you activate the external
# ACL file, the server will refuse to start.
# 用户只需在这里配置一个单独的文件就可以了。这两种方法不能混合使用:如果在这里配置用户,同时激活外部ACL文件,服务器将拒绝启动。
#
# The format of the external ACL user file is exactly the same as the
# format that is used inside redis.conf to describe users.
#
# aclfile /etc/redis/users.acl

# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
# layer on top of the new ACL system. The option effect will be just setting
# the password for the default user. Clients will still authenticate using
# AUTH <password> as usually, or more explicitly with AUTH default <password>
# if they follow the new protocol: both will work.
#
# requirepass foobared

# Command renaming (DEPRECATED).
#
# ------------------------------------------------------------------------
# WARNING: avoid using this option if possible. Instead use ACLs to remove
# commands from the default user, and put them only in some admin user you
# create for administrative purposes.
# ------------------------------------------------------------------------
#
# 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命令可以重命名为一个很难被猜到的命令,这样用户不能使用,而内部工具还能接着使用。
#
# 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 replicas may cause problems.

################################### CLIENTS ####################################

# 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保留了一些文件描述符供内部使用)
# 就是说默认设置10000实际上最高连接数是9968
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
# 超额将关闭所有新连接,并发送错误报告日志“max number of clients reached”。
#
# IMPORTANT: When Redis Cluster is used, the max number of connections is also
# shared with the cluster bus: every node in the cluster will use two
# connections, one incoming and another outgoing. It is important to size the
# limit accordingly in case of very large clusters.
# 重要提示:当使用Redis集群时,最大连接数也与集群总线共享:集群中的每个节点将使用两个连接,一个传入,另一个传出。(就是对与主节点而言,没个从节点都保持了两个连接来维持主从通信的)
# 在非常大的簇的情况下,相应地调整限制的大小是很重要的。
# 客户端连接数
# maxclients 10000

############################## MEMORY MANAGEMENT ################################
############################## 内存  #####  管理 ################################

# Set a memory usage limit to 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策略)。
#
# 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无法根据策略删除密钥,或者如果策略设置为“noeviction”,Redis将开始对使用更多内存的命令(如set、LPUSH等)进行错误应答,并继续回复GET等只读命令。
# 就是说内存不够了后,还不允许删除旧有的数据的话,再插入就会报错了,只能调用取命令
#
# This option is usually useful when using Redis as an LRU or LFU cache, or to
# set a hard memory limit for an instance (using the 'noeviction' policy).
# 当将Redis用作LRU或LFU缓存时,或者设置实例的硬内存限制(使用“noeviction”策略)时,此选项通常很有用。
#
# WARNING: If you have replicas attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the replicas 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 replicas is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
# 警告:如果启用了maxmemory的实例有从节点,则从已用内存计数中减去提供从节点所需
# 的输出缓冲区的大小,这样网络问题/重新同步将不会触发一个循环,在该循环中,数据被逐出,
# 而副本的输出缓冲区将充满,并触发删除更多的密钥,以此类推,直到数据库完全清空。
#
# In short... if you have replicas attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for replica
# output buffers (but this is not needed if the policy is 'noeviction').
# 简而言之。。。如果附加了副本,建议您为maxmemory设置一个下限,以便系统上有一些可用的RAM用于副本输出缓冲区(但是,如果策略为“noeviction”,则不需要这样做)。
# maxmemory <bytes>

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select one from the following behaviors:
# MAXMEMORY策略:达到MAXMEMORY时Redis将如何选择要删除的内容。可以从以下行为中选择一个:
#
# volatile-lru -> Evict using approximated LRU, only keys with an expire set.   从已设置过期时间的内存数据集中挑选最近最少使用的数据 淘汰;
# allkeys-lru -> Evict any key using approximated LRU.							从内存数据集中挑选最近最少使用的数据 淘汰;
# volatile-lfu -> Evict using approximated LFU, only keys with an expire set.   从已设置过期时间的内存数据集中挑选最近最多使用的数据 淘汰;
# allkeys-lfu -> Evict any key using approximated LFU.							从内存数据集中挑选最近最多使用的数据 淘汰;
# volatile-random -> Remove a random key having an expire set.					从已设置过期时间的内存数据集中任意挑选数据 淘汰;
# allkeys-random -> Remove a random key, any key.								从数据集中任意挑选数据 淘汰;	
# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)       已设置过期时间的内存数据集中删除最接近过期时间的数据(次要TTL)
# noeviction -> Don't evict anything, just return an error on write operations. 不淘汰任何数据,直接返回写入数据异常
#
# LRU means Least Recently Used         LRU标识最少使用
# LFU means Least Frequently Used		LFU表示最多使用
#
# Both LRU, LFU and volatile-ttl are implemented using approximated
# randomized algorithms.
# LRU、LFU和volatile ttl都是用近似随机算法实现的。
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
# 注意:对于以上任何一种策略,当没有合适的密钥进行逐出时,Redis将在写操作时返回错误。
#
#       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
#
# The default is:
# 默认设置是不淘汰数据,直接返回异常
# maxmemory-policy noeviction

# LRU, LFU 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. By default Redis will check five keys and pick the one that was
# used least recently, you can change the sample size using the following
# configuration directive.
# LRU、LFU和minimal TTL算法不是精确算法,而是近似算法(为了节省内存),因此您可以根据速度或精度对其进行调整。默认情况下,Redis将检查五个键并选择最近使用过的一个,您可以使用以下配置指令更改样本大小。
#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs more CPU. 3 is faster but not very accurate.
# 默认值为5会产生足够好的结果。10接近真实的LRU,但占用更多的CPU。3更快,但不是很准确。
#
# maxmemory-samples 5

# Starting from Redis 5, by default a replica will ignore its maxmemory setting
# (unless it is promoted to master after a failover or manually). It means
# that the eviction of keys will be just handled by the master, sending the
# DEL commands to the replica as keys evict in the master side.
# 从Redis 5开始,默认情况下,复制副本将忽略其maxmemory设置(除非在故障转移后或手动将其升级为master)。
# 这意味着密钥的收回将由主服务器处理,将DEL命令作为主机端的密钥收回发送到副本。
#
# This behavior ensures that masters and replicas stay consistent, and is usually
# what you want, however if your replica is writable, or you want the replica
# to have a different memory setting, and you are sure all the writes performed
# to the replica are idempotent, then you may change this default (but be sure
# to understand what you are doing).
# 此行为可确保主副本和副本保持一致,并且通常是您想要的,但是,如果您的复制副本是可写的,
# 或者您希望复制副本具有不同的内存设置,并且您确定对副本执行的所有写操作都是幂等的,
# 则可以更改此默认值(但一定要了解您正在做什么)。
#
# Note that since the replica by default does not evict, it may end using more
# memory than the one set via maxmemory (there are certain buffers that may
# be larger on the replica, or data structures may sometimes take more memory
# and so forth). So make sure you monitor your replicas and make sure they
# have enough memory to never hit a real out-of-memory condition before the
# master hits the configured maxmemory setting.
# 请注意,由于复制副本在默认情况下不会逐出,因此它可能会使用比通过maxmemory设置的内存更多的内存
# (副本上有一些缓冲区可能更大,或者数据结构有时可能占用更多内存等等)。因此,请确保您监视您的副本,
# 并确保它们有足够的内存,在主机命中配置的maxmemory设置之前,它们不会出现内存不足的情况。
# 
# 从节点会略最大内存设置
# replica-ignore-maxmemory yes

# Redis reclaims expired keys in two ways: upon access when those keys are
# found to be expired, and also in background, in what is called the
# "active expire key". The key space is slowly and interactively scanned
# looking for expired keys to reclaim, so that it is possible to free memory
# of keys that are expired and will never be accessed again in a short time.
# Redis通过两种方式回收过期的密钥:当访问时发现这些密钥已过期,并且在后台,即所谓的“活动过期密钥”。
# 密钥空间被缓慢地交互扫描,寻找过期的密钥以回收,这样就可以释放过期密钥的内存,而这些密钥在很短时间内就设置未永远不能被访问。
#
# The default effort of the expire cycle will try to avoid having more than
# ten percent of expired keys still in memory, and will try to avoid consuming
# more than 25% of total memory and to add latency to the system. However
# it is possible to increase the expire "effort" that is normally set to
# "1", to a greater value, up to the value "10". At its maximum value the
# system will use more CPU, longer cycles (and technically may introduce
# more latency), and will tolerate less already expired keys still present
# in the system. It's a tradeoff between memory, CPU and latency.
# expire循环的默认工作将尽量避免超过10%的过期密钥仍在内存中,并将尽量避免消耗超过25%的总内存,并增加系统的延迟。
# 但是,可以将通常设置为“1”的expire“efforce”增加到更大的值,直到值“10”。在其最大值时,系统将使用更多的CPU、更长的周期(从技术上讲,可能会引入更多的延迟)
# ,并将容忍系统中仍然存在的已过期密钥更少。这是内存、CPU和延迟之间的折衷。
# 大致意思是expire循环任务调度清理密钥也是需要消耗性能的,想过期密钥清理的越干净那么cpu消耗就越高,看你自己折中选择
# effort改变了过期键可占内存的最大百分比,改变了最大占用cpu的百分比等,effort越大,cpu负担越重,所以根据自己的需要设置effort的值。 引至:https://cloud.tencent.com/developer/article/1692645
# active-expire-effort 1

############################# LAZY FREEING ####################################

# Redis has two primitives to delete keys. One is called DEL and is a blocking
# deletion of the object. It means that the server stops processing new commands
# in order to reclaim all the memory associated with an object in a synchronous
# way. If the key deleted is associated with a small object, the time needed
# in order to execute the DEL command is very small and comparable to most other
# O(1) or O(log_N) commands in Redis. However if the key is associated with an
# aggregated value containing millions of elements, the server can block for
# a long time (even seconds) in order to complete the operation.
# Redis有两个基本体来删除密钥。一种叫做DEL,是对对象的阻塞性删除。这意味着服务器停止处理新命令,
# 以便以同步方式回收与对象关联的所有内存。如果删除的密钥与一个小对象关联,
# 则执行DEL命令所需的时间非常小,与Redis中大多数其他O(1)或O(log_N)命令相比是非常小的。
# 但是,如果密钥与一个包含数百万个元素的聚合值相关联,服务器可能会长时间(甚至几秒钟)阻塞以完成操作。
#
# For the above reasons Redis also offers non blocking deletion primitives
# such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and
# FLUSHDB commands, in order to reclaim memory in background. Those commands
# are executed in constant time. Another thread will incrementally free the
# object in the background as fast as possible.
# 基于以上原因,Redis还提供了UNLINK(non-blocking DEL)等非阻塞删除原语,
# 以及FLUSHALL和FLUSHDB命令的异步选项,以便在后台回收内存。这些命令在固定时间内执行。
# 另一个线程将以最快的速度增量释放后台的对象。
#
# DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled.
# It's up to the design of the application to understand when it is a good
# idea to use one or the other. However the Redis server sometimes has to
# delete keys or flush the whole database as a side effect of other operations.
# Specifically Redis deletes objects independently of a user call in the
# following scenarios:
# FLUSHALL和FLUSHDB的DEL、UNLINK和ASYNC选项由用户控制。这取决于应用程序的设计来
# 理解何时使用其中一个是好主意。然而,由于其他操作的副作用,Redis服务器有时不得
# 不删除密钥或刷新整个数据库。具体来说,在以下情况下,Redis会独立于用户调用删除对象:
#
# 1) On eviction, because of the maxmemory and maxmemory policy configurations,
#    in order to make room for new data, without going over the specified
#    memory limit.     
#    在逐出时,由于maxmemory和maxmemory策略配置,为了在不超过指定内存限制的情况下为新数据腾出空间。

# 2) Because of expire: when a key with an associated time to live (see the
#    EXPIRE command) must be deleted from memory.
#    因为expire:必须从内存中删除具有相关生存时间的密钥(请参阅expire命令)。

# 3) Because of a side effect of a command that stores data on a key that may
#    already exist. For example the RENAME command may delete the old key
#    content when it is replaced with another one. Similarly SUNIONSTORE
#    or SORT with STORE option may delete existing keys. The SET command
#    itself removes any old content of the specified key in order to replace
#    it with the specified string.
#    因为命令的副作用是可能将数据存储在已经存在的键上。
#    例如,重命名命令可能会删除旧的密钥内容,当它被另一个替换时。类似地,
#    SUNIONSTORE或SORT with STORE选项可能会删除现有的密钥。SET命令本身删除指定键的任何旧内容,以便用指定的字符串替换它。

# 4) During replication, when a replica performs a full resynchronization with
#    its master, the content of the whole database is removed in order to
#    load the RDB file just transferred.
#    在复制过程中,当从节点与其主节点执行数据完全重新同步时,从节点整个数据库的内容将被删除,以便加载刚刚传输的RDB文件
#
# In all the above cases the default is to delete objects in a blocking way,
# like if DEL was called. However you can configure each case specifically
# in order to instead release memory in a non-blocking way like if UNLINK
# was called, using the following configuration directives.
# 在上述所有情况下,默认情况是以阻塞方式删除对象,就像调用DEL一样。但是,您可以具体地配置每种情况,以便使用以下配置指令以非阻塞方式释放内存,就像调用UNLINK一样。

lazyfree-lazy-eviction no    
# 是否异步驱逐key,当内存达到上限,分配失败后
lazyfree-lazy-expire no
# 是否异步进行key过期事件的处理
lazyfree-lazy-server-del no
# del命令是否异步执行删除操作,类似unlink
replica-lazy-flush no
# 从节点做全同步的时候,是否异步flush本地db

# It is also possible, for the case when to replace the user code DEL calls
# with UNLINK calls is not easy, to modify the default behavior of the DEL
# command to act exactly like UNLINK, using the following configuration
# directive:
# 在用UNLINK调用替换用户代码DEL调用并不容易的情况下,还可以使用以下配置指令修改DEL命令的默认行为,使其与UNLINK完全相同:

#执行DEL命令时是否基于lazyfree异步删除数据,可选值:
lazyfree-lazy-user-del no

################################ THREADED I/O #################################

# Redis is mostly single threaded, however there are certain threaded
# operations such as UNLINK, slow I/O accesses and other things that are
# performed on side threads.
# redis的大多数操作()都是单线程的,但也有部分操作多线程操作
#
# Now it is also possible to handle Redis clients socket reads and writes
# in different I/O threads. Since especially writing is so slow, normally
# Redis users use pipelining in order to speed up the Redis performances per
# core, and spawn multiple instances in order to scale more. Using I/O
# threads it is possible to easily speedup two times Redis without resorting
# to pipelining nor sharding of the instance.
#
# By default threading is disabled, we suggest enabling it only in machines
# that have at least 4 or more cores, leaving at least one spare core.
# Using more than 8 threads is unlikely to help much. We also recommend using
# threaded I/O only if you actually have performance problems, with Redis
# instances being able to use a quite big percentage of CPU time, otherwise
# there is no point in using this feature.
# 大致意思是:1、cpu核心至少4核以上。2、缺失存在由于线程数造成的io性能瓶颈
# (然而大部分性能瓶颈都是内存与网络造成的,除非你用明朝的cpu配清朝的内存)。否则使用多线程没什么意义
#
# So for instance if you have a four cores boxes, try to use 2 or 3 I/O
# threads, if you have a 8 cores, try to use 6 threads. In order to
# enable I/O threads use the following configuration directive:
# io线程数,默认为1。可根据你的cpu线程数调配,4核的就设置2或者3,8核的就设置6。
# io-threads 4
#
# Setting io-threads to 1 will just use the main thread as usual.
# When I/O threads are enabled, we only use threads for writes, that is
# to thread the write(2) syscall and transfer the client buffers to the
# socket. However it is also possible to enable threading of reads and
# protocol parsing using the following configuration directive, by setting
# it to yes:
# 大致意思是:无法理解。
# 反正这个配置的意思是读操作是否也启用I/O多线程
# io-threads-do-reads no
#
# Usually threading reads doesn't help much. 通常情况下,多线程读取没什么卵用
#
# NOTE 1: This configuration directive cannot be changed at runtime via
# CONFIG SET. Aso this feature currently does not work when SSL is
# enabled.
# 这个配置不能在redis运行时进行改变。该版本下,使用SSL时,该功能失效
#
# NOTE 2: If you want to test the Redis speedup using redis-benchmark, make
# sure you also run the benchmark itself in threaded mode, using the
# --threads option to match the number of Redis threads, otherwise you'll not
# be able to notice the improvements.
# 如果你使用redis-benchmark测试性能的化,请确认你的操作运行在该线程模式下。使用
# --threads 参数设置redis线程数。否则,你是看不到多线程的改进的。菜鸡新人基本用不上这个。

KERNEL OOM CONTROL 内核OOM控件

############################ KERNEL OOM CONTROL ##############################

# On Linux, it is possible to hint the kernel OOM killer on what processes
# should be killed first when out of memory.
# 在linux上,可以再内粗溢出的时候提示 OOM杀手干掉那些进程
#
# Enabling this feature makes Redis actively control the oom_score_adj value
# for all its processes, depending on their role. The default scores will
# attempt to have background child processes killed before all others, and
# replicas killed before masters.
# 启用此功能将使Redis主动控制其所有进程的oom_score_adj值,具体取决于它们的角色。
# 默认分数将尝试在所有其他进程之前杀死后台子进程,并在主进程之前杀死副本。

oom-score-adj no

# When oom-score-adj is used, this directive controls the specific values used
# for master, replica and background child processes. Values range -1000 to
# 1000 (higher means more likely to be killed).
# 当使用oom score adj时,此指令控制主进程、副本进程和后台子进程使用的特定值。值的范围是-1000到1000(越高意味着死亡的可能性越大)。
#
# Unprivileged processes (not root, and without CAP_SYS_RESOURCE capabilities)
# can freely increase their value, but not decrease it below its initial
# settings.
# 非特权进程(不是根进程,也没有CAP_SYS_资源功能)可以自由地增加它们的值,但不能将其降低到初始设置以下。
#
# Values are used relative to the initial value of oom_score_adj when the server
# starts. Because typically the initial value is 0, they will often match the
# absolute values.
# 当服务器启动时,使用相对于oom_score_adj的初始值的值。因为通常初始值是0,所以它们通常与绝对值匹配。

oom-score-adj-values 0 200 800

APPEND ONLY MODE 附加模式

############################## 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进程的问题或断电可能会导致几分钟的写操作丢失(取决于配置的保存点)。
#
# 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.
# Append-Only文件是另一种持久性模式,它提供了更好的持久性。例如,如果使用默认的数据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,即具有更好的持久性保证的文件。
# 
# Please check http://redis.io/topics/persistence for more information.

# 开启AOF 默认no
appendonly yes

# The name of the append only file (default: "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:
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.    从不fsync,只需将数据交给操作系统即可(官网说明:从不fsync,只需将数据交给操作系统即可。更快,更不安全的方法。通常,Linux使用此配置每30秒刷新一次数据,但这取决于内核的精确调整。)
# always: fsync after every write to the append only log. Slow, Safest.     次将新命令附加到AOF时。非常非常慢,非常安全。请注意,在执行了来自多个客户端或管道的一批命令之后,这些命令会附加到AOF,因此这意味着一次写入和一次fsync(在发送答复之前)。
# everysec: fsync only one time every second. Compromise.            		fsync每秒。速度足够快(在2.4中可能与快照速度一样快),如果发生灾难,您可能会丢失1秒的数据。
#
# 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.
# 默认值是“everysec”,因为这通常是速度和数据安全之间的正确折衷。这取决于您是否可以将此设置放宽为“否”,
# 这样操作系统可以在需要时刷新输出缓冲区,以获得更好的性能(但是如果您可以接受某些数据丢失的想法,
# 请考虑默认的快照持久性模式),或者恰恰相反,使用“always”,它非常慢,但比everysec安全一些。
#
# More details please check the following article:
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec".
# 如果你不确定,建议使用  "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 fsync策略设置为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或bwriteAOF时在主进程中调用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的耐久性与“appendfsync none”相同。(就是有子进程在背后写AOF,主进程也在写AOF文件,两者同时操作磁盘,会存在阻塞的情形。)
# 实际上,这意味着在最坏的情况下(使用默认的Linux设置),可能会丢失最多30秒的日志。
#
# 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.
# 如果您有延迟问题,请将此选项设置为“是”。否则,将其保留为“否”,从耐用性的角度来看,这是最安全的选择。

# 当主进程执行写AOF文件的时候不进行appendfsync操作
no-appendfsync-on-rewrite no
# 使用推荐:无法忍受延迟,而可以容忍少量的数据丢失,则设置为yes。如果应用系统无法忍受数据丢失,则设置为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.
# 自动重写仅附加文件。Redis能够在AOF日志大小按指定的百分比增长时自动重写日志文件,并隐式调用BGREWRITEAOF。
#
# 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.
# 将此基本大小与当前大小进行比较。如果当前大小大于指定的百分比,则会触发重写。
# 此外,您还需要为要重写的AOF文件指定最小大小,这对于避免重写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).
# 在Redis启动过程中,当AOF数据加载回内存时,可能会发现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时,用户需要在重新启动服务器之前使用“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文件加载是否允许文件存在错误信息,
# 允许则会自动从第一个错误开始截取至最后(可能造成很严重的数据丢失)
# 不允许,则启动报错,需要先人工修复AOF文件后才能正常的启动,官方根据不通的版本给出了不通的修复策略、修复工具。详情:https://redis.io/topics/persistence
aof-load-truncated yes

# When rewriting the AOF file, Redis is able to use an RDB preamble in the
# AOF file for faster rewrites and recoveries. When this option is turned
# on the rewritten AOF file is composed of two different stanzas:
# 在重写AOF文件时,Redis能够在AOF文件中使用RDB前导码以加快重写和恢复。
# 启用此选项时,重写的AOF文件由两个不同的段落组成:(RDB文件头+AOF尾)
#
#   [RDB file][AOF tail]
#
# When loading, Redis recognizes that the AOF file starts with the "REDIS"
# string and loads the prefixed RDB file, then continues loading the AOF
# tail.
# 加载时,Redis识别出AOF文件以“Redis”字符串开头并加载带前缀的RDB文件,然后继续加载AOF尾部。

aof-use-rdb-preamble yes

LUA SCRIPTING LUA脚本

################################ LUA SCRIPTING  ###############################
################################ LUA      脚本  ###############################

# Max execution time of a Lua script in milliseconds.
# Lua脚本的最长执行时间(毫秒)。
#
# 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.
# 如果达到最大执行时间,Redis将记录在允许的最长时间之后脚本仍在执行中,并将开始以错误的方式答复查询。
#
# 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 call any 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.
# 当长时间运行的脚本超过最大执行时间时,只有脚本KILL和SHUTDOWN NOSAVE命令可用。
# 第一个命令可用于停止尚未调用任何write命令的脚本。第二种方法是在脚本已经发出
# write命令但用户不想等待脚本自然终止的情况下关闭服务器的唯一方法。
#
# Set it to 0 or a negative value for unlimited execution without warnings.
# 将其设置为0或负值,以无限制地执行而不发出警告。默认5000毫秒
lua-time-limit 5000

REDIS CLUSTER redis集群配置

################################ REDIS CLUSTER  ###############################
################################ REDIS    集群  ###############################

# 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 a multiple of the node timeout.
# 大多数其他内部时间限制是节点超时的倍数。
#
# cluster-node-timeout 15000

# A replica of a failing master will avoid to start a failover if its data
# looks too old.
# 如果主节点出错了,但是从节点的数据看起来也太久了,它将避免启动故障转移(从节点竞选主节点)
#
# There is no simple way for a replica to actually have an exact measure of
# its "data age", so the following two checks are performed:
# 对于从节点来说,没有一种简单的方法来实际精确测量其“数据期限”,因此需要执行以下两种检查:
#
# 1) If there are multiple replicas able to failover, they exchange messages
#    in order to try to give an advantage to the replica with the best
#    replication offset (more data from the master processed).
#    Replicas 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 replica 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 replica will not try to failover
#    at all.
#    每个副本都计算最后一次与主副本交互的时间。这可以是上一次接收到的ping或命令
#   (如果主服务器仍处于“已连接”状态),也可以是自与主服务器断开连接后经过的时间
#   (如果复制链接当前处于关闭状态)。如果最后一次交互太旧,复制副本根本不会尝试故障转移
#
# The point "2" can be tuned by user. Specifically a replica will not perform
# the failover if, since the last interaction with the master, the time
# elapsed is greater than:
# 第二点可由用户调节。具体地说,如果自上次与主服务器交互以来,经过的时间大于   
#
#   (node-timeout * cluster-replica-validity-factor) + repl-ping-replica-period
#   节点超时时间 * 集群-复制—有效—系数 + 从节点ping周期
#
# So for example if node-timeout is 30 seconds, and the cluster-replica-validity-factor
# is 10, and assuming a default repl-ping-replica-period of 10 seconds, the
# replica will not try to failover if it was not able to talk with the master
# for longer than 310 seconds.
# 因此,例如,如果节点超时为30秒,而群集副本有效性系数为10,并且假定默认的复制副本周期为10秒,
# 则如果副本无法与主机通信超过310秒,则该副本不会尝试进行故障转移。
#
# A large cluster-replica-validity-factor may allow replicas with too old data to failover
# a master, while a too small value may prevent the cluster from being able to
# elect a replica at all.
# 较大的群集副本有效性系数可能会允许具有太旧数据的副本对主服务器进行故障转移,而太小的值可能会使群集根本无法选择副本。
#
# For maximum availability, it is possible to set the cluster-replica-validity-factor
# to a value of 0, which means, that replicas 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).
# 为了获得最大可用性,可以将群集副本有效性因子设置为0,这意味着副本将始终尝试故障转移主服务器,而不管它们上次与主服务器交互的时间。(但是他们总是尝试应用与偏移量成比例的延迟)。
#
# Zero is the only value able to guarantee that when all the partitions heal
# the cluster will always be able to continue.
# 零是唯一能够保证当所有分区恢复时,集群始终能够继续运行的值。
#
# 集群-复制—有效—系数
# cluster-replica-validity-factor 10

# Cluster replicas are able to migrate to orphaned masters, that are masters
# that are left without working replicas. 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 replicas.
# 从节点能够变成主节点。这提高了集群抵御故障的能力,
# 否则,如果单独的主节点没有从节点,则无法在发生故障时进行故障切换。
#
# Replicas migrate to orphaned masters only if there are still at least a
# given number of other working replicas for their old master. This number
# is the "migration barrier". A migration barrier of 1 means that a replica
# will migrate only if there is at least 1 other working replica for its master
# and so forth. It usually reflects the number of replicas you want for every
# master in your cluster.
# 大致意思是设置了个集群最小从节点数,主节点宕机后,集群必须至少还拥有不少于这个数的节点
# 才能进行故障迁移。
#
# Default is 1 (replicas migrate only if their masters remain with at least
# one replica). 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.
# 默认值为1(复制副本仅在其主副本保留至少一个副本时才迁移)。
# 要禁用迁移,只需将其设置为非常大的值。可以设置值0,但仅对调试有用,并且在生产中很危险
#
# 集群-迁移-屏障
# cluster-migration-barrier 1

# By default Redis Cluster nodes stop accepting queries if they detect there
# is at least a 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.
# 默认情况下,如果Redis集群节点检测到至少有一个未覆盖的哈希槽(没有可用节点为其提供服务),
# 则它们将停止接受查询。这样,如果集群部分关闭(例如不再覆盖一系列哈希槽),
# 那么最终所有集群都将不可用。一旦所有插槽再次被覆盖,它就会自动返回可用。
#
# 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选项设置为no。
# 
# 默认情况下,集群全部的slot有节点负责,集群状态才为ok,才能提供服务。设置为no,可以在slot没有全部分配的时候提供服务。不建议打开该配置,这样会造成分区的时候,小分区的master一直在接受写请求,而造成很长时间数据不一致。
# cluster-require-full-coverage yes

# This option, when set to yes, prevents replicas from trying to failover its
# master during master failures. However the master can still perform a
# manual failover, if forced to do so.
# 此选项设置为“是”时,可防止复制副本在主服务器出现故障时尝试故障转移其主服务器。但是,主服务器仍然可以执行手动故障转移,如果被迫这样做的话。
#
# This is useful in different scenarios, especially in the case of multiple
# data center operations, where we want one side to never be promoted if not
# in the case of a total DC failure.
# 这在不同的场景中非常有用,特别是在多个数据中心操作的情况下,如果在整个DC故障的情况下,我们希望永远不会升级一个端。
# 
# 集群-副本-不发生故障转移
# cluster-replica-no-failover no

# This option, when set to yes, allows nodes to serve read traffic while the
# the cluster is in a down state, as long as it believes it owns the slots. 
# 此选项在设置为yes时,允许节点在集群处于关闭状态时提供读取流量,只要它认为它拥有插槽。
#
# This is useful for two cases.  The first case is for when an application 
# doesn't require consistency of data during node failures or network partitions.
# One example of this is a cache, where as long as the node has the data it
# should be able to serve it. 
# 这有两种情况。第一种情况是在节点故障或网络分区期间,应用程序不需要数据的一致性。缓存就是一个例子,只要节点有数据,它就应该能够为它提供服务。
#
# The second use case is for configurations that don't meet the recommended  
# three shards but want to enable cluster mode and scale later. A 
# master outage in a 1 or 2 shard configuration causes a read/write outage to the
# entire cluster without this option set, with it set there is only a write outage.
# Without a quorum of masters, slot ownership will not change automatically. 
# 第二个用例是针对那些不满足推荐的三个碎片,但希望以后启用集群模式和扩展的配置。
# 1或2碎片配置中的主中断会导致对的读/写中断 没有设置此选项的整个群集,
# 如果设置了此选项,则只会发生写入中断。如果没有足够数量的主机,插槽所有权将不会自动更改。
#
# 当集群关闭的时候允许读取数据
# cluster-allow-reads-when-down no

# In order to setup your cluster make sure to read the documentation
# available at http://redis.io web site.

CLUSTER DOCKER/NAT support 集群DOCKER/NAT支持

########################## CLUSTER DOCKER/NAT support  ########################
########################## 集群    DOCKER/NAT    支持  ########################

# In certain deployments, Redis Cluster nodes address discovery fails, because
# addresses are NAT-ted or because ports are forwarded (the typical case is
# Docker and other containers).
# 在某些部署中,Redis集群节点地址发现失败,原因是地址是NAT的,或者是端口被转发(典型的情况是Docker和其他容器)。
#
# In order to make Redis Cluster working in such environments, a static
# configuration where each node knows its public address is needed. The
# following two options are used for this scope, and are:
# 为了使Redis集群能够在这样的环境中工作,需要一个静态配置,每个节点都知道自己的公共地址。以下两个选项(其实有三个)用于此范围,分别是:
#
# * cluster-announce-ip  
# * cluster-announce-port
# * cluster-announce-bus-port
#
# Each instructs the node about its address, client port, and cluster message
# bus port. The information is then published in the header of the bus packets
# so that other nodes will be able to correctly map the address of the node
# publishing the information.
# 每个都指示节点关于其地址、客户机端口和集群消息总线端口。然后在总线包的报头中发布信息,以便其他节点能够正确地映射发布信息的节点的地址。
#
# If the above options are not used, the normal Redis Cluster auto-detection
# will be used instead.
# 如果不使用上述选项,则使用正常的Redis集群自动检测。
#
# Note that when remapped, the bus port may not be at the fixed offset of
# clients port + 10000, so you can specify any port and bus-port depending
# on how they get remapped. If the bus-port is not set, a fixed offset of
# 10000 will be used as usual.
# 请注意,当客户机在总线上重新映射端口时,可能无法指定端口的偏移量。如果没有设置总线端口,将像往常一样使用固定偏移量10000。
#
# Example:
#
# cluster-announce-ip 10.1.1.5
# cluster-announce-port 6379
# cluster-announce-bus-port 6380

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).
# 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.
# 您可以使用两个参数来配置slow log:一个参数告诉Redis为了让命令被记录下来,要超过多少执行时间(以微秒为单位),
# 另一个参数是慢日志的长度。记录新命令时,最旧的命令将从记录的命令队列中删除。

# 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秒。请注意,负数将禁用慢速日志,而值为零将强制记录每个命令。
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-max-len 128

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.
# Redis延迟监控子系统在运行时对不同的操作进行采样,以收集与Redis实例可能的延迟源相关的数据。
#
# Via the LATENCY command this information is available to the user that can
# print graphs and obtain reports.
# 通过LATENCY命令,用户可以打印图形并获取报告。
#
# 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.
# 默认情况下,延迟监视是禁用的,因为如果没有延迟问题,则通常不需要延迟监视,并且收集数据会对性能产生影响,虽然影响很小,
# 但可以在大负载下进行测量。如果需要,可以使用命令“CONFIG SET Latency monitor threshold<millises>”在运行时轻松启用延迟监视。
latency-monitor-threshold 0

EVENT NOTIFICATION事件通知

############################# EVENT NOTIFICATION ##############################
############################# 事件          通知 ##############################

# Redis can notify Pub/Sub clients about events happening in the key space.
# Redis可以将密钥空间中发生的事件通知发布/订阅客户端。
# 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:
# 例如,如果启用了keystpace events通知,并且客户机对存储在数据库0中的键“foo”执行DEL操作,则将通过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:
# 可以在一组类中选择Redis将通知的事件。每个类都由一个字符标识:
#
#  K     Keyspace events, published with __keyspace@<db>__ prefix.  			键空间通知,以 __keyspace@<db>__ 作为前缀发布。
#  E     Keyevent events, published with __keyevent@<db>__ prefix.  			键事件通知,以 __keyevent@<db>__ 作为前缀发布。
#  g     Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...   	DEL、EXPIRE、RENAME 等类型无关的通用命令的通知
#  $     String commands														字符串命令的通知
#  l     List commands															列表命令的通知
#  s     Set commands															set集合命令的通知
#  h     Hash commands															哈希命令的通知
#  z     Sorted set commands													有序set集合命令的通知
#  x     Expired events (events generated every time a key expires)				过期事件:每当有过期键被删除时发送
#  e     Evicted events (events generated when a key is evicted for maxmemory)	 驱逐(evict)事件:每当有键因为 maxmemory 政策而被删除时发送
#  t     Stream commands														流事件时发布
#  m     Key-miss events (Note: It is not included in the 'A' class)			key未命中事件,(不包含在A类别中)
#  A     Alias for g$lshzxet, so that the "AKE" string means all the events     参数 g$lshzxe 的别名
#        (Except key-miss events which are excluded from 'A' due to their
#         unique nature).
#
#  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:
# 例如:启动列表命令通知、Generic命令通知、键事件通知案例
#
#  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.
#  默认情况下,所有通知都被禁用,因为大多数用户不需要此功能,而且该功能有一些开销。
#  请注意,如果不指定K或E中的任何一个,则不会传递任何事件。
notify-keyspace-events ""

GOPHER SERVER GOPHER服务支持

############################### GOPHER SERVER #################################
############################### GOPHER 服务 #################################

# Redis contains an implementation of the Gopher protocol, as specified in
# the RFC 1436 (https://www.ietf.org/rfc/rfc1436.txt).
#
# The Gopher protocol was very popular in the late '90s. It is an alternative
# to the web, and the implementation both server and client side is so simple
# that the Redis server has just 100 lines of code in order to implement this
# support.
# Gopher协议在90年代末非常流行,它是web的一种替代方案,服务器端和客户端的实现都非常简单,Redis服务器只有100行代码来实现这种支持。
#
# What do you do with Gopher nowadays? Well Gopher never *really* died, and
# lately there is a movement in order for the Gopher more hierarchical content
# composed of just plain text documents to be resurrected. Some want a simpler
# internet, others believe that the mainstream internet became too much
# controlled, and it's cool to create an alternative space for people that
# want a bit of fresh air.
#
# Anyway for the 10nth birthday of the Redis, we gave it the Gopher protocol
# as a gift.
# 无论如何,在Redis 10岁生日那天,我们把Gopher协议作为礼物送给它。
#
# --- HOW IT WORKS? ---
# --- 这个怎么用? ---
#
# The Redis Gopher support uses the inline protocol of Redis, and specifically
# two kind of inline requests that were anyway illegal: an empty request
# or any request that starts with "/" (there are no Redis commands starting
# with such a slash). Normal RESP2/RESP3 requests are completely out of the
# path of the Gopher protocol implementation and are served as usual as well.
# Redis Gopher支持使用Redis的内联协议,特别是两种无论如何都是非法的内联请求:
# 空请求或任何以“/”开头的请求(没有以这样的斜杠开头的Redis命令)。正常的RESP2/RESP3
# 请求完全脱离了Gopher协议实现的路径,并且也像往常一样提供服务。
#
# If you open a connection to Redis when Gopher is enabled and send it
# a string like "/foo", if there is a key named "/foo" it is served via the
# Gopher protocol.
# 如果你连接一个启用Gopher服务的Redis,并向其发送类似“/foo”的字符串,那么如果有一个名为“/foo”的密钥,则通过Gopher协议提供服务。
#
# In order to create a real Gopher "hole" (the name of a Gopher site in Gopher
# talking), you likely need a script like the following:
# 为了创建一个真正的Gopher“hole”(Gopher talking中的一个Gopher站点的名称),您可能需要以下脚本:
#
#   https://github.com/antirez/gopher2redis
#
# --- SECURITY WARNING ---
# --- 安全        警告 ---
#
# If you plan to put Redis on the internet in a publicly accessible address
# to server Gopher pages MAKE SURE TO SET A PASSWORD to the instance.
# Once a password is set:
# 如果您计划将Redis放在internet上的一个公共可访问的地址,那么一定要为实例设置一个密码。设置密码后:
#
#   1. The Gopher server (when enabled, not by default) will still serve
#      content via Gopher.
# 	   Gopher服务器(启用时,不是默认情况下)仍将通过Gopher提供内容
#   2. However other commands cannot be called before the client will
#      authenticate.
#      但是,在客户端进行身份验证之前不能调用其他命令。
#
# So use the 'requirepass' option to protect your instance.
# 所以使用  “requirepass”(必须密钥) 选项来保护您的实例。
#
# Note that Gopher is not currently supported when 'io-threads-do-reads'
# is enabled.
# 请注意,当启用“io线程执行读取”时,当前不支持Gopher。
#
# To enable Gopher support, uncomment the following line and set the option
# from no (the default) to yes.
# 要启用Gopher支持,请取消注释以下行并将选项从no(默认值)设置为yes。
#
# gopher-enabled no

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的用ziplist,大于hash-max-ziplist-entries用hash
hash-max-ziplist-entries 512
# value大小小于等于list-max-ziplist-value的用ziplist,大于list-max-ziplist-value用list。
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到-1,意思是:
# -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.
# 正数意味着每个列表节点最多存储u个元素。
# 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.
# 性能最高的选项通常是-2(8KB大小)或-1(4KB大小),但是如果您的用例是唯一的,请根据需要调整设置。
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:
# 从快速压缩列表中排除压缩列表中每个压缩节点的 *exclude*。。列表的头和尾总是未压缩的,以便进行快速 push/pop 操作。设置为:
# 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"
#    1 表示在列表中有1个节点之后才开始压缩,无论是从头部还是尾部
#    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.
#    2 表示头的下一个节点与尾的上一个节点不会被压缩,中间的其他节点将被压缩。
# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
#    3 表示头的下两个节点与尾的上两个个节点不会被压缩,中间的其他节点将被压缩。
# 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.
# 集合只有一种特殊的编码方式:当一个集合由恰好是基数为10的64位有符号整数范围内的整数组成时。
# 为了使用这种特殊的内存节省编码,下面的配置设置设置了集合大小的限制。
# 设置最大的intset复数
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用ziplist,大于zset-max-ziplist-entries用zset。
zset-max-ziplist-entries 128
# value大小小于等于zset-max-ziplist-value用ziplist,大于zset-max-ziplist-value用zset。
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.
# 大于16000的值是完全无用的,因为在这一点上密集表示更节省内存。
#
# 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.
# value大小小于等于hll-sparse-max-bytes使用稀疏数据结构(sparse),
# 大于hll-sparse-max-bytes使用稠密的数据结构(dense)。一个比16000大的value是几乎没用的,
# 建议值为~3000,以便在不减慢过多PFADD(稀疏编码为O(N))的情况下利用空间高效编码的优点。当CPU不是问题,但空间是问题,并且数据集由许多基数在0-15000范围内的超日志组成时,该值可以提升到~10000。
hll-sparse-max-bytes 3000

# Streams macro node max size / items. The stream data structure is a radix
# tree of big nodes that encode multiple items inside. Using this configuration
# it is possible to configure how big a single node can be in bytes, and the
# maximum number of items it may contain before switching to a new node when
# appending new stream entries. If any of the following settings are set to
# zero, the limit is ignored, so for instance it is possible to set just a
# max entires limit by setting max-bytes to 0 and max-entries to the desired
# value.
# Streams 宏节点 每项最大值。流数据结构是一个由大节点组成的基数树,其中对多个项进行编码。
# 使用此配置,可以配置单个节点的大小(以字节为单位),以及在附加新的流条目时切换到新节点
# 之前可能包含的最大项数。如果将以下任何设置设置为零,则会忽略该限制,因此,例如,可以
# 通过将max bytes设置为0,将max entries设置为所需的值来设置max entires限制

# stream节点最大大小
stream-node-max-bytes 4096
# stream节点最大数量
stream-node-max-entries 100

# 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.
# 主动重新缓存每100毫秒CPU时间使用1毫秒,以帮助重新缓存主Redis哈希表(映射顶层的表
# 值的键)。Redis使用的哈希表实现(参见dict.c)执行延迟重散列:在重新散列表中运行的操作越多,
# 执行的重新散列“步骤”就越多,因此,如果服务器空闲,则重新散列永远不会完成,哈希表将使用更多内存。
#
# The default is to use this millisecond 10 times every second in order to
# actively rehash the main dictionaries, freeing memory when possible.
# 默认情况下,每秒使用此操作10次,以便主动重新整理主词典,尽可能释放内存。
#
# 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.
# 如果您有严格的延迟要求,并且在您的环境中,Redis可以不时地以2毫秒的延迟响应查询,那么使用“activerehashing no”。
#
# use "activerehashing yes" if you don't have such hard requirements but
# want to free memory asap when possible.
# 如果您没有这样的硬性要求,但希望尽快释放内存,请使用“activerehashingyes”。

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         普通客户端包括监视器客户端
# replica  -> replica clients								 从节点客户端
# pubsub -> clients subscribed to at least one pubsub channel or pattern   至少订阅了一个pubsub频道或模式的客户端
#
# The syntax of every client-output-buffer-limit directive is the following:
# 每个客户端输出缓冲区限制指令的语法如下:
#
# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
# 客户端输出缓冲区限制<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.
# 一旦达到硬限制,或者达到软限制并保持达到指定秒数(连续)时,客户端将立即断开连接。
# 因此,例如,如果硬限制为32兆字节,软限制为16兆字节/10秒,则当输出缓冲区的大小达到32兆字节时,
# 客户端将立即断开连接,但如果客户端达到16兆字节并连续超过限制10秒,客户端也将断开连接。
#
# 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 replica clients, since
# subscribers and replicas receive data in a push fashion.
# 相反,pubsub和replica客户端有一个默认限制,因为订阅服务器和副本以推送方式接收数据。
#
# Both the hard or the soft limit can be disabled by setting them to zero.
# 硬限制或软限制都可以通过设置为零来禁用。

# 对于normal client,第一个0表示取消hard limit,第二个0和第三个0表示取消soft limit,normal client默认取消限制,因为如果没有寻问,他们是不会接收数据的。
client-output-buffer-limit normal 0 0 0
# 对于slave client和MONITER client,如果client-output-buffer一旦超过256mb,又或者超过64mb持续60秒,那么服务器就会立即断开客户端连接。
client-output-buffer-limit replica 256mb 64mb 60
# 对于pubsub client,如果client-output-buffer一旦超过32mb,又或者超过8mb持续60秒,那么服务器就会立即断开客户端连接。
client-output-buffer-limit pubsub 32mb 8mb 60

# Client query buffers accumulate new commands. They are limited to a fixed
# amount by default in order to avoid that a protocol desynchronization (for
# instance due to a bug in the client) will lead to unbound memory usage in
# the query buffer. However you can configure it here if you have very special
# needs, such us huge multi/exec requests or alike.
# 客户端查询缓冲区累积新命令。默认情况下,它们被限制为固定数量,以避免协议取消同步
#(例如由于客户端中的错误)将导致查询缓冲区中未绑定内存的使用。但是,如果您有非常特殊的需要,
# 比如我们巨大的multi/exec请求或类似的请求,您可以在这里配置它。
#
# client-query-buffer-limit 1gb

# In the Redis protocol, bulk requests, that are, elements representing single
# strings, are normally limited to 512 mb. However you can change this limit
# here, but must be 1mb or greater
# 在Redis协议中,大容量请求,即代表单个字符串的元素,通常被限制在512MB。不过,您可以在这里更改此限制,但必须大于1mb
#
# proto-max-bulk-len 512mb

# 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.
# Redis调用一个内部函数来执行许多后台任务,比如超时关闭客户端的连接,清除从未被请求的过期密钥,等等。
#
# Not all tasks are performed with the same frequency, but Redis checks for
# tasks to perform according to the specified "hz" value.
# 并非所有任务都以相同的频率执行,但Redis会根据指定的“hz”值检查要执行的任务。
#
# 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.
# 默认情况下,“hz”设置为10。当Redis空闲时,提高该值将占用更多的CPU,但同时也会使Redis在多个密钥同时过期时响应更快,超时处理可能更精确。
#
# 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.
# 范围在1到500之间,但最好别超过100。大多数用户应该使用默认值10,并且只有在需要非常低延迟的环境中才将此值提高到100。

# redis执行任务的频率为1s除以hz。
hz 10

# Normally it is useful to have an HZ value which is proportional to the
# number of clients connected. This is useful in order, for instance, to
# avoid too many clients are processed for each background task invocation
# in order to avoid latency spikes.
# 通常,有一个与连接的客户机数量成比例的赫兹值是有用的。例如,
# 为了避免每次后台任务调用处理过多的客户机,以避免延迟峰值,这很有用。
#
# Since the default HZ value by default is conservatively set to 10, Redis
# offers, and enables by default, the ability to use an adaptive HZ value
# which will temporarily raise when there are many connected clients.
# 由于默认的默认HZ值保守地设置为10,Redis提供并在默认情况下启用使用自适应HZ值的能力,当有许多连接的客户端时,该值将临时提高。
#
# When dynamic HZ is enabled, the actual configured HZ will be used
# as a baseline, but multiples of the configured HZ value will be actually
# used as needed once more clients are connected. In this way an idle
# instance will use very little CPU time while a busy instance will be
# more responsive.
# 当启用动态赫兹时,实际配置的赫兹将被用作基线,但是一旦有更多的客户机连接起来,
# 实际上将根据需要使用配置的赫兹值的倍数。这样一来,空闲实例将占用很少的CPU时间,而繁忙的实例将具有更高的响应速度。
dynamic-hz yes

# 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文件时,如果启用以下选项,则每生成32mb的数据将对该文件进行fsync。
# 这对于以增量方式将文件提交到磁盘并避免较大的延迟峰值非常有用。

# aof以增量方式使用fsync保存
aof-rewrite-incremental-fsync yes

# When redis saves RDB 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.
# 当redis保存RDB文件时,如果启用以下选项,则每生成32mb的数据将对该文件进行fsync。
# 这对于以增量方式将文件提交到磁盘并避免较大的延迟峰值非常有用。

# rdb以增量方式使用fsync保存
rdb-save-incremental-fsync yes

# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
# idea to start with the default settings and only change them after investigating
# how to improve the performances and how the keys LFU change over time, which
# is possible to inspect via the OBJECT FREQ command.
# Redis LFU逐出(请参阅maxmemory设置)可以进行调整。但是,最好从默认设置开始,
# 在研究如何提高性能以及密钥LFU如何随时间变化后才更改它们,这可以通过OBJECT FREQ命令进行检查。
#
# There are two tunable parameters in the Redis LFU implementation: the
# counter logarithm factor and the counter decay time. It is important to
# understand what the two parameters mean before changing them.
#
# The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis
# uses a probabilistic increment with logarithmic behavior. Given the value
# of the old counter, when a key is accessed, the counter is incremented in
# this way:
# Redis-LFU实现中有两个可调参数:计数器对数因子和计数器衰减时间。在改变这两个参数之前,了解它们的含义是很重要的。
#
# 1. A random number R between 0 and 1 is extracted.                          提取0到1之间的随机数R。
# 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1).         概率P计算为1/(old_value*lfu_log_factor+1)。
# 3. The counter is incremented only if R < P.                                只有当R<P时,计数器才递增。
#
# The default lfu-log-factor is 10. This is a table of how the frequency
# counter changes with a different number of accesses with different
# logarithmic factors:													      默认的lfu日志系数为10。以下是频率计数器如何随不同对数因子的不同访问次数而变化的表:
#
# +--------+------------+------------+------------+------------+------------+
# | factor | 100 hits   | 1000 hits  | 100K hits  | 1M hits    | 10M hits   |
# +--------+------------+------------+------------+------------+------------+
# | 0      | 104        | 255        | 255        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 1      | 18         | 49         | 255        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 10     | 10         | 18         | 142        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 100    | 8          | 11         | 49         | 143        | 255        |
# +--------+------------+------------+------------+------------+------------+
#
# NOTE: The above table was obtained by running the following commands:
#       上表是通过运行以下命令获得的:
#
#   redis-benchmark -n 1000000 incr foo
#   redis-cli object freq foo
#
# NOTE 2: The counter initial value is 5 in order to give new objects a chance
# to accumulate hits.
# 计数器的初始值是5,以便给新对象一个累积命中的机会。
#
# The counter decay time is the time, in minutes, that must elapse in order
# for the key counter to be divided by two (or decremented if it has a value
# less <= 10).
# 计数器衰变时间是按键计数器除以2(如果其值小于等于10,则递减)必须经过的时间(以分钟为单位)。
#
# The default value for the lfu-decay-time is 1. A special value of 0 means to
# decay the counter every time it happens to be scanned.
# lfu衰退时间的默认值为1。一个特殊值0意味着每次扫描计数器时都会衰减计数器。
#
# lfu-log-factor 10
# lfu-decay-time 1

ACTIVE DEFRAGMENTATION活动碎片整理

########################### ACTIVE DEFRAGMENTATION #######################
########################### 活动          碎片整理 #######################
#
# What is active defragmentation?
# -------------------------------
#
# Active (online) defragmentation allows a Redis server to compact the
# spaces left between small allocations and deallocations of data in memory,
# thus allowing to reclaim back memory.
# 主动(在线)碎片整理允许Redis服务器压缩内存中数据的少量分配和释放之间的空间,从而允许回收内存。
#
# Fragmentation is a natural process that happens with every allocator (but
# less so with Jemalloc, fortunately) and certain workloads. Normally a server
# restart is needed in order to lower the fragmentation, or at least to flush
# away all the data and create it again. However thanks to this feature
# implemented by Oran Agra for Redis 4.0 this process can happen at runtime
# in a "hot" way, while the server is running.
# 碎片化是一个自然的过程,它发生在每个分配器(幸运的是Jemalloc)和某些工作负载上。
# 通常需要重新启动服务器以降低碎片,或者至少刷新所有数据并重新创建。不过,
# 多亏了OranAgra for Redis 4.0实现的这一特性,这个过程可以在服务器运行时以“热”的方式在运行时发生
#
# Basically when the fragmentation is over a certain level (see the
# configuration options below) Redis will start to create new copies of the
# values in contiguous memory regions by exploiting certain specific Jemalloc
# features (in order to understand if an allocation is causing fragmentation
# and to allocate it in a better place), and at the same time, will release the
# old copies of the data. This process, repeated incrementally for all the keys
# will cause the fragmentation to drop back to normal values.
# 基本上,当碎片超过某个级别(参见下面的配置选项)时,Redis将开始利用某些特定的Jemalloc特性
# 在连续内存区域中创建值的新副本(以便了解某个分配是否导致碎片并将其分配到更好的位置)
# ,同时,会发布旧的数据拷贝。对所有键增量重复此过程将导致碎片返回到正常值。
#
# Important things to understand:
# 需要了解的重要事项:
#
# 1. This feature is disabled by default, and only works if you compiled Redis
#    to use the copy of Jemalloc we ship with the source code of Redis.
#    This is the default with Linux builds.
#    此功能在默认情况下是禁用的,并且只有在您编译Redis以使用Redis源代码附带的Jemalloc副本时才起作用。这是Linux版本的默认设置。
#
# 2. You never need to enable this feature if you don't have fragmentation
#    issues.
# 	 如果没有碎片问题,则不需要启用此功能。
#
# 3. Once you experience fragmentation, you can enable this feature when
#    needed with the command "CONFIG SET activedefrag yes".
#    一旦遇到碎片,您可以在需要时使用命令“CONFIG SET activedefrag yes”来启用此功能。
#
# The configuration parameters are able to fine tune the behavior of the
# defragmentation process. If you are not sure about what they mean it is
# a good idea to leave the defaults untouched.
# 配置参数可以微调碎片整理过程的行为。如果您不确定它们的含义,那么最好保持默认值不变。

# Enabled active defragmentation
# 启用活动碎片整理
# activedefrag no

# Minimum amount of fragmentation waste to start active defrag
# 当碎片达到 100mb 时,开启内存碎片整理
# active-defrag-ignore-bytes 100mb

# Minimum percentage of fragmentation to start active defrag
# 当碎片超过 10% 时,开启内存碎片整理
# active-defrag-threshold-lower 10

# Maximum percentage of fragmentation at which we use maximum effort
# 内存碎片超过 100%,则尽最大努力整理
# active-defrag-threshold-upper 100

# Minimal effort for defrag in CPU percentage, to be used when the lower
# threshold is reached
# 内存自动整理占用资源最小百分比
# active-defrag-cycle-min 1

# Maximal effort for defrag in CPU percentage, to be used when the upper
# threshold is reached
# 内存自动整理占用资源最大百分比
# active-defrag-cycle-max 25

# Maximum number of set/hash/zset/list fields that will be processed from
# the main dictionary scan
# 将从主字典扫描中处理的set/hash/zset/list字段的最大数目
# active-defrag-max-scan-fields 1000

# Jemalloc background thread for purging will be enabled by default
# 默认情况下,将启用用于清除的Jemalloc后台线程
jemalloc-bg-thread yes

# It is possible to pin different threads and processes of Redis to specific
# CPUs in your system, in order to maximize the performances of the server.
# This is useful both in order to pin different Redis threads in different
# CPUs, but also in order to make sure that multiple Redis instances running
# in the same host will be pinned to different CPUs.
# 可以将Redis的不同线程和进程固定到系统中的特定cpu上,以最大限度地提高服务器的性能。
# 这有助于将不同的Redis线程固定在不同的cpu上,也可以确保在同一主机上运行的多个Redis实例被固定到不同的cpu上。
# 就是将redis线程与cpu线程绑定
#
# Normally you can do this using the "taskset" command, however it is also
# possible to this via Redis configuration directly, both in Linux and FreeBSD.
# 通常,您可以使用“taskset”命令来完成此操作,但是在Linux和FreeBSD中,也可以通过Redis配置直接实现。
#
# You can pin the server/IO threads, bio threads, aof rewrite child process, and
# the bgsave child process. The syntax to specify the cpu list is the same as
# the taskset command:
# 您可以固定服务器/IO线程、bio线程、aof重写子进程和bgsave子进程。指定cpu列表的语法与taskset命令相同:
#
# Set redis server/io threads to cpu affinity 0,2,4,6:
# 将redis 服务/io 线程绑定到cpu 线 0,2,4,6 上
# server_cpulist 0-7:2
#
# Set bio threads to cpu affinity 1,3:
# 将 bio线程绑定到cpu线 1,3 上
# bio_cpulist 1,3
#
# Set aof rewrite child process to cpu affinity 8,9,10,11:
# 将 AOF 子进程写操作绑定到 cpu线 8,9,10,11 上
# aof_rewrite_cpulist 8-11
#
# Set bgsave child process to cpu affinity 1,10,11
# 将子进程后台保存操作绑定到 cpu线 1,10,11 上
# bgsave_cpulist 1,10-11

sentinel.conf

哨兵配置,基本上百度翻译一遍就行,唯一有难点的就是ACL文件里面存什么,刚开始博主查官方文档时没发现案例还准备吐槽的,后来发现,使用redis的ACL指令,写两个带密码的自定义权限的用户进去,就知道文件保存的是什么了。

# Example sentinel.conf

# *** IMPORTANT ***
#
# By default Sentinel will not be reachable from interfaces different than
# localhost, either use the 'bind' directive to bind to a list of network
# interfaces, or disable protected mode with "protected-mode no" by
# adding it to this configuration file.
#
# Before doing that MAKE SURE the instance is protected from the outside
# world via firewalling or other means.
#
# For example you may use one of the following:
# 指定受保护模式下,可通过下列ip端口访问哨兵服务
# bind 127.0.0.1 192.168.1.1
bind 127.0.0.1 172.165.165.101
#
# protected-mode no
# 以保护模式启动哨兵服务
protected-mode yes

# port <sentinel-port>
# The port that this sentinel instance will run on
# 指定哨兵启动端口
port 26379

# By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
# daemonized.
# 以守护进程启动,就是后台启动的意思
daemonize yes

# When running daemonized, Redis Sentinel writes a pid file in
# /var/run/redis-sentinel.pid by default. You can specify a custom pid file
# location here.
# 指定pid文件
pidfile /data/redis/redis-sentinel_26379.pid

# Specify the log file name. Also the empty string can be used to force
# Sentinel to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
# 指定日志文件
logfile "/data/redis/log/redis-sentinel_26379.log"

# sentinel announce-ip <ip>
# sentinel announce-port <port>
sentinel announce-ip 172.165.165.101
sentinel announce-port 26379
# 
# The above two configuration directives are useful in environments where,
# because of NAT, Sentinel is reachable from outside via a non-local address.
#
# When announce-ip is provided, the Sentinel will claim the specified IP address
# in HELLO messages used to gossip its presence, instead of auto-detecting the
# local address as it usually does.
#
# Similarly when announce-port is provided and is valid and non-zero, Sentinel
# will announce the specified TCP port.
#
# The two options don't need to be used together, if only announce-ip is
# provided, the Sentinel will announce the specified IP and the server port
# as specified by the "port" option. If only announce-port is provided, the
# Sentinel will announce the auto-detected local IP and the specified port.
# 这一大段话的意思就是,指定告诉其他哨兵自己的访问ip、端口。主要当互相之间的
# 访问经过了nginx或其他代理软件后,无法直接获取通过本地ip访问。这里就配置成可
# 访问的代理ip、端口。和reids服务一样。 
#
# Example:
#
# sentinel announce-ip 1.2.3.4

# dir <working-directory>
# Every long running process should have a well-defined working directory.
# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
# for the process to don't interfere with administrative tasks such as
# unmounting filesystems.
# 工作空间,默认/tmp
dir /data/redis

# sentinel monitor <master-name> <ip> <redis-port> <quorum>
#
# Tells Sentinel to monitor this master, and to consider it in O_DOWN
# (Objectively Down) state only if at least <quorum> sentinels agree.
# 告诉哨兵建视这个redis-master,并且只有在至少 quorum 个哨兵统一的情况
# 下,才客观关闭该 redis-master
#
# Note that whatever is the ODOWN quorum, a Sentinel will require to
# be elected by the majority of the known Sentinels in order to
# start a failover, so no failover can be performed in minority.
# 就是哨兵的客观下线,是必须大多数哨兵同意才行,因此哨兵太少了,就不得行
# 那样的话就无法容错了
#
# Replicas are auto-discovered, so you don't need to specify replicas in
# any way. Sentinel itself will rewrite this configuration file adding
# the replicas using additional configuration options.
# Also note that the configuration file is rewritten when a
# replica is promoted to master.
# 复制副本是自动发现的,因此您不需要以任何方式指定复制副本。
# Sentinel本身将重写此配置文件,并使用其他配置选项添加副本。还要注意,
# 当复制副本升级为主副本时,配置文件会被重写。
#
# Note: master name should not include special characters or spaces.
# 注意:主控形状名称不应包含特殊字符或空格
# The valid charset is A-z 0-9 and the three characters ".-_".
# 有效的字符集是A-z 0-9和这三个字符“—”。
sentinel monitor mymaster 172.165.165.101 6379 2

# sentinel auth-pass <master-name> <password>
#
# Set the password to use to authenticate with the master and replicas.
# 设置用于向主副本和副本进行身份验证的密码。
# Useful if there is a password set in the Redis instances to monitor.
#
# Note that the master password is also used for replicas, so it is not
# possible to set a different password in masters and replicas instances
# if you want to be able to monitor these instances with Sentinel.
# 请注意,主密码也用于副本,因此,如果您希望能够使用Sentinel监视这些实例,
# 则无法在主密码和副本实例中设置不同的密码。就是主redis与从redis的密码必须相同
#
# However you can have Redis instances without the authentication enabled
# mixed with Redis instances requiring the authentication (as long as the
# password set is the same for all the instances requiring the password) as
# the AUTH command will have no effect in Redis instances with authentication
# switched off.
# 但是,您可以将未启用身份验证的Redis实例与需要身份验证的Redis实例混合使用(
# 只要对所有需要密码的实例设置的密码相同),因为AUTH命令在关闭身份验证的Redis
# 实例中无效。
# 就是允许混搭使用,有的要密码,有的不要密码,只要保证要密码的密码都相同即可
#
# Example:
#
# sentinel auth-pass mymaster MySUPER--secret-0123passw0rd
sentinel auth-pass sentinel-user 05a364a63b7cd0894a7f97817ac11041fe4f581d82aeeb3b0d773b9dcc19ba9c

# sentinel auth-user <master-name> <username>
#
# This is useful in order to authenticate to instances having ACL capabilities,
# that is, running Redis 6.0 or greater. When just auth-pass is provided the
# Sentinel instance will authenticate to Redis using the old "AUTH <pass>"
# method. When also an username is provided, it will use "AUTH <user> <pass>".
# In the Redis servers side, the ACL to provide just minimal access to
# Sentinel instances, should be configured along the following lines:
# 这对于向具有ACL功能的实例(即运行Redis 6.0或更高版本)进行身份验证非常有用。
# 当只提供auth pass时,Sentinel实例将使用旧的“auth<pass>方法对Redis进行身份验证。
# 同时提供用户名时,它将使用“AUTH<user><pass>”。在Redis服务器端,仅提供对Sentinel
# 实例的最小访问的ACL应按以下方式配置:
#
#     user sentinel-user >somepassword +client +subscribe +publish \
#                        +ping +info +multi +slaveof +config +client +exec on

# sentinel down-after-milliseconds <master-name> <milliseconds>
#
# Number of milliseconds the master (or any attached replica or sentinel) should
# be unreachable (as in, not acceptable reply to PING, continuously, for the
# specified period) in order to consider it in S_DOWN state (Subjectively
# Down).
# 设置超时主观下线毫秒数。哨兵连接redis服务超过了这个指定时间,则视该redis主观下线
#
# Default is 30 seconds.
sentinel down-after-milliseconds mymaster 30000

# requirepass <password>
#
# You can configure Sentinel itself to require a password, however when doing
# so Sentinel will try to authenticate with the same password to all the
# other Sentinels. So you need to configure all your Sentinels in a given
# group with the same "requirepass" password. Check the following documentation
# for more info: https://redis.io/topics/sentinel
# 意思就是说,你也可以给哨兵服务设置一个密码,就是如果一个设置了,其余的也必须设置这个密码


# sentinel parallel-syncs <master-name> <numreplicas>
#
# How many replicas we can reconfigure to point to the new replica simultaneously
# during the failover. Use a low number if you use the replicas to serve query
# to avoid that all the replicas will be unreachable at about the same
# time while performing the synchronization with the master.
# 指定了在执行故障转移时, 最多可以有多少个从服务器同时对新的主服务器进行同步
# 例如三个服务的话,死了一个,还剩两个,则允许一个对主服务器进行同步
sentinel parallel-syncs mymaster 1

# sentinel failover-timeout <master-name> <milliseconds>
#
# Specifies the failover timeout in milliseconds. It is used in many ways:
# 指定故障转移超时时间
#
# - The time needed to re-start a failover after a previous failover was
#   already tried against the same master by a given Sentinel, is two
#   times the failover timeout.
# 在给定的Sentinel已经针对同一主机尝试了上一次故障转移之后,
# 重新启动故障转移所需的时间是故障转移超时的两倍。
#
# - The time needed for a replica replicating to a wrong master according
#   to a Sentinel current configuration, to be forced to replicate
#   with the right master, is exactly the failover timeout (counting since
#   the moment a Sentinel detected the misconfiguration).
# 根据Sentinel当前配置,复制副本复制到错误主机所需的时间,强制复制到正确
# 主机所需的时间,正好是故障转移超时(从Sentinel检测到错误配置的那一刻起计算)。
#
# - The time needed to cancel a failover that is already in progress but
#   did not produced any configuration change (SLAVEOF NO ONE yet not
#   acknowledged by the promoted replica).
# 取消已在进行但未产生任何配置更改的故障转移所需的时间(从属于尚未被提升的复
# 制副本确认的任何人)。
#
# - The maximum time a failover in progress waits for all the replicas to be
#   reconfigured as replicas of the new master. However even after this time
#   the replicas will be reconfigured by the Sentinels anyway, but not with
#   the exact parallel-syncs progression as specified.
# 正在进行的故障转移等待将所有副本重新配置为新主机的副本的最长时间。
# 但是,即使在这段时间之后,复制副本也将由sentinel重新配置,但不会按照指定的
# 并行同步进程进行配置。
#
# Default is 3 minutes.
sentinel failover-timeout mymaster 180000

# SCRIPTS EXECUTION
# 执行脚本
#
# sentinel notification-script and sentinel reconfig-script are used in order
# to configure scripts that are called to notify the system administrator
# or to reconfigure clients after a failover. The scripts are executed
# with the following rules for error handling:
# sentinel通知脚本和sentinel reconfig脚本用于配置调用的脚本,以便在故障转移
# 后通知系统管理员或重新配置客户端。使用以下错误处理规则执行脚本:
#
# If script exits with "1" the execution is retried later (up to a maximum
# number of times currently set to 10).
# 如果脚本以“1”退出,则稍后将重试执行(最多可重试10次)。
#
# If script exits with "2" (or an higher value) the script execution is
# not retried.
# 如果脚本以“2”(或更高的值)退出,则不重试脚本执行。
#
# If script terminates because it receives a signal the behavior is the same
# as exit code 1.
# 如果脚本因为接收到信号而终止,则行为与退出代码1相同。
#
# A script has a maximum running time of 60 seconds. After this limit is
# reached the script is terminated with a SIGKILL and the execution retried.
# 脚本的最大运行时间为60秒。达到此限制后,脚本将以SIGKILL终止并重试执行。

# NOTIFICATION SCRIPT
# 通知脚本
#
# sentinel notification-script <master-name> <script-path>
# 
# Call the specified notification script for any sentinel event that is
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
# This script should notify the system administrator via email, SMS, or any
# other messaging system, that there is something wrong with the monitored
# Redis systems
# 为警告级别中生成的任何sentinel事件调用指定的通知脚本(例如-sdown、-odown等等)
# 。此脚本应通过电子邮件、SMS或任何其他消息传递系统通知系统管理员受监视的Redis
# 系统有问题。.
#
# The script is called with just two arguments: the first is the event type
# and the second the event description.
# 调用脚本时只有两个参数:第一个是事件类型,第二个是事件描述。
#
# The script must exist and be executable in order for sentinel to start if
# this option is provided.
# 如果提供了此选项,则脚本必须存在并可执行,以便sentinel启动。
#
# Example:
#
# sentinel notification-script mymaster /var/redis/notify.sh

# CLIENTS RECONFIGURATION SCRIPT
# 客户端重新配置脚本
#
# sentinel client-reconfig-script <master-name> <script-path>
#
# When the master changed because of a failover a script can be called in
# order to perform application-specific tasks to notify the clients that the
# configuration has changed and the master is at a different address.
# 由于故障转移而更改了主机时,可以调用脚本来执行特定于应用程序的任务,
# 以通知客户端配置已更改,并且主机位于不同的地址。
# 
# The following arguments are passed to the script:
#
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
#
# <state> is currently always "failover"
# <role> is either "leader" or "observer"
# 
# The arguments from-ip, from-port, to-ip, to-port are used to communicate
# the old address of the master and the new address of the elected replica
# (now a master).
# 参数from ip,from port,to ip,to port用于传递主机的旧地址和所选副本(现在是主机)的新地址。
#
# This script should be resistant to multiple invocations.
# 这个脚本应该能够抵抗多次调用。
#
# Example:
#
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh

# SECURITY
# 安全
#
# By default SENTINEL SET will not be able to change the notification-script
# and client-reconfig-script at runtime. This avoids a trivial security issue
# where clients can set the script to anything and trigger a failover in order
# to get the program executed.
# 默认情况下,SENTINEL SET将无法在运行时更改通知脚本和客户端重新配置脚本。
# 这避免了一个微不足道的安全问题,即客户端可以将脚本设置为任何值并触发故障转移以执行程序。

sentinel deny-scripts-reconfig yes

# REDIS COMMANDS RENAMING
# REDIS命令重命名
#
# Sometimes the Redis server has certain commands, that are needed for Sentinel
# to work correctly, renamed to unguessable strings. This is often the case
# of CONFIG and SLAVEOF in the context of providers that provide Redis as
# a service, and don't want the customers to reconfigure the instances outside
# of the administration console.
# 有时Redis服务器有一些Sentinel正常工作所需的命令,这些命令被重命名为不可使用的字符串。
# 在将Redis作为服务提供的提供者的上下文中,CONFIG和SLAVEOF常常是这种情况,
# 它们不希望客户在管理控制台之外重新配置实例。
# 就是为了安全起见,不允许客户在控制台以外的其他地方通过指令操作哨兵服务。所以重命名指令
#
# In such case it is possible to tell Sentinel to use different command names
# instead of the normal ones. For example if the master "mymaster", and the
# associated replicas, have "CONFIG" all renamed to "GUESSME", I could use:
# 在这种情况下,可以告诉Sentinel使用不同的命令名,而不是普通的命令名。例如,
# 如果主机“mymaster”和相关副本的“CONFIG”都重命名为“GUESSME”,

# SENTINEL rename-command mymaster CONFIG GUESSME
#
# After such configuration is set, every time Sentinel would use CONFIG it will
# use GUESSME instead. Note that there is no actual need to respect the command
# case, so writing "config guessme" is the same in the example above.
# 在设置了这样的配置之后,每次Sentinel使用CONFIG时,它都会使用GUESSME。
# 请注意,实际上不需要考虑命令大小写,因此在上面的示例中编写“config guessme”是相同的。
#
# SENTINEL SET can also be used in order to perform this configuration at runtime.
# 为了在运行时执行此配置,还可以使用SENTINEL SET。
#
# In order to set a command back to its original name (undo the renaming), it
# is possible to just rename a command to itself:
# 为了将命令设置回其原始名称(撤消重命名),可以只将命令重命名为其自身:
#
# SENTINEL rename-command mymaster CONFIG CONFIG

users.acl

user default off nopass ~* +@all
user admin-user on #6073ee0c1f33a7c55c023cfb5ae41202634ec5d47f5839766d7e9c72784692c7 ~* +@all
user redis-user on #b29890a1832f93ab561d6e5da14ac6cd6688a72674da66ba342e52dfb3fced0b
user stop-user on #aa655477ccee0866310f71602923f37351245c53fe77c178cf2f79b04d0b2cd0 +SHUTDOWN
user sentinel-user on #f52269d79c568147710decedb57dac72400211768eb1137097b5f67233f4290d -@all +subscribe +publish +client|setname +client|kill +config|rewrite +role +exec +slaveof +info +multi +ping +script|kill
user replica-user on #3ee15bb3d499740ccdc5ebf49b6f8b3f4a43dfc74b1597f6f3822023cbab008a -@all +ping +psync +replconf

参考地址:https://www.cnblogs.com/chuijingjing/p/12832678.html

百度翻译真香

由于英语渣渣,刚开始很多配置信息看不明白的就用有道翻译。然后翻译出来的更是天书,只能一个一个单词的翻译,然后自己去理解redis官方在配置文件里留的这段话到底是什么意思。后来用了下百度翻译。真TM的香,不得不说百度对于这些IT行业的专有名词处理的很好,感觉两者就完全不是一个层级的。从此卸载有道翻译。
一个具有注脚的文本。

posted @ 2021-08-08 16:07  临渊不羡渔  阅读(1038)  评论(0编辑  收藏  举报