Created
March 13, 2021 09:07
-
-
Save ficapy/b8eecaa718124de1c8fb8d8953c62ad5 to your computer and use it in GitHub Desktop.
redis.conf 中文翻译 版本6.2.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redis configuration file example. | |
# | |
# Note that in order to read the configuration file, Redis must be | |
# started with the file path as first argument: | |
# 注意,为了读取配置文件,Redis必须以文件路径作为第一个参数启动。 | |
# | |
# ./redis-server /path/to/redis.conf | |
# Note on units: when memory size is needed, it is possible to specify | |
# it in the usual form of 1k 5GB 4M and so forth: | |
# 注意单位:当需要内存大小时,可以用1k 5GB 4M等常用形式指定。 | |
# | |
# 1k => 1000 bytes | |
# 1kb => 1024 bytes | |
# 1m => 1000000 bytes | |
# 1mb => 1024*1024 bytes | |
# 1g => 1000000000 bytes | |
# 1gb => 1024*1024*1024 bytes | |
# | |
# units are case insensitive so 1GB 1Gb 1gB are all the same. | |
# 单位不分大小写,所以1GB 1Gb 1gB 作用相同 | |
################################## INCLUDES ################################### | |
# Include one or more other config files here. This is useful if you | |
# have a standard template that goes to all Redis servers but also need | |
# to customize a few per-server settings. Include files can include | |
# other files, so use this wisely. | |
# 在这里包含一个或多个其他配置文件。如果你有一个适用于所有Redis服务器的标准模板, | |
# 但也需要自定义一些每个服务器的设置,这很有用。包含文件可以包含其他文件,所以要选择性的使用这个配置 | |
# | |
# Notice option "include" won't be rewritten by command "CONFIG REWRITE" | |
# from admin or Redis Sentinel. Since Redis always uses the last processed | |
# line as value of a configuration directive, you'd better put includes | |
# at the beginning of this file to avoid overwriting config change at runtime. | |
# 注意选项include不会被管理员或Redis Sentinel的CONFIG REWRITE命令重写。 | |
# 由于Redis总是使用最后处理过的行作为配置指令的值,所以你最好把include放在文件开头,以避免覆盖了其他配置。 | |
# | |
# If instead you are interested in using includes to override configuration | |
# options, it is better to use include as the last line. | |
# 如果你想用include文件覆盖调其他配置,最好使用include作为最后一行。 | |
# | |
# include /path/to/local.conf | |
# include /path/to/other.conf | |
################################## 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 the network interfaces available on the server. | |
# It is possible to listen to just one or multiple selected interfaces using | |
# the "bind" configuration directive, followed by one or more IP addresses. | |
# 默认情况下,如果没有指定 bind 配置指令,Redis会监听服务器上所有可用网络接口的连接(即0.0.0.0)。 | |
# 可以使用 bind 配置指令监听一个或多个选定的接口,然后是一个或多个IP地址。 | |
# | |
# Examples: | |
# | |
# bind 192.168.1.100 10.0.0.1 | |
# bind 127.0.0.1 ::1 | |
# | |
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the | |
# internet, binding to all the interfaces is dangerous and will expose the | |
# instance to everybody on the internet. So by default we uncomment the | |
# following bind directive, that will force Redis to listen only into | |
# the IPv4 lookback interface address (this means Redis will be able to | |
# accept connections only from clients running into the same computer it | |
# is running). | |
# ~~~~警告 ~~~~如果运行Redis的计算机直接暴露在互联网上,绑定所有的接口是很危险的, | |
# 会让实例暴露在互联网上的所有人面前。所以默认情况下,我们取消注释bind指令, | |
# 这将强制Redis只监听到IPv4回环地址(这意味着Redis将只能接受来自运行到同一台计算机的客户端的连接) | |
# | |
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES | |
# JUST COMMENT THE FOLLOWING LINE. | |
# 如果你确定要让你的实例接收所有请求,只需注释掉它 | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
bind 127.0.0.1 ::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. | |
# 保护模式是一层安全保护,以避免在互联网上开放的Redis实例被访问和利用。 | |
# | |
# When protected mode is on and if: | |
# 当存在如下情况的时候保护模式开启 | |
# | |
# 1) The server is not binding explicitly to a set of addresses using the | |
# "bind" directive. | |
# 1)服务器没有使用 bind 指令明确地与一组地址进行绑定 | |
# 2) No password is configured. | |
# 2)没有配置密码 | |
# | |
# The server only accepts connections from clients connecting from the | |
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain | |
# sockets. | |
# 服务器只接受来自IPv4和IPv6环回地址127.0.0.1和::1以及Unix域套接字的客户端连接。 | |
# | |
# By default protected mode is enabled. You should disable it only if | |
# you are sure you want clients from other hosts to connect to Redis | |
# even if no authentication is configured, nor a specific set of interfaces | |
# are explicitly listed using the "bind" directive. | |
# 默认情况下,保护模式是启用的。只有当你确定你想让来自其他主机的客户端连接到Redis时, | |
# 才应该禁用它,即使没有配置认证,也没有使用 bind 指令明确列出一组特定的接口。 | |
protected-mode 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. | |
# 接受指定端口上的连接,默认为6379(IANA #815344)。如果指定了端口0,Redis将不会监听TCP套接字。 | |
port 6379 | |
# TCP listen() backlog. | |
# | |
# In high requests-per-second environments you need an high backlog in order | |
# to avoid slow clients connections issues. Note that the Linux kernel | |
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so | |
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog | |
# in order to get the desired effect. | |
# 在高QPS环境中,你需要一个高的backlog值,以避免客户机连接速度慢的问题。 | |
# 请注意,Linux内核会默默地将其截断到/proc/sys/net/core/somaxconn的值, | |
# 所以要确保同时增加somaxconn和tcp_max_syn_backlog的值,以获得预期的效果。 | |
tcp-backlog 511 | |
# Unix socket. | |
# | |
# Specify the path for the Unix socket that will be used to listen for | |
# incoming connections. There is no default, so Redis will not listen | |
# on a unix socket when not specified. | |
# 指定用于监听传入连接的Unix套接字的路径。没有默认值,所以当没有指定Unix套接字时,Redis不会监听 | |
# | |
# unixsocket /tmp/redis.sock | |
# unixsocketperm 700 | |
# Close the connection after a client is idle for N seconds (0 to disable) | |
# 在客户端空闲N秒后关闭连接(0表示禁用)。 | |
timeout 0 | |
# 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 ACK。这有两个原因。 | |
# | |
# 1) Detect dead peers. | |
# 1)检测死链接。 | |
# 2) Take the connection alive from the point of view of network | |
# equipment in the middle. | |
# 2)从中间网络设备的角度出发,保持链接活跃。 | |
# | |
# 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. | |
# On other kernels the period depends on the kernel configuration. | |
# 在Linux上,指定的值(以秒为单位)是用来发送ACK的周期。 | |
# 注意,关闭连接需要双倍的时间。在其他内核上,周期取决于内核的配置。 | |
# | |
# A reasonable value for this option is 300 seconds, which is the new | |
# Redis default starting with Redis 3.2.1. | |
# 这个选项的合理值是300秒,这是Redis 3.2.1开始的新的Redis默认值。 | |
tcp-keepalive 300 | |
################################# GENERAL ##################################### | |
# By default Redis does not run as a daemon. Use 'yes' if you need it. | |
# Note that Redis will write a pid file in /usr/local/var/run/redis.pid when daemonized. | |
# 默认情况下,Redis不作为守护进程运行。如果你需要的话,请使用'yes'。 | |
# 注意,当守护进程化时,Redis会在/usr/local/var/run/redis.pid中写入一个pid文件。 | |
daemonize no | |
# If you run Redis from upstart or systemd, Redis can interact with your | |
# supervision tree. Options: | |
# 如果你从upstart或systemd运行Redis,Redis可以与你的supervision tree进行交互。选项。 | |
# supervised no - no supervision interaction | |
# 无交互 | |
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode | |
# Redis进入SIGSTOP模式 | |
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET | |
# 将READY=1写入$NOTIFY_SOCKET。 | |
# supervised auto - detect upstart or systemd method based on | |
# UPSTART_JOB or NOTIFY_SOCKET environment variables | |
# 根据UPSTART_JOB或NOTIFY_SOCKET环境变量检测upstart或systemd方法 | |
# Note: these supervision methods only signal "process is ready." | |
# They do not enable continuous liveness pings back to your supervisor. | |
# 这些监督方法只发出 进程已就绪 的信号。它们并不能实现连续的ping回传给你的监管程序。 | |
supervised no | |
# If a pid file is specified, Redis writes it where specified at startup | |
# and removes it at exit. | |
# 如果指定了pid文件,Redis会在启动时将其写入指定的位置,并在退出时将其删除。 | |
# | |
# When the server runs non daemonized, no pid file is created if none is | |
# specified in the configuration. When the server is daemonized, the pid file | |
# is used even if not specified, defaulting to "/usr/local/var/run/redis.pid". | |
# 当服务器以非守护进程运行时,如果在配置中没有指定pid文件,则不会创建。 | |
# 当服务器运行在守护进程模式时,即使没有指定,也会使用pid文件,默认为"/usr/local/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文件,如果创建失败, 屁事没有,服务器照常启动,正常运行 | |
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) | |
# 指定服务器的verbosity级别 | |
# 以下之一: | |
# debug (很多信息,对开发/测试有用) | |
# verbose (很多很少有用的信息,但不像debug级别那样乱七八糟) | |
# notice (中等程度的啰嗦,可能是你在生产中想要的) | |
# warning (只记录非常重要/关键的消息) | |
loglevel notice | |
# Specify the log file name. Also the empty string can be used to force | |
# Redis to log on the standard output. Note that if you use standard | |
# output for logging but daemonize, logs will be sent to /dev/null | |
# 指定日志文件名。也可以使用空字符串来强制Redis在标准输出上进行日志记录。 | |
# 请注意,如果你使用标准输出进行日志记录,但守护进程,日志将被发送到/dev/null。 | |
logfile "" | |
# To enable logging to the system logger, just set 'syslog-enabled' to yes, | |
# and optionally update the other syslog parameters to suit your needs. | |
# 要启用系统日志记录,只需将'syslog-enabled'设置为 "是",并根据需要更新其他syslog参数。 | |
# syslog-enabled no | |
# Specify the syslog identity. | |
# 指定syslog身份 | |
# syslog-ident redis | |
# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. | |
# 指定syslog设施,必须是USER或在LOCAL0-LOCAL7之间 | |
# syslog-facility local0 | |
# Set the number of databases. The default database is DB 0, you can select | |
# a different one on a per-connection basis using SELECT <dbid> where | |
# dbid is a number between 0 and 'databases'-1 | |
# 设置数据库的数量。默认的数据库是DB 0,你可以根据每个连接选择不同的数据库, | |
# 使用SELECT <dbid>,其中dbid是0和'databases'-1之间的数字。 | |
databases 16 | |
# 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. | |
# 默认情况下,Redis只在开始登录到标准输出时,并且如果标准输出是TTY,才会显示一个ASCII艺术标识。 | |
# 基本上,这意味着通常只有在交互式会话中才会显示一个标识。 | |
# | |
# 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. | |
# 然而,通过将以下选项设置为 "是",可以强制执行4.0之前的行为,并始终在启动日志中显示ASCII艺术标识。 | |
always-show-logo yes | |
################################ SNAPSHOTTING ################################ | |
# | |
# Save the DB on disk: | |
# 保存数据库文件到磁盘 | |
# | |
# save <seconds> <changes> | |
# | |
# Will save the DB if both the given number of seconds and the given | |
# number of write operations against the DB occurred. | |
# 如果在规定的时间内发生规定的写入次数,则触发保存操作 | |
# | |
# In the example below the behaviour will be to save: | |
# after 900 sec (15 min) if at least 1 key changed | |
# after 300 sec (5 min) if at least 10 keys changed | |
# after 60 sec if at least 10000 keys changed | |
# 下面的例子含义是这样的(触发保存) | |
# 900秒(15分钟)后,至少有一个键发生了变化 | |
# 300秒(5分钟)后,至少有10个键发生了变化 | |
# 60秒后,至少有10000个键发生了变化 | |
# | |
# Note: you can disable saving completely by commenting out all "save" lines. | |
# 注意:你可以通过注释所有 "保存 "行来完全禁止保存。 | |
# | |
# 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 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. | |
# 默认情况下,如果启用了RDB快照(至少有一个保存点),并且最新的后台保存失败, | |
# Redis将停止接受写入。这将使用户意识到(以一种硬性的方式),数据没有在磁盘上正常持久化, | |
# 否则有可能没有人注意到,会发生一些灾难。 | |
# | |
# If the background saving process will start working again Redis will | |
# automatically allow writes again. | |
# 如果后台保存过程重新开始工作,Redis将自动允许再次写入。 | |
# | |
# However if you have setup your proper monitoring of the Redis server | |
# and persistence, you may want to disable this feature so that Redis will | |
# continue to work as usual even if there are problems with disk, | |
# permissions, and so forth. | |
# 但是如果你已经设置了对Redis服务器和持久性的适当监控,你可能会希望禁用这个功能, | |
# 这样即使出现磁盘、权限等问题,Redis也能继续正常工作。 | |
stop-writes-on-bgsave-error yes | |
# Compress string objects using LZF when dump .rdb databases? | |
# For default that's set to 'yes' as it's almost always a win. | |
# If you want to save some CPU in the saving child set it to 'no' but | |
# the dataset will likely be bigger if you have compressible values or keys. | |
# 在保存rdb数据库时使用LZF压缩字符串对象?默认情况下,设置为'是',因为这几乎总是有利的。 | |
# 如果你想在保存子程序中节省一些CPU,就把它设置为'no',但如果你有可压缩的值或键,数据集可能会更大。 | |
rdbcompression yes | |
# Since version 5 of RDB a CRC64 checksum is placed at the end of the file. | |
# This makes the format more resistant to corruption but there is a performance | |
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it | |
# for maximum performances. | |
# 自RDB第5版以来,CRC64校验和被放在文件的最后。这使得格式更不易损坏,但在保存和加载RDB文件时, | |
# 会对性能产生影响(大约10%),所以你可以禁用它以获得最大性能。 | |
# | |
# RDB files created with checksum disabled have a checksum of zero that will | |
# tell the loading code to skip the check. | |
# 在禁用校验和的情况下创建的RDB文件的校验和为0,会告诉加载代码跳过校验。 | |
rdbchecksum yes | |
# The filename where to dump the DB | |
# 保存DB的文件名 | |
dbfilename dump.rdb | |
# The working directory. | |
# | |
# The DB will be written inside this directory, with the filename specified | |
# above using the 'dbfilename' configuration directive. | |
# | |
# The Append Only File will also be created inside this directory. | |
# | |
# Note that you must specify a directory here, not a file name. | |
# 工作目录 | |
# DB将被写入这个目录,并使用上面'dbfilename'配置指令指定的文件名 | |
# Append Only文件也将在这个目录下创建 | |
# 注意,你必须在这里指定一个目录,而不是一个文件名。 | |
dir /usr/local/var/db/redis/ | |
################################# REPLICATION ################################# | |
# Master-Slave replication. Use slaveof to make a Redis instance a copy of | |
# another Redis server. A few things to understand ASAP about Redis replication. | |
# 主从复制。使用slaveof让一个Redis实例成为另一个Redis服务器的副本。关于Redis复制,要尽快了解一些事情。 | |
# | |
# 1) Redis replication is asynchronous, but you can configure a master to | |
# stop accepting writes if it appears to be not connected with at least | |
# a given number of slaves. | |
# 1)Redis复制是异步的,但你可以配置一个Master,如果它看起来没有与至少给定数量的slave连接,则停止接受写入。 | |
# 2) Redis slaves are able to perform a partial resynchronization with the | |
# master if the replication link is lost for a relatively small amount of | |
# time. You may want to configure the replication backlog size (see the next | |
# sections of this file) with a sensible value depending on your needs. | |
# 2)如果复制链路丢失的时间比较少,Redis从机能够与主机进行部分重新同步。你可能需要根据你的需求, | |
# 用一个合理的值来配置复制backlog大小(参见本文件的下一节)。 | |
# 3) Replication is automatic and does not need user intervention. After a | |
# network partition slaves automatically try to reconnect to masters | |
# and resynchronize with them. | |
# 3)复制是自动的,不需要用户干预。网络分区后,slave会自动尝试重新连接到主机,并与主机重新同步。 | |
# | |
# slaveof <masterip> <masterport> | |
# If the master is password protected (using the "requirepass" configuration | |
# directive below) it is possible to tell the slave to authenticate before | |
# starting the replication synchronization process, otherwise the master will | |
# refuse the slave request. | |
# 如果master是有密码保护的(使用下面的 "requirepass "配置指令), | |
# 可以告诉从站在启动复制同步过程前进行身份验证,否则master会拒绝slave的请求。 | |
# | |
# masterauth <master-password> | |
# When a slave loses its connection with the master, or when the replication | |
# is still in progress, the slave can act in two different ways: | |
# 当一个slave失去与master的连接时,或者当复制仍在进行时,slave可以以两种不同的方式行动。 | |
# | |
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will | |
# still reply to client requests, possibly with out of date data, or the | |
# data set may just be empty if this is the first synchronization. | |
# 1) 如果slave-serve-stale-data被设置为 "是"(默认值),那么slave仍然会回复客户端的请求, | |
# 可能会有过时的数据,或者如果这是第一次同步,数据集可能只是空的。 | |
# | |
# 2) if slave-serve-stale-data is set to 'no' the slave will reply with | |
# an error "SYNC with master in progress" to all the kind of commands | |
# but to INFO and SLAVEOF. | |
# 2)如果slave-serve-stale-data设置为 "no", | |
# 则slave将对所有类型的命令(除了INFO和SLAVEOF)回复错误 "SYNC with master in progress"。 | |
# | |
slave-serve-stale-data yes | |
# You can configure a slave instance to accept writes or not. Writing against | |
# a slave instance may be useful to store some ephemeral data (because data | |
# written on a slave will be easily deleted after resync with the master) but | |
# may also cause problems if clients are writing to it because of a | |
# misconfiguration. | |
# 您可以配置一个slave实例接受或不接受写入。针对slave实例的写入可能对存储一些短暂的数据很有用 | |
#(因为在slave实例上写入的数据在与master重新同步后很容易被删除),但如果客户机因配置错误而向其写入, | |
# 也可能会造成问题。 | |
# | |
# Since Redis 2.6 by default slaves are read-only. | |
# Redis 2.6开始默认情况下slave是只读的。 | |
# | |
# Note: read only slaves are not designed to be exposed to untrusted clients | |
# on the internet. It's just a protection layer against misuse of the instance. | |
# Still a read only slave exports by default all the administrative commands | |
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve | |
# security of read only slaves using 'rename-command' to shadow all the | |
# administrative / dangerous commands. | |
# 注意:只读slave不是为了暴露在互联网上不信任的客户端上。这只是防止实例被滥用的一个保护层。 | |
# 还是一个只读slave默认导出所有的管理命令,如CONFIG、DEBUG等。在有限的范围内, | |
# 你可以使用'rename-command'来提高只读slave的安全性,以屏蔽所有管理/危险命令。 | |
slave-read-only yes | |
# Replication SYNC strategy: disk or socket. | |
# 复制SYNC策略:磁盘或socket。 | |
# | |
# ------------------------------------------------------- | |
# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY | |
# 警告:无磁盘复制目前还处于试验阶段。 | |
# ------------------------------------------------------- | |
# | |
# New slaves and reconnecting slaves that are not able to continue the replication | |
# process just receiving differences, need to do what is called a "full | |
# synchronization". An RDB file is transmitted from the master to the slaves. | |
# The transmission can happen in two different ways: | |
# 新的slave和重新连接的slave,如果只是接收差异,无法继续复制过程,需要做所谓的 "完全同步"。 | |
# 一个RDB文件从master传输到slave。传输可以通过两种不同的方式进行。 | |
# | |
# 1) Disk-backed: The Redis master creates a new process that writes the RDB | |
# file on disk. Later the file is transferred by the parent | |
# process to the slaves incrementally. | |
# 1)磁盘: Redis master创建一个新进程,将RDB文件写入磁盘。之后该文件由父进程递增传输给slave进程。 | |
# 2) Diskless: The Redis master creates a new process that directly writes the | |
# RDB file to slave sockets, without touching the disk at all. | |
# 2)无磁盘: Redis master创建一个新的进程,直接将RDB文件写入slave套接字,完全不接触磁盘。 | |
# | |
# With disk-backed replication, while the RDB file is generated, more slaves | |
# can be queued and served with the RDB file as soon as the current child producing | |
# the RDB file finishes its work. With diskless replication instead once | |
# the transfer starts, new slaves arriving will be queued and a new transfer | |
# will start when the current one terminates. | |
# 使用有磁盘的复制,在RDB文件生成的同时,更多的slave可以排队,一旦当前生成RDB文件的子进程完成工作, | |
# 就可以用RDB文件服务。而使用无盘复制则一旦传输开始,新到达的slave将被排队,当当前的slave终止时,新的传输将开始。 | |
# 注:相当于无盘复制的时候,生成临时文件到内存,一段段复制 | |
# | |
# When diskless replication is used, the master waits a configurable amount of | |
# time (in seconds) before starting the transfer in the hope that multiple slaves | |
# will arrive and the transfer can be parallelized. | |
# 当使用无盘复制时,master在开始传输前会等待一段可配置的时间(以秒为单位),希望多个从站到达,传输可以并行化。 | |
# | |
# With slow disks and fast (large bandwidth) networks, diskless replication | |
# works better. | |
# 在磁盘速度慢、网络速度快(带宽大)的情况下,无盘复制效果更好。 | |
repl-diskless-sync no | |
# When diskless replication is enabled, it is possible to configure the delay | |
# the server waits in order to spawn the child that transfers the RDB via socket | |
# to the slaves. | |
# 当启用无盘复制时,可以配置服务器等待的延迟,以便生成通过socket将RDB传输到slave的子程序。 | |
# | |
# This is important since once the transfer starts, it is not possible to serve | |
# new slaves arriving, that will be queued for the next RDB transfer, so the server | |
# waits a delay in order to let more slaves arrive. | |
# 这一点很重要,因为一旦传输开始,就不可能为新到达的slave提供服务,这些slave将排队等待下一次RDB传输, | |
# 所以服务器会等待一个延迟,以便让更多的slave到达。 | |
# | |
# The delay is specified in seconds, and by default is 5 seconds. To disable | |
# it entirely just set it to 0 seconds and the transfer will start ASAP. | |
# 延时以秒为单位,默认为5秒。如果要完全禁用它,只需将其设置为0秒,传输将尽快开始。 | |
repl-diskless-sync-delay 5 | |
# Slaves send PINGs to server in a predefined interval. It's possible to change | |
# this interval with the repl_ping_slave_period option. The default value is 10 | |
# seconds. | |
# salve在预定义的时间间隔内向服务器发送PING。可以通过 repl_ping_slave_period 选项来改变这个间隔。默认值是10秒。 | |
# | |
# repl-ping-slave-period 10 | |
# The following option sets the replication timeout for: | |
# 以下选项设置了复制超时时间: | |
# | |
# 1) Bulk transfer I/O during SYNC, from the point of view of slave. | |
# 1)SYNC期间的批量传输I/O,从slave的角度来看。 | |
# 2) Master timeout from the point of view of slaves (data, pings). | |
# 2)从slave(数据、ping)的角度看master超时。 | |
# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings). | |
# 3)从master的角度看,slave超时(REPLCONF ACK pings)。 | |
# | |
# It is important to make sure that this value is greater than the value | |
# specified for repl-ping-slave-period otherwise a timeout will be detected | |
# every time there is low traffic between the master and the slave. | |
# 重要的是要确保这个值大于 repl-ping-slave-period 的指定值,否则每次master和slave之间的流量较低时都会检测到超时。 | |
# | |
# repl-timeout 60 | |
# Disable TCP_NODELAY on the slave socket after SYNC? | |
# SYNC后禁用slave socket上的TCP_NODELAY? | |
# | |
# If you select "yes" Redis will use a smaller number of TCP packets and | |
# less bandwidth to send data to slaves. But this can add a delay for | |
# the data to appear on the slave side, up to 40 milliseconds with | |
# Linux kernels using a default configuration. | |
# 如果选择 "yes",Redis将使用较少的TCP数据包和较少的带宽向slave发送数据。 | |
# 但这会增加数据在slave端出现的延迟,在Linux内核使用默认配置的情况下,延迟可达40毫秒。 | |
# | |
# If you select "no" the delay for data to appear on the slave side will | |
# be reduced but more bandwidth will be used for replication. | |
# 如果选择 "no",则会减少数据在slave侧出现的延迟,但会有更多带宽用于复制。 | |
# | |
# By default we optimize for low latency, but in very high traffic conditions | |
# or when the master and slaves are many hops away, turning this to "yes" may | |
# be a good idea. | |
# 默认情况下,我们会对低延迟进行优化,但在非常高的流量条件下,或者当master和slave有很多跳的距离时, | |
# 将此设置为 "yes" 可能是个好主意。 | |
repl-disable-tcp-nodelay no | |
# Set the replication backlog size. The backlog is a buffer that accumulates | |
# slave data when slaves are disconnected for some time, so that when a slave | |
# wants to reconnect again, often a full resync is not needed, but a partial | |
# resync is enough, just passing the portion of data the slave missed while | |
# disconnected. | |
# 设置复制的backlog大小。backlog是一个缓冲区,当slave断开连接一段时间后,会将slave数据积累起来, | |
# 这样当slave想再次连接的时候,往往不需要进行完整的重新同步,只需要进行部分重新同步即可, | |
# 只需要传递slave在断开连接时遗漏的那部分数据即可。 | |
# | |
# The bigger the replication backlog, the longer the time the slave can be | |
# disconnected and later be able to perform a partial resynchronization. | |
# backlog越大,从机可以断开连接的时间越长,以后就可以进行部分重新同步。 | |
# | |
# The backlog is only allocated once there is at least a slave connected. | |
# 只有当至少有一个slave连接时,才会分配backlog。 | |
# | |
# repl-backlog-size 1mb | |
# After a master has no longer connected slaves for some time, the backlog | |
# will be freed. The following option configures the amount of seconds that | |
# need to elapse, starting from the time the last slave disconnected, for | |
# the backlog buffer to be freed. | |
# 当master不再连接slave一段时间后,将释放backlog。 | |
# 下面的选项配置了从最后一个slave断开连接开始,需要经过多少秒才能释放backlog缓冲区的时间。 | |
# | |
# Note that slaves never free the backlog for timeout, since they may be | |
# promoted to masters later, and should be able to correctly "partially | |
# resynchronize" with the slaves: hence they should always accumulate backlog. | |
# 需要注意的是,slave永远不会因为超时而释放backlog,因为它们以后可能会晋升为主机, | |
# 并且应该能够正确地与slave "部分重新同步":因此,它们应该总是积累backlog。 | |
# | |
# A value of 0 means to never release the backlog. | |
# 值为0意味着永远不会释放 | |
# | |
# repl-backlog-ttl 3600 | |
# The slave priority is an integer number published by Redis in the INFO output. | |
# It is used by Redis Sentinel in order to select a slave to promote into a | |
# master if the master is no longer working correctly. | |
# slave优先级是Redis在INFO输出中公布的一个整数。Redis Sentinel使用它来选择一个slave, | |
# 以便在master不再正常工作时将其晋升为主机。 | |
# | |
# A slave with a low priority number is considered better for promotion, so | |
# for instance if there are three slaves with priority 10, 100, 25 Sentinel will | |
# pick the one with priority 10, that is the lowest. | |
# 优先级数低的slave被认为是比较好晋升的,比如说有3个slave,优先级10、100、25的哨兵会选优先级10的 | |
# | |
# However a special priority of 0 marks the slave as not able to perform the | |
# role of master, so a slave with priority of 0 will never be selected by | |
# Redis Sentinel for promotion. | |
# 然而特殊的优先级为0,则标志着该slave无法胜任master的角色,所以优先级为0的slave将永远不会被Redis哨兵选中晋升。 | |
# | |
# By default the priority is 100. | |
# 默认情况下,优先级为100。 | |
slave-priority 100 | |
# It is possible for a master to stop accepting writes if there are less than | |
# N slaves connected, having a lag less or equal than M seconds. | |
# 如果连接的slave少于N个,滞后小于或等于M秒,master有可能停止接受写入。 | |
# | |
# The N slaves need to be in "online" state. | |
# N个slave需要处于 "在线 "状态。 | |
# | |
# The lag in seconds, that must be <= the specified value, is calculated from | |
# the last ping received from the slave, that is usually sent every second. | |
# 以秒为单位的滞后,必须<=指定的值,是从slave收到的最后一次ping计算出来的,通常是每秒发送一次。 | |
# | |
# This option does not GUARANTEE that N replicas will accept the write, but | |
# will limit the window of exposure for lost writes in case not enough slaves | |
# are available, to the specified number of seconds. | |
# 这个选项并不保证N个副本会接受写入,但会在没有足够的slave可用的情况下,将丢失写入的暴露窗口限制在指定的秒数内。 | |
# | |
# For example to require at least 3 slaves with a lag <= 10 seconds use: | |
# 例如要求至少有3个滞后<=10秒的slave | |
# | |
# min-slaves-to-write 3 | |
# min-slaves-max-lag 10 | |
# | |
# Setting one or the other to 0 disables the feature. | |
# 将其中一个或另一个设置为0,则禁用该功能。 | |
# | |
# By default min-slaves-to-write is set to 0 (feature disabled) and | |
# min-slaves-max-lag is set to 10. | |
# 默认情况下,min-slaves-to-write被设置为0(功能被禁用),min-slaves-max-lag被设置为10。 | |
# A Redis master is able to list the address and port of the attached | |
# slaves in different ways. For example the "INFO replication" section | |
# offers this information, which is used, among other tools, by | |
# Redis Sentinel in order to discover slave instances. | |
# Another place where this info is available is in the output of the | |
# "ROLE" command of a master. | |
# 一个Redis master能够以不同的方式列出所连接的slave的地址和端口。 | |
# 例如,"INFO replication "部分提供了这些信息,Redis Sentinel使用这些信息和其他工具来发现slave实例。 | |
# 另一个提供这些信息的地方是在master的 "ROLE "命令的输出中。 | |
# | |
# The listed IP and address normally reported by a slave is obtained | |
# in the following way: | |
# 通常由slave报告的列表IP和地址是通过以下方式获得的。 | |
# | |
# IP: The address is auto detected by checking the peer address | |
# of the socket used by the slave to connect with the master. | |
# IP:通过检查slave与master连接时使用的socket的对等地址来自动检测地址。 | |
# | |
# Port: The port is communicated by the slave during the replication | |
# handshake, and is normally the port that the slave is using to | |
# list for connections. | |
# Port:在复制握手时由slave传达的端口,通常是slave用来列出连接的端口??? | |
# | |
# However when port forwarding or Network Address Translation (NAT) is | |
# used, the slave may be actually reachable via different IP and port | |
# pairs. The following two options can be used by a slave in order to | |
# report to its master a specific set of IP and port, so that both INFO | |
# and ROLE will report those values. | |
# 然而,当使用端口转发或网络地址转换(NAT)时,slave实际上可能可以通过不同的 IP 和端口对进行访问。 | |
# slave可以使用以下两个选项,以便向其主站报告一组特定的 IP 和端口,这样 INFO 和 ROLE 都会报告这些值。 | |
# | |
# | |
# There is no need to use both the options if you need to override just | |
# the port or the IP address. | |
# 如果你只需要覆盖端口或IP地址,就不需要使用这两个选项。 | |
# | |
# slave-announce-ip 5.5.5.5 | |
# slave-announce-port 1234 | |
################################## SECURITY ################################### | |
# Require clients to issue AUTH <PASSWORD> before processing any other | |
# commands. This might be useful in environments in which you do not trust | |
# others with access to the host running redis-server. | |
# 要求客户端在处理任何其他命令之前,先发出AUTH <PASSWORD>。 这在不信任他人能够访问运行redis-server的主机的环境中可能很有用。 | |
# | |
# This should stay commented out for backward compatibility and because most | |
# people do not need auth (e.g. they run their own servers). | |
# 为了向后兼容性,并且因为大多数人不需要授权(例如,他们运行自己的服务器),这个应该保留注释。 | |
# | |
# Warning: since Redis is pretty fast an outside user can try up to | |
# 150k passwords per second against a good box. This means that you should | |
# use a very strong password otherwise it will be very easy to break. | |
# 警告:由于Redis的速度相当快,一个外部用户可以针对一个好的盒子每秒尝试多达150k个密码。这意味着你应该使用一个非常强大的密码,否则它将很容易被破解。 | |
# | |
# requirepass foobared | |
# Command renaming. | |
# | |
# It is possible to change the name of dangerous commands in a shared | |
# environment. For instance the CONFIG command may be renamed into something | |
# hard to guess so that it will still be available for internal-use tools | |
# but not available for general clients. | |
# 在共享环境中可以改变危险命令的名称。例如,CONFIG命令可能会被重新命名为难以猜测的名称,这样它仍可用于内部使用的工具,但不能用于一般客户。 | |
# | |
# Example: | |
# | |
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 | |
# | |
# It is also possible to completely kill a command by renaming it into | |
# an empty string: | |
# 也可以通过将一个命令重命名为空字符串来彻底禁用它。 | |
# | |
# rename-command CONFIG "" | |
# | |
# Please note that changing the name of commands that are logged into the | |
# AOF file or transmitted to slaves may cause problems. | |
# 请注意,变更会记录到AOF文件然后传输到slave, 这可能会导致问题。 | |
################################### 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保留了一些文件描述符供内部使用)。 | |
# | |
# Once the limit is reached Redis will close all the new connections sending | |
# an error 'max number of clients reached'. | |
# 一旦达到限制,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-policy)尝试删除key | |
# | |
# If Redis can't remove keys according to the policy, or if the policy is | |
# set to 'noeviction', Redis will start to reply with errors to commands | |
# that would use more memory, like SET, LPUSH, and so on, and will continue | |
# to reply to read-only commands like GET. | |
# 如果Redis不能根据策略删除key,或者策略设置为 "noeviction",Redis就会开始对SET、LPUSH等会占用更多内存的命令进行错误回复, | |
# 对GET等只读命令则会继续回复。 | |
# | |
# This option is usually useful when using Redis as an LRU 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 slaves attached to an instance with maxmemory on, | |
# the size of the output buffers needed to feed the slaves are subtracted | |
# from the used memory count, so that network problems / resyncs will | |
# not trigger a loop where keys are evicted, and in turn the output | |
# buffer of slaves is full with DELs of keys evicted triggering the deletion | |
# of more keys, and so forth until the database is completely emptied. | |
# 警告:如果你在开启maxmemory的情况下将slave连接到实例上,那么slave所需的输出缓冲区的大小就会从使用的内存数中减去, | |
# 这样网络问题/重新同步就不会触发键被驱逐的循环,反过来slave的输出缓冲区满了, | |
# 被驱逐的键的DEL就会触发更多键的删除,以此类推,直到数据库完全清空。 | |
# | |
# In short... if you have slaves attached it is suggested that you set a lower | |
# limit for maxmemory so that there is some free RAM on the system for slave | |
# output buffers (but this is not needed if the policy is 'noeviction'). | |
# 简而言之......如果你连接了slave,建议你为maxmemory设置一个下限, | |
# 这样系统上就有一些空闲的RAM用于slave输出缓冲区(但如果策略是 "noeviction",就不需要这样做)。 | |
# | |
# maxmemory <bytes> | |
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory | |
# is reached. You can select among five behaviors: | |
# MAXMEMORY POLICY:当达到maxmemory时,Redis将如何选择要删除的内容。你可以在五个行为中选择。 | |
# | |
# volatile-lru -> Evict using approximated LRU among the keys with an expire set. | |
# 在有过期集的key中使用近似LRU进行删除 | |
# allkeys-lru -> Evict any key using approximated LRU. | |
# 使用近似LRU删除任何key。 | |
# volatile-lfu -> Evict using approximated LFU among the keys with an expire set. | |
# 在有过期集的key中使用近似LFU进行删除。 | |
# allkeys-lfu -> Evict any key using approximated LFU. | |
# 使用近似的LFU删除任何key。 | |
# volatile-random -> Remove a random key among the ones with an expire set. | |
# 在有过期设置的随机key中删除一个。 | |
# allkeys-random -> Remove a random key, any key. | |
# 随机删除一个key | |
# volatile-ttl -> Remove the key with the nearest expire time (minor TTL) | |
# 删除过期时间最近的key(小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. | |
# 注意:使用上述任何一种策略,当没有合适的key进行删除时,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 | |
# 在编写本报告之日,这些命令是:xxxxx | |
# | |
# 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. For default Redis will check five keys and pick the one that was | |
# used less recently, you can change the sample size using the following | |
# configuration directive. | |
# LRU、LFU和最小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 | |
############################# 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(非阻塞DEL)以及FLUSHALL和FLUSHDB命令的ASYNC选项, | |
# 以便在后台回收内存。这些命令是在恒定时间内执行的。另一个线程将以最快的速度在后台增量释放对象。 | |
# | |
# 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. | |
# 1)在删除时,由于maxmemory和maxmemory策略的配置,为了给新数据腾出空间,在不超过指定内存限制的情况下。 | |
# 2) Because of expire: when a key with an associated time to live (see the | |
# EXPIRE command) must be deleted from memory. | |
# 2)因为过期:当一个键的相关存活时间(见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. | |
# 3)由于命令的副作用,在一个可能已经存在的键上存储数据。例如RENAME命令在用另一个键替换时可能会删除旧的键内容。 | |
# 同样SUNIONSTORE或带有STORE选项的SORT也可能会删除现有的键。SET命令本身会删除指定键的任何旧内容,以便用指定的字符串替换。 | |
# 4) During replication, when a slave performs a full resynchronization with | |
# its master, the content of the whole database is removed in order to | |
# load the RDB file just transfered. | |
# 4)在复制过程中,当slave与master进行完全重新同步时,为了加载刚刚传输的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 | |
lazyfree-lazy-expire no | |
lazyfree-lazy-server-del no | |
slave-lazy-flush no | |
############################## 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 File是一种替代性的持久化模式,它提供了更好的耐久性。例如使用默认的数据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. | |
appendonly no | |
# The name of the append only file (default: "appendonly.aof") | |
# aof文件的名称(默认:"appendonly.aof")。 | |
appendfilename "appendonly.aof" | |
# The fsync() call tells the Operating System to actually write data on disk | |
# instead of waiting for more data in the output buffer. Some OS will really flush | |
# data on disk, some other OS will just try to do it ASAP. | |
# fsync()调用告诉操作系统在磁盘上实际写入数据,而不是在输出缓冲区中等待更多的数据。有些操作系统会真的在磁盘上刷新数据,而有些操作系统则会尝试尽快刷新数据。 | |
# | |
# Redis supports three different modes: | |
# Redis支持三种不同的模式。 | |
# | |
# no: don't fsync, just let the OS flush the data when it wants. Faster. | |
# always: fsync after every write to the append only log. Slow, Safest. | |
# everysec: fsync only one time every second. Compromise. | |
# no:不要fsync,只要让操作系统在它想要的时候刷新数据。更快。 | |
# always: 每次写完append only日志后都要进行fsync。慢,最安全。 | |
# everysec: 每秒钟只进行一次fsync。妥协。 | |
# | |
# 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",因为这通常是速度和数据安全之间的正确折中。这取决于你是否可以将其放宽到 "no", | |
# 让操作系统在它想要的时候刷新输出缓冲区,以获得更好的性能(但如果你可以忍受一些数据丢失的想法,可以考虑默认的持久化模式,即快照), | |
# 或者相反,使用 "always",它非常慢,但比everysec更安全一些。 | |
# | |
# More details please check the following article: | |
# http://antirez.com/post/redis-persistence-demystified.html | |
# | |
# If unsure, use "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也会阻塞我们的同步写(2)调用。 | |
# | |
# In order to mitigate this problem it's possible to use the following option | |
# that will prevent fsync() from being called in the main process while a | |
# BGSAVE or BGREWRITEAOF is in progress. | |
# 为了缓解这个问题,可以使用以下选项,防止在主进程中,当 BGSAVE 或 BGREWRITEAOF 正在进行时调用 fsync() 。 | |
# | |
# This means that while another child is saving, the durability of Redis is | |
# the same as "appendfsync none". In practical terms, this means that it is | |
# possible to lose up to 30 seconds of log in the worst scenario (with the | |
# default Linux settings). | |
# 这意味着,当另一个子进程在保存时,Redis的持久性与 "appendfsync none "相同。 | |
# 在实际操作中,这意味着在最坏的情况下,有可能丢失长达30秒的日志(在Linux默认设置下)。 | |
# | |
# If you have latency problems turn this to "yes". Otherwise leave it as | |
# "no" that is the safest pick from the point of view of durability. | |
# 如果你有延迟问题,就把这个调到 "yes"。否则,将其设为 "no",从持久性的角度来看,这是最安全的选择。 | |
no-appendfsync-on-rewrite no | |
# Automatic rewrite of the append only file. | |
# Redis is able to automatically rewrite the log file implicitly calling | |
# BGREWRITEAOF when the AOF log size grows by the specified percentage. | |
# 自动重写append only文件。当AOF日志大小按指定百分比增长时,Redis能够自动重写日志文件,隐式调用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. | |
# 百分比设置为0,则禁用自动AOF重写功能。 | |
auto-aof-rewrite-percentage 100 | |
auto-aof-rewrite-min-size 64mb | |
# An AOF file may be found to be truncated at the end during the Redis | |
# startup process, when the AOF data gets loaded back into memory. | |
# This may happen when the system where Redis is running | |
# crashes, especially when an ext4 filesystem is mounted without the | |
# data=ordered option (however this can't happen when Redis itself | |
# crashes or aborts but the operating system still works correctly). | |
# 在Redis启动过程中,当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,服务器就会以错误的方式中止并拒绝启动。当该选项被设置为no时, | |
# 用户需要使用 "redis-check-aof "工具修复AOF文件,然后才能重新启动服务器。 | |
# | |
# Note that if the AOF file will be found to be corrupted in the middle | |
# the server will still exit with an error. This option only applies when | |
# Redis will try to read more data from the AOF file but not enough bytes | |
# will be found. | |
# 请注意,如果中途发现AOF文件损坏,服务器仍然会以错误退出。这个选项只适用于Redis将尝试从AOF文件中读取更多的数据,但没有找到足够的字节时。 | |
aof-load-truncated yes | |
# 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 file][AOF tail] | |
# | |
# When loading Redis recognizes that the AOF file starts with the "REDIS" | |
# string and loads the prefixed RDB file, and continues loading the AOF | |
# tail. | |
# 加载时Redis会识别AOF文件以 "REDIS "字符串开头,并加载前缀的RDB文件,继续加载AOF尾部。 | |
# | |
# This is currently turned off by default in order to avoid the surprise | |
# of a format change, but will at some point be used as the default. | |
# 为了避免格式变化带来的意外惊吓,目前默认关闭了这个功能,但在未来某个版本会默认启用 | |
aof-use-rdb-preamble no | |
################################ LUA SCRIPTING ############################### | |
# 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 called write commands. The second | |
# is the only way to shut down the server in the case a write command was | |
# already issued by the script but the user doesn't want to wait for the natural | |
# termination of the script. | |
# 当一个长期运行的脚本超过最大执行时间时,只有SCRIPT KILL和SHUTDOWN NOSAVE命令可用。 | |
# 第一个可以用来停止一个还没有调用写命令的脚本。第二种是在脚本已经发出写命令但用户不想等待脚本自然终止的情况下,关闭服务器的唯一方法。 | |
# | |
# Set it to 0 or a negative value for unlimited execution without warnings. | |
# 将其设置为0或负值,以实现无警告的无限执行。 | |
lua-time-limit 5000 | |
################################ REDIS CLUSTER ############################### | |
# | |
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however | |
# in order to mark it as "mature" we need to wait for a non trivial percentage | |
# of users to deploy it in production. | |
# 警告 实验性的。Redis Cluster被认为是稳定的代码,但是为了将其标记为 "成熟",我们需要等待一定比例的用户将其部署到生产中。 | |
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
# | |
# Normal Redis instances can't be part of a Redis Cluster; only nodes that are | |
# started as cluster nodes can. In order to start a Redis instance as a | |
# cluster node enable the cluster support uncommenting the following: | |
# 普通的Redis实例不能成为Redis集群的一部分,只有作为集群节点启动的节点才可以。为了将Redis实例作为群集节点启动,启用群集支持,请取消以下注释。 | |
# | |
# cluster-enabled yes | |
# Every cluster node has a cluster configuration file. This file is not | |
# intended to be edited by hand. It is created and updated by Redis nodes. | |
# Every Redis Cluster node requires a different cluster configuration file. | |
# Make sure that instances running in the same system do not have | |
# overlapping cluster configuration file names. | |
# 每个集群节点都有一个集群配置文件。这个文件不打算用手来编辑,而是由Redis节点创建和更新。 | |
# 它是由Redis节点创建和更新的。每个 Redis 群集节点都需要一个不同的群集配置文件。 | |
# 确保在同一系统中运行的实例没有重叠的群集配置文件名称。 | |
# | |
# cluster-config-file nodes-6379.conf | |
# Cluster node timeout is the amount of milliseconds a node must be unreachable | |
# for it to be considered in failure state. | |
# Most other internal time limits are multiple of the node timeout. | |
# 集群节点超时是指一个节点必须在无法到达的毫秒内才会被认为是处于故障状态。大多数其他内部时间限制是节点超时的倍数。 | |
# | |
# cluster-node-timeout 15000 | |
# A slave of a failing master will avoid to start a failover if its data | |
# looks too old. | |
# 故障master的slave将避免在其数据看起来太旧时启动故障转移。 | |
# | |
# There is no simple way for a slave to actually have an exact measure of | |
# its "data age", so the following two checks are performed: | |
# 对于一个slave来说,没有一个简单的方法可以真正对其 "数据年龄 "有一个准确的衡量,所以要进行以下两项检查。 | |
# | |
# 1) If there are multiple slaves able to failover, they exchange messages | |
# in order to try to give an advantage to the slave with the best | |
# replication offset (more data from the master processed). | |
# Slaves will try to get their rank by offset, and apply to the start | |
# of the failover a delay proportional to their rank. | |
# 1)如果有多个slave能够进行故障转移,它们会交换消息,以试图给复制偏移量最好的从机带来优势(处理了更多来自master的数据)。 | |
# slave将试图通过偏移量来获得他们的等级,并在故障转移的开始时应用一个与他们的等级成正比的延迟。 | |
# | |
# 2) Every single slave computes the time of the last interaction with | |
# its master. This can be the last ping or command received (if the master | |
# is still in the "connected" state), or the time that elapsed since the | |
# disconnection with the master (if the replication link is currently down). | |
# If the last interaction is too old, the slave will not try to failover | |
# at all. | |
# 2) 每一个slave都会计算与master最后一次交互的时间。这可以是接收到的最后一次ping或命令(如果master仍处于 "连接 "状态), | |
# 也可以是与master断开连接后经过的时间(如果复制链路目前处于故障状态)。如果最后一次交互时间太长,slave将根本不会尝试故障转移。 | |
# | |
# The point "2" can be tuned by user. Specifically a slave will not perform | |
# the failover if, since the last interaction with the master, the time | |
# elapsed is greater than: | |
# 用户可以对第二种情况进行调整。具体来说,如果自与master最后一次交互以来,经过的时间大于以下几点,则slave将不执行故障切换: | |
# | |
# (node-timeout * slave-validity-factor) + repl-ping-slave-period | |
# | |
# So for example if node-timeout is 30 seconds, and the slave-validity-factor | |
# is 10, and assuming a default repl-ping-slave-period of 10 seconds, the | |
# slave will not try to failover if it was not able to talk with the master | |
# for longer than 310 seconds. | |
# 所以比如说,如果节点time-out为30秒,slave-validity-factor为10,假设默认的repl-ping-slave-period为10秒, | |
# 那么如果slave无法与master对话超过310秒,就不会尝试failover。 | |
# | |
# A large slave-validity-factor may allow slaves with too old data to failover | |
# a master, while a too small value may prevent the cluster from being able to | |
# elect a slave at all. | |
# 一个大的slave-validity-factor可能会让数据太旧的slave失效,而一个太小的值可能会让集群根本无法选出一个slave。 | |
# | |
# For maximum availability, it is possible to set the slave-validity-factor | |
# to a value of 0, which means, that slaves will always try to failover the | |
# master regardless of the last time they interacted with the master. | |
# (However they'll always try to apply a delay proportional to their | |
# offset rank). | |
# 为了实现最大的可用性,可以将slave-validity-factor设置为0,这意味着,无论slave最后一次与master交互的时间是什么时候, | |
# 他们都会尝试failover master。(然而他们总是会尝试应用一个与他们的偏移等级成比例的延迟)。 | |
# | |
# Zero is the only value able to guarantee that when all the partitions heal | |
# the cluster will always be able to continue. | |
# 零是唯一能够保证当所有分区愈合后,集群始终能够继续的值。 | |
# | |
# cluster-slave-validity-factor 10 | |
# Cluster slaves are able to migrate to orphaned masters, that are masters | |
# that are left without working slaves. This improves the cluster ability | |
# to resist to failures as otherwise an orphaned master can't be failed over | |
# in case of failure if it has no working slaves. | |
# 集群slave能够迁移到孤儿master,即没有slave的master。这提高了集群抵御故障的能力,否则,如果一个孤儿master没有slave,在发生故障时,它就不能被替换掉。 | |
# | |
# Slaves migrate to orphaned masters only if there are still at least a | |
# given number of other working slaves for their old master. This number | |
# is the "migration barrier". A migration barrier of 1 means that a slave | |
# will migrate only if there is at least 1 other working slave for its master | |
# and so forth. It usually reflects the number of slaves you want for every | |
# master in your cluster. | |
# slave只有在其旧master至少还有一定数量的其他slave的情况下才会迁移到孤儿master那里。 | |
# 这个数字就是 "迁移障碍"。迁移障碍为1,意味着只有当至少有1个其他slave为其master工作时, | |
# slave才会迁移,以此类推。它通常反映了您希望集群中每个master拥有的slave数量。 | |
# | |
# Default is 1 (slaves migrate only if their masters remain with at least | |
# one slave). To disable migration just set it to a very large value. | |
# A value of 0 can be set but is useful only for debugging and dangerous | |
# in production. | |
# 默认值为1(只有当master至少还有一个slave时,master才会迁移)。要禁用迁移,只需将其设置为一个非常大的值。可以设置为0,但只对调试有用,在生产中很危险。 | |
# | |
# cluster-migration-barrier 1 | |
# By default Redis Cluster nodes stop accepting queries if they detect there | |
# is at least an hash slot uncovered (no available node is serving it). | |
# This way if the cluster is partially down (for example a range of hash slots | |
# are no longer covered) all the cluster becomes, eventually, unavailable. | |
# It automatically returns available as soon as all the slots are covered again. | |
# 默认情况下,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。 | |
# | |
# cluster-require-full-coverage yes | |
# This option, when set to yes, prevents slaves from trying to failover its | |
# master during master failures. However the master can still perform a | |
# manual failover, if forced to do so. | |
# 当设置为 "yes "时,该选项可以防止slave在master故障时尝试进行master故障切换。然而,如果被迫这样做,master仍然可以执行手动故障转移。 | |
# | |
# 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-slave-no-failover no | |
# In order to setup your cluster make sure to read the documentation | |
# available at http://redis.io web site. | |
########################## CLUSTER DOCKER/NAT support ######################## | |
# 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 Cluster节点地址发现失败,因为地址被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在这样的环境中工作,需要一个静态配置,每个节点都知道自己的公有地址。以下两个选项用于这个范围,分别是:。 | |
# | |
# * cluster-announce-ip | |
# * cluster-announce-port | |
# * cluster-announce-bus-port | |
# | |
# Each instruct 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 usually. | |
# 需要注意的是,当重新映射时,总线端口可能不在客户机端口+10000的固定偏移量上, | |
# 所以可以根据重新映射的方式指定任何端口和总线端口。如果没有设置总线端口,则会像平时一样使用10000的固定偏移量。 | |
# | |
# Example: | |
# | |
# cluster-announce-ip 10.1.1.5 | |
# cluster-announce-port 6379 | |
# cluster-announce-bus-port 6380 | |
################################## 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慢速日志是一个记录超过指定执行时间的查询的系统。执行时间不包括与客户端对话、发送回复等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. | |
# 你可以用两个参数来配置慢速日志:一个参数告诉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相当于一秒钟。请注意,负数会禁用慢速日志,而数值为零则会强制记录每条命令。 | |
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 ############################## | |
# 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 <milliseconds>"命令轻松启用延迟监控。 | |
latency-monitor-threshold 0 | |
############################# EVENT NOTIFICATION ############################## | |
# Redis can notify Pub/Sub clients about events happening in the key space. | |
# This feature is documented at http://redis.io/topics/notifications | |
# Redis可以通知Pub/Sub客户端在key空间发生的事件。这个功能的文档在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: | |
# 例如,如果启用了键空间事件通知,客户端对存储在数据库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. | |
# E Keyevent events, published with __keyevent@<db>__ prefix. | |
# g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... | |
# $ String commands | |
# l List commands | |
# s Set commands | |
# h Hash commands | |
# z Sorted set commands | |
# x Expired events (events generated every time a key expires) | |
# e Evicted events (events generated when a key is evicted for maxmemory) | |
# A Alias for g$lshzxe, so that the "AKE" string means all the events. | |
# | |
# The "notify-keyspace-events" takes as argument a string that is composed | |
# of zero or multiple characters. The empty string means that notifications | |
# are disabled. | |
# "notify-keyspace-events "的参数是一个由零或多个字符组成的字符串。空字符串表示通知被禁用。 | |
# | |
# Example: to enable list and generic events, from the point of view of the | |
# event name, use: | |
# 例如:从事件名称的角度来看,要启用列表和通用事件,请使用。 | |
# | |
# notify-keyspace-events Elg | |
# | |
# Example 2: to get the stream of the expired keys subscribing to channel | |
# name __keyevent@0__:expired use: | |
# 例子2: 要获取订阅通道名 __keyevent@0__:expired 的过期key流,使用: | |
# | |
# 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 "" | |
############################### ADVANCED CONFIG ############################### | |
# Hashes are encoded using a memory efficient data structure when they have a | |
# small number of entries, and the biggest entry does not exceed a given | |
# threshold. These thresholds can be configured using the following directives. | |
# 当哈希值的条目数较少,且最大的条目不超过给定的阈值时,哈希值就会使用内存效率高的数据结构进行编码。这些阈值可以使用以下指令进行配置。 | |
hash-max-ziplist-entries 512 | |
hash-max-ziplist-value 64 | |
# Lists are also encoded in a special way to save a lot of space. | |
# The number of entries allowed per internal list node can be specified | |
# as a fixed maximum size or a maximum number of elements. | |
# For a fixed maximum size, use -5 through -1, meaning: | |
# 列表也以一种特殊的方式进行编码,以节省大量的空间。 | |
# 每个内部列表节点允许的条目数可以指定为固定的最大尺寸或最大元素数。对于固定的最大尺寸,使用-5到-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. | |
# 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(8 Kb大小)或-1(4 Kb大小),但如果你的使用情况是独特的,请根据需要调整设置。 | |
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: | |
# 列表也可以被压缩。压缩深度是列表每一边要排除在压缩之外的quicklist ziplist节点的数量。 | |
# 列表的头和尾总是不压缩的,以便进行快速的推/弹操作。 | |
# 设置为 | |
# 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. | |
# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] | |
# etc. | |
list-compress-depth 0 | |
# Sets have a special encoding in just one case: when a set is composed | |
# of just strings that happen to be integers in radix 10 in the range | |
# of 64 bit signed integers. | |
# The following configuration setting sets the limit in the size of the | |
# set in order to use this special memory saving encoding. | |
# 集合在一种情况下有一种特殊的编码:当一个集合只由字符串组成时, | |
# 而这些字符串恰好是64位有符号整数范围内的小数点10的整数。下面的配置设置设置了集的大小限制,以便使用这种特殊的节省内存的编码。 | |
set-max-intset-entries 512 | |
# Similarly to hashes and lists, sorted sets are also specially encoded in | |
# order to save a lot of space. This encoding is only used when the length and | |
# elements of a sorted set are below the following limits: | |
# 与哈希和列表类似,为了节省大量空间,排序集也进行了特殊编码。只有当排序集的长度和元素低于以下限制时,才会使用这种编码。 | |
zset-max-ziplist-entries 128 | |
zset-max-ziplist-value 64 | |
# HyperLogLog sparse representation bytes limit. The limit includes the | |
# 16 bytes header. When an HyperLogLog using the sparse representation crosses | |
# this limit, it is converted into the dense representation. | |
# HyperLogLog稀疏表示的字节数限制。这个限制包括16字节的头。当使用稀疏表示法的HyperLogic超过这个限制时,它将被转换为密集表示法。 | |
# | |
# 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. | |
# 建议的值是3000左右,以获得空间效率编码的好处,而不至于使PFADD速度太慢,因为稀疏编码的速度是O(N)。 | |
# 当CPU不是问题,但空间是问题,而且数据集是由许多HyperLogs组成的,卡片数在0-15000范围内时,这个值可以提高到~10000。 | |
hll-sparse-max-bytes 3000 | |
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in | |
# order to help rehashing the main Redis hash table (the one mapping top-level | |
# keys to values). The hash table implementation Redis uses (see dict.c) | |
# performs a lazy rehashing: the more operation you run into a hash table | |
# that is rehashing, the more rehashing "steps" are performed, so if the | |
# server is idle the rehashing is never complete and some more memory is used | |
# by the hash table. | |
# 主动重散列每100毫秒使用1毫秒的 CPU 时间,以帮助重散列主 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. | |
# 如果不确定:使用 "acterehashing no",如果你对延迟有硬性要求,而且在你的环境中,Redis可以时常回复延迟2毫秒的查询,这不是一件好事。 | |
# | |
# use "activerehashing yes" if you don't have such hard requirements but | |
# want to free memory asap when possible. | |
# 如果你没有这样的硬性要求,但又想尽快释放内存,就使用 "acterehashing yes"。 | |
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). | |
# 客户端输出缓冲区限制可以用来强制断开因某些原因从服务器读取数据速度不够快的客户端的连接(常见的原因是Pub/Sub客户端消耗消息的速度赶不上发布者产生消息的速度)。 | |
# | |
# The limit can be set differently for the three different classes of clients: | |
# 针对三类不同的客户,可以设置不同的限额。 | |
# | |
# normal -> normal clients including MONITOR clients | |
# 普通客户,包括monitor客户 | |
# slave -> slave 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> | |
# | |
# 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. | |
# 所以比如硬限制是32M,软限制是16M/10s,如果输出缓冲区的大小达到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 slave clients, since | |
# subscribers and slaves receive data in a push fashion. | |
# 而对pubsub和slave则有一个默认的限制,因为订阅者和slave以推送的方式接收数据。 | |
# | |
# Both the hard or the soft limit can be disabled by setting them to zero. | |
# 硬限位或软限位都可以通过设置为零来禁用。 | |
client-output-buffer-limit normal 0 0 0 | |
client-output-buffer-limit slave 256mb 64mb 60 | |
client-output-buffer-limit pubsub 32mb 8mb 60 | |
# 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. | |
# 客户端查询缓冲区会累积新的命令。默认情况下,它们被限制在一个固定的数量,以避免协议解同步(例如由于客户端的一个错误)导致查询缓冲区的内存使用不受限制。 | |
# 但是如果你有非常特殊的需求,比如巨大的多/执行请求或类似的情况,你可以在这里进行配置。 | |
# | |
# client-query-buffer-limit 1gb | |
# In the Redis protocol, bulk requests, that are, elements representing single | |
# strings, are normally limited ot 512 mb. However you can change this limit | |
# here. | |
# 在Redis协议中,批量请求,即代表单个字符串的元素,通常被限制在512mb。但是你可以在这里改变这个限制。 | |
# | |
# 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。 | |
hz 10 | |
# When a child rewrites the AOF file, if the following option is enabled | |
# the file will be fsync-ed every 32 MB of data generated. This is useful | |
# in order to commit the file to the disk more incrementally and avoid | |
# big latency spikes. | |
# 当子进程重写AOF文件时,如果启用以下选项,文件将每生成32MB的数据就会被fsync。这对于以更多的增量方式将文件提交到磁盘并避免大的延迟峰值非常有用。 | |
aof-rewrite-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 eviction(见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. | |
# Redis LFU实现中有两个可调参数:计数器对数因子和计数器衰减时间。在改变这两个参数之前,了解这两个参数的含义很重要。 | |
# | |
# 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: | |
# LFU计数器每个键只有8位,它的最大值是255,所以Redis使用的是对数行为的概率增量。给定旧计数器的值,当一个密钥被访问时,计数器会以这种方式递增。 | |
# | |
# 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-log-factor为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. | |
# 注2:计数器初始值为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). | |
# 计数器衰减时间是指密钥计数器除以二(或如果它的值小于<=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-decay-time的默认值为1,特殊值为0表示每次扫描时都要对计数器进行衰减。 | |
# | |
# lfu-log-factor 10 | |
# lfu-decay-time 1 | |
########################### ACTIVE DEFRAGMENTATION ####################### | |
# | |
# WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested | |
# even in production and manually tested by multiple engineers for some | |
# time. | |
# 警告此功能是实验性的。然而,压力测试,甚至上生产生产环境,多位工程师手动测试也有一段时间了 | |
# | |
# 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服务器压缩内存中数据的小分配和deallocations之间留下的空间,从而允许回收内存。 | |
# | |
# 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 an "hot" way, while the server is running. | |
# 碎片化是一个自然的过程,每个分配器都会发生(但幸运的是,Jemalloc的碎片化较少),而且工作负荷也比较大。 | |
# 通常情况下,需要重启服务器以降低碎片化,或者至少冲掉所有数据并重新创建。不过多亏了Oran Agra为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. | |
# 1. 这个功能默认是禁用的,只有当你编译Redis时使用我们随Redis源代码一起发布的Jemalloc副本时才会生效。这是在Linux版本中的默认设置。 | |
# | |
# 2. You never need to enable this feature if you don't have fragmentation | |
# issues. | |
# 2. 如果你没有碎片化问题,你永远不需要启用这个功能。 | |
# | |
# 3. Once you experience fragmentation, you can enable this feature when | |
# needed with the command "CONFIG SET activedefrag yes". | |
# 3. 一旦遇到碎片化的情况,可以在需要的时候用 "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 yes | |
# Minimum amount of fragmentation waste to start active defrag | |
# 开始主动清除碎片的最小碎片量 | |
# active-defrag-ignore-bytes 100mb | |
# Minimum percentage of fragmentation to start active defrag | |
# 开始主动清除碎片的最小百分比 | |
# active-defrag-threshold-lower 10 | |
# Maximum percentage of fragmentation at which we use maximum effort | |
# 我们使用最大努力的最大碎片比例 | |
# active-defrag-threshold-upper 100 | |
# Minimal effort for defrag in CPU percentage | |
# 以CPU百分比计算的最小化的碎片整理工作 | |
# active-defrag-cycle-min 25 | |
# Maximal effort for defrag in CPU percentage | |
# 以CPU百分比计算的最大碎片整理工作 | |
# active-defrag-cycle-max 75 | |
loadmodule /Users/ficapy/rebloom/rebloom.so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment