当前位置:   article > 正文

Redis配置文件详解(redis.conf)_redisconfig配置文件

redisconfig配置文件
  1. # Redis配置文件示例。
  2. # Redis configuration file example.
  3. #
  4. # 注意,为了读取配置文件,Redis必须以文件路径作为第一个参数开始:
  5. # Note that in order to read the configuration file, Redis must be
  6. # started with the file path as first argument:
  7. #
  8. # ./redis-server /path/to/redis.conf
  9. # 关于单位的说明:当需要内存大小时,可以指定
  10. # Note on units: when memory size is needed, it is possible to specify
  11. #
  12. # 它通常采用1k 5GB 4M等形式:
  13. # it in the usual form of 1k 5GB 4M and so forth:
  14. #
  15. # 1k => 1000 bytes
  16. # 1kb => 1024 bytes
  17. # 1m => 1000000 bytes
  18. # 1mb => 1024*1024 bytes
  19. # 1g => 1000000000 bytes
  20. # 1gb => 1024*1024*1024 bytes
  21. #
  22. # 单元不区分大小写,所以1GB 1GB都是一样的。
  23. # units are case insensitive so 1GB 1Gb 1gB are all the same.
  24. ################################## INCLUDES ###################################
  25. #
  26. # 在此处包含一个或多个其他配置文件。如果您有一个标准的模板,可以连接到所有Redis服务器,
  27. # 但也需要自定义每个服务器的一些设置,那么这将非常有用。Include文件可以包含其他文件,
  28. # 所以请明智地使用它。
  29. # Include one or more other config files here. This is useful if you
  30. # have a standard template that goes to all Redis servers but also need
  31. # to customize a few per-server settings. Include files can include
  32. # other files, so use this wisely.
  33. #
  34. # 注意,admin或Redis Sentinel的命令“CONFIG REWRITE”不会重写选项“include”。
  35. # 由于Redis总是使用最后处理的行作为配置指令的值,因此最好将includes放在该文件的开头,
  36. # 以避免在运行时覆盖配置更改。
  37. # Notice option "include" won't be rewritten by command "CONFIG REWRITE"
  38. # from admin or Redis Sentinel. Since Redis always uses the last processed
  39. # line as value of a configuration directive, you'd better put includes
  40. # at the beginning of this file to avoid overwriting config change at runtime.
  41. #
  42. # 如果您对使用include覆盖配置选项感兴趣,最好使用include作为最后一行。
  43. # If instead you are interested in using includes to override configuration
  44. # options, it is better to use include as the last line.
  45. #
  46. # include /path/to/local.conf
  47. # include /path/to/other.conf
  48. ################################## MODULES #####################################
  49. # 启动时加载模块。如果服务器无法加载模块,它将中止。可以使用多个loadmodule指令。
  50. # Load modules at startup. If the server is not able to load modules
  51. # it will abort. It is possible to use multiple loadmodule directives.
  52. #
  53. # loadmodule /path/to/my_module.so
  54. # loadmodule /path/to/other_module.so
  55. ################################## NETWORK #####################################
  56. # 默认情况下,如果没有指定“bind”配置指令,Redis将侦听服务器上所有可用网络接口的连接。
  57. # 可以使用“bind”配置指令(后跟一个或多个IP地址)只侦听一个或多个选定的接口。
  58. # By default, if no "bind" configuration directive is specified, Redis listens
  59. # for connections from all the network interfaces available on the server.
  60. # It is possible to listen to just one or multiple selected interfaces using
  61. # the "bind" configuration directive, followed by one or more IP addresses.
  62. #
  63. # 例如:
  64. # Examples:
  65. #
  66. # bind 192.168.1.100 10.0.0.1
  67. # bind 127.0.0.1 ::1
  68. #
  69. # ~~~警告~~~如果运行Redis的计算机直接暴露在internet上,绑定到所有接口是危险的,
  70. # 会将实例暴露给internet上的所有人。因此,默认情况下,我们取消注释下面的bind指令,
  71. # 这将强制Redis只监听IPv4 lookback接口地址(这意味着Redis将只能接受来自运行在
  72. # 同一台计算机上的客户端的连接)。
  73. # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
  74. # internet, binding to all the interfaces is dangerous and will expose the
  75. # instance to everybody on the internet. So by default we uncomment the
  76. # following bind directive, that will force Redis to listen only into
  77. # the IPv4 lookback interface address (this means Redis will be able to
  78. # accept connections only from clients running into the same computer it
  79. # is running).
  80. #
  81. # 如果您确定希望您的实例侦听所有接口,只需注释以下行。
  82. # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
  83. # JUST COMMENT THE FOLLOWING LINE.
  84. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. bind 127.0.0.1
  86. # 保护模式是一层安全保护,以避免Redis实例在internet上被访问和利用。
  87. # Protected mode is a layer of security protection, in order to avoid that
  88. # Redis instances left open on the internet are accessed and exploited.
  89. #
  90. # 打开保护模式时,如果:
  91. # When protected mode is on and if:
  92. #
  93. # 服务器没有使用bind“指令显式绑定到一组地址。
  94. # 1) The server is not binding explicitly to a set of addresses using the
  95. # "bind" directive.
  96. #
  97. # 未配置密码。
  98. # 2) No password is configured.
  99. #
  100. # 服务器仅接受来自从IPv4和IPv6环回地址127.0.0.1和::1连接的客户端的连接,
  101. # 以及来自Unix域套接字的连接。
  102. # The server only accepts connections from clients connecting from the
  103. # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
  104. # sockets.
  105. #
  106. # 默认情况下,启用保护模式。只有当您确定希望来自其他主机的客户端连接到Redis时才应该禁用它,
  107. # 即使没有配置身份验证,也没有使用“bind”指令显式列出一组特定的接口。
  108. # By default protected mode is enabled. You should disable it only if
  109. # you are sure you want clients from other hosts to connect to Redis
  110. # even if no authentication is configured, nor a specific set of interfaces
  111. # are explicitly listed using the "bind" directive.
  112. protected-mode yes
  113. # 接受指定端口上的连接,默认值为6379(IANA#815344)。
  114. # 如果指定了端口0,Redis将不会侦听TCP套接字。
  115. # Accept connections on the specified port, default is 6379 (IANA #815344).
  116. # If port 0 is specified Redis will not listen on a TCP socket.
  117. port 6379
  118. # TCP listen()积压工作。
  119. # TCP listen() backlog.
  120. #
  121. # 在每秒请求数高的环境中,您需要一个高积压工作,以避免客户端连接速度慢的问题。
  122. # 请注意,Linux内核将自动将其截断为/proc/sys/net/core/somaxconn的值,
  123. # 因此请确保同时提高somaxconn和tcp\u max\u syn\u backlog的值,以获得所需的效果。
  124. # In high requests-per-second environments you need an high backlog in order
  125. # to avoid slow clients connections issues. Note that the Linux kernel
  126. # will silently truncate it to the value of /proc/sys/net/core/somaxconn so
  127. # make sure to raise both the value of somaxconn and tcp_max_syn_backlog
  128. # in order to get the desired effect.
  129. tcp-backlog 511
  130. # Unix套接字。
  131. # Unix socket.
  132. #
  133. # 指定用于侦听传入连接的Unix套接字的路径。没有默认值,因此Redis在未指定时不会侦听unix套接字
  134. # Specify the path for the Unix socket that will be used to listen for
  135. # incoming connections. There is no default, so Redis will not listen
  136. # on a unix socket when not specified.
  137. #
  138. # unixsocket /tmp/redis.sock
  139. # unixsocketperm 700
  140. # 客户端空闲N秒后关闭连接(0表示禁用)
  141. # Close the connection after a client is idle for N seconds (0 to disable)
  142. timeout 0
  143. # TCP保持连接。
  144. # TCP keepalive.
  145. #
  146. # 如果非零,则在没有通信的情况下,使用SO_KEEPALIVE向客户端发送TCP确认。这有两个原因:
  147. # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
  148. # of communication. This is useful for two reasons:
  149. #
  150. # 检测死掉的同伴。
  151. # 1) Detect dead peers.
  152. #
  153. # 从中间的网络设备的角度来看待连接。
  154. # 2) Take the connection alive from the point of view of network
  155. # equipment in the middle.
  156. #
  157. # 在Linux上,指定的值(以秒为单位)是用于发送ACK的时间段。
  158. # 请注意,要关闭连接,需要两倍的时间。
  159. # 在其他内核上,周期取决于内核配置。
  160. # On Linux, the specified value (in seconds) is the period used to send ACKs.
  161. # Note that to close the connection the double of the time is needed.
  162. # On other kernels the period depends on the kernel configuration.
  163. #
  164. # 这个选项的合理值是300秒,这是从redis3.2.1开始的新Redis默认值。
  165. # A reasonable value for this option is 300 seconds, which is the new
  166. # Redis default starting with Redis 3.2.1.
  167. tcp-keepalive 300
  168. ################################ SNAPSHOTTING ################################
  169. #
  170. # 将数据库保存在磁盘上:
  171. # Save the DB on disk:
  172. #
  173. # 保存 <seconds> <changes>
  174. # save <seconds> <changes>
  175. #
  176. # 如果给定的秒数和对数据库执行的写入操作数都达到给定的秒数,则将保存数据库。
  177. # Will save the DB if both the given number of seconds and the given
  178. # number of write operations against the DB occurred.
  179. #
  180. # 在下面的示例中,行为将会保存:
  181. # In the example below the behaviour will be to save:
  182. #
  183. # 900秒(15分钟)后,如果至少有一个键更改
  184. # after 900 sec (15 min) if at least 1 key changed
  185. #
  186. # 300秒(5分钟)后,如果至少有10个键更改
  187. # after 300 sec (5 min) if at least 10 keys changed
  188. #
  189. # 60秒后,如果至少10000个键发生更改
  190. # after 60 sec if at least 10000 keys changed
  191. #
  192. # 注意:您可以通过注释掉所有“save”行来完全禁用保存。
  193. # Note: you can disable saving completely by commenting out all "save" lines.
  194. #
  195. # 通过添加带有单个空字符串参数的save指令,也可以删除以前配置的所有保存点,如以下示例所示:
  196. # It is also possible to remove all the previously configured save
  197. # points by adding a save directive with a single empty string argument
  198. # like in the following example:
  199. #
  200. # save ""
  201. save 900 1
  202. save 300 10
  203. save 60 10000
  204. # 默认情况下,如果RDB快照已启用(至少一个保存点),并且最新的后台保存失败,Redis将停止接受写入。
  205. # 这将使用户意识到(以一种强硬的方式)数据没有正确地保存在磁盘上,否则很可能没有人会注意到,
  206. # 并且会发生一些灾难。
  207. # By default Redis will stop accepting writes if RDB snapshots are enabled
  208. # (at least one save point) and the latest background save failed.
  209. # This will make the user aware (in a hard way) that data is not persisting
  210. # on disk properly, otherwise chances are that no one will notice and some
  211. # disaster will happen.
  212. #
  213. # 如果后台保存过程重新开始工作,Redis将自动再次允许写操作。
  214. # If the background saving process will start working again Redis will
  215. # automatically allow writes again.
  216. #
  217. # 但是,如果您已经设置了对Redis服务器和持久性的正确监视,那么您可能需要禁用此功能,
  218. # 以便即使在磁盘、权限等方面出现问题时,Redis仍能正常工作。
  219. # However if you have setup your proper monitoring of the Redis server
  220. # and persistence, you may want to disable this feature so that Redis will
  221. # continue to work as usual even if there are problems with disk,
  222. # permissions, and so forth.
  223. stop-writes-on-bgsave-error yes
  224. # 转储.rdb数据库时使用LZF压缩字符串对象?
  225. # 默认设置为“是”,因为它几乎总是一个胜利。
  226. # 如果您想在saving child中保存一些CPU,请将其设置为“no”,但是如果您有可压缩的值或键,
  227. # 则数据集可能会更大。
  228. # Compress string objects using LZF when dump .rdb databases?
  229. # For default that's set to 'yes' as it's almost always a win.
  230. # If you want to save some CPU in the saving child set it to 'no' but
  231. # the dataset will likely be bigger if you have compressible values or keys.
  232. rdbcompression yes
  233. # 由于RDB版本5,CRC64校验和放在文件的末尾。
  234. # 这使格式更能抵抗损坏,但在保存和加载RDB文件时,性能会受到影响(约10%),
  235. # 因此可以禁用它以获得最大性能。
  236. # Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
  237. # This makes the format more resistant to corruption but there is a performance
  238. # hit to pay (around 10%) when saving and loading RDB files, so you can disable it
  239. # for maximum performances.
  240. #
  241. # 在禁用校验和的情况下创建的RDB文件的校验和为零,这将告诉加载代码跳过检查。
  242. # RDB files created with checksum disabled have a checksum of zero that will
  243. # tell the loading code to skip the check.
  244. rdbchecksum yes
  245. # 将数据库转储到的文件名
  246. # The filename where to dump the DB
  247. dbfilename dump.rdb
  248. # 工作目录。
  249. # The working directory.
  250. #
  251. # DB将被写入这个目录,使用上面使用'dbfilename'配置指令指定的文件名。
  252. # The DB will be written inside this directory, with the filename specified
  253. # above using the 'dbfilename' configuration directive.
  254. #
  255. # 只附加的文件也将在这个目录中创建。
  256. # The Append Only File will also be created inside this directory.
  257. #
  258. # 请注意,必须在此处指定目录,而不是文件名。
  259. # Note that you must specify a directory here, not a file name.
  260. dir ./
  261. ################################# REPLICATION #################################
  262. # 主从复制。使用slaveof使Redis实例成为另一个Redis服务器的副本。
  263. # 关于Redis复制,需要尽快了解的一些事情。
  264. # Master-Slave replication. Use slaveof to make a Redis instance a copy of
  265. # another Redis server. A few things to understand ASAP about Redis replication.
  266. #
  267. # Redis复制是异步的,但是您可以配置一个主设备,如果它看起来没有连接到至少给定数量的从设备,
  268. # 那么它就停止接受写操作。
  269. # 1) Redis replication is asynchronous, but you can configure a master to
  270. # stop accepting writes if it appears to be not connected with at least
  271. # a given number of slaves.
  272. #
  273. # 如果复制链路丢失的时间相对较少,Redis从机可以执行与主机的部分重新同步。
  274. # 您可能需要根据需要使用合理的值来配置复制积压工作大小(请参阅本文件的下一节)。
  275. # 2) Redis slaves are able to perform a partial resynchronization with the
  276. # master if the replication link is lost for a relatively small amount of
  277. # time. You may want to configure the replication backlog size (see the next
  278. # sections of this file) with a sensible value depending on your needs.
  279. #
  280. # 复制是自动的,不需要用户干预。在网络分区之后,从机会自动尝试重新连接到主机并与它们重新同步。
  281. # 3) Replication is automatic and does not need user intervention. After a
  282. # network partition slaves automatically try to reconnect to masters
  283. # and resynchronize with them.
  284. #
  285. # slaveof <masterip> <masterport>
  286. # 如果主机受密码保护(使用下面的“requirepass”配置指令),
  287. # 则可以在启动复制同步过程之前通知从机进行身份验证,否则主机将拒绝从机请求。
  288. # If the master is password protected (using the "requirepass" configuration
  289. # directive below) it is possible to tell the slave to authenticate before
  290. # starting the replication synchronization process, otherwise the master will
  291. # refuse the slave request.
  292. #
  293. # masterauth <master-password>
  294. # 当从机失去与主机的连接时,或当复制仍在进行时,从机可以以两种不同的方式操作:
  295. # When a slave loses its connection with the master, or when the replication
  296. # is still in progress, the slave can act in two different ways:
  297. #
  298. # 如果slave serve stale data设置为“yes”(默认值),那么slave仍然会回复客户机请求,
  299. # 可能有过期的数据,或者如果这是第一次同步,那么数据集可能是空的。
  300. # 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
  301. # still reply to client requests, possibly with out of date data, or the
  302. # data set may just be empty if this is the first synchronization.
  303. #
  304. # 如果slave-serve-stale data设置为“no”,
  305. # 则slave将以错误“SYNC with master in progress”回复除INFO和SLAVEOF之外的所有命令。
  306. # 2) if slave-serve-stale-data is set to 'no' the slave will reply with
  307. # an error "SYNC with master in progress" to all the kind of commands
  308. # but to INFO and SLAVEOF.
  309. #
  310. slave-serve-stale-data yes
  311. # 您可以将从属实例配置为是否接受写入。对从属实例进行写入可能有助于存储一些临时数据
  312. # (因为写入从属实例的数据在与主实例重新同步后很容易被删除),
  313. # 但如果客户端由于配置错误而向其写入数据,则也可能会导致问题。
  314. # You can configure a slave instance to accept writes or not. Writing against
  315. # a slave instance may be useful to store some ephemeral data (because data
  316. # written on a slave will be easily deleted after resync with the master) but
  317. # may also cause problems if clients are writing to it because of a
  318. # misconfiguration.
  319. #
  320. # 因为redis2.6在默认情况下是只读的。
  321. # Since Redis 2.6 by default slaves are read-only.
  322. #
  323. # 注意:只读从属服务器的设计不允许暴露于internet上不受信任的客户端。
  324. # 它只是一个防止实例被滥用的保护层。
  325. # 默认情况下,只读从设备仍然导出所有管理命令,如CONFIG、DEBUG等。
  326. # 在一定程度上,您可以使用“rename command”来隐藏所有管理/危险命令,
  327. # 从而提高只读从机的安全性。
  328. # Note: read only slaves are not designed to be exposed to untrusted clients
  329. # on the internet. It's just a protection layer against misuse of the instance.
  330. # Still a read only slave exports by default all the administrative commands
  331. # such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
  332. # security of read only slaves using 'rename-command' to shadow all the
  333. # administrative / dangerous commands.
  334. slave-read-only yes
  335. # 复制同步策略:磁盘或套接字。
  336. # Replication SYNC strategy: disk or socket.
  337. #
  338. # -------------------------------------------------------
  339. # 警告:无盘复制目前处于试验阶段
  340. # WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY
  341. # -------------------------------------------------------
  342. #
  343. # 新的从机和重新连接的从机如果只是接收到差异而无法继续复制过程,
  344. # 则需要执行所谓的“完全同步”。
  345. # RDB文件从主设备传输到从设备。
  346. # 传输有两种不同的方式:
  347. # New slaves and reconnecting slaves that are not able to continue the replication
  348. # process just receiving differences, need to do what is called a "full
  349. # synchronization". An RDB file is transmitted from the master to the slaves.
  350. # The transmission can happen in two different ways:
  351. #
  352. # 磁盘备份:Redis主控程序创建一个新的进程,该进程将RDB文件写入磁盘。
  353. # 之后,父进程将文件增量传输到从属程序。
  354. # 1) Disk-backed: The Redis master creates a new process that writes the RDB
  355. # file on disk. Later the file is transferred by the parent
  356. # process to the slaves incrementally.
  357. # 无盘:Redis master创建了一个新进程,直接将RDB文件写入从属套接字,而完全不接触磁盘。
  358. # 2) Diskless: The Redis master creates a new process that directly writes the
  359. # RDB file to slave sockets, without touching the disk at all.
  360. #
  361. # 使用磁盘备份复制,在生成RDB文件的同时,只要生成RDB文件的当前子级完成其工作,
  362. # 就可以将更多的从属服务器排队并与RDB文件一起提供服务。如果使用无盘复制,则在传输开始后,
  363. # 到达的新从机将排队,当当前传输终止时,新的传输将开始。
  364. # With disk-backed replication, while the RDB file is generated, more slaves
  365. # can be queued and served with the RDB file as soon as the current child producing
  366. # the RDB file finishes its work. With diskless replication instead once
  367. # the transfer starts, new slaves arriving will be queued and a new transfer
  368. # will start when the current one terminates.
  369. #
  370. # 当使用无盘复制时,主机在开始传输之前等待一段可配置的时间(以秒为单位),
  371. # 希望多个从机将到达并且传输可以并行化。
  372. # When diskless replication is used, the master waits a configurable amount of
  373. # time (in seconds) before starting the transfer in the hope that multiple slaves
  374. # will arrive and the transfer can be parallelized.
  375. #
  376. # 对于慢速磁盘和快速(大带宽)网络,无盘复制工作得更好。
  377. # With slow disks and fast (large bandwidth) networks, diskless replication
  378. # works better.
  379. repl-diskless-sync no
  380. # 启用无盘复制时,可以配置服务器等待的延迟,以便生成通过套接字将RDB传输到从属服务器的子级。
  381. # When diskless replication is enabled, it is possible to configure the delay
  382. # the server waits in order to spawn the child that transfers the RDB via socket
  383. # to the slaves.
  384. #
  385. # 这一点很重要,因为一旦传输开始,就不可能为到达的新从属服务器提供服务,
  386. # 这些从属服务器将排队等待下一次RDB传输,因此服务器会等待一个延迟,以便让更多从属服务器到达。
  387. # This is important since once the transfer starts, it is not possible to serve
  388. # new slaves arriving, that will be queued for the next RDB transfer, so the server
  389. # waits a delay in order to let more slaves arrive.
  390. #
  391. # 延迟以秒为单位指定,默认为5秒。要完全禁用它,只需将其设置为0秒,传输将尽快开始。
  392. # The delay is specified in seconds, and by default is 5 seconds. To disable
  393. # it entirely just set it to 0 seconds and the transfer will start ASAP.
  394. repl-diskless-sync-delay 5
  395. # 从属服务器以预定义的间隔向服务器发送ping。可以使用repl_ping_slave_period选项更改此间隔。
  396. # 默认值为10秒。
  397. # Slaves send PINGs to server in a predefined interval. It's possible to change
  398. # this interval with the repl_ping_slave_period option. The default value is 10
  399. # seconds.
  400. #
  401. # repl-ping-slave-period 10
  402. # 以下选项设置的复制超时:
  403. # The following option sets the replication timeout for:
  404. #
  405. # 1)从从从机的角度来看,同步期间的批量传输I/O。
  406. # 2)从从机(数据、ping)的角度看主超时。
  407. # 3)从主机的角度来看,从机超时(REPLCONF-ACK pings)。
  408. # 1) Bulk transfer I/O during SYNC, from the point of view of slave.
  409. # 2) Master timeout from the point of view of slaves (data, pings).
  410. # 3) Slave timeout from the point of view of masters (REPLCONF ACK pings).
  411. #
  412. # 务必确保此值大于为repl ping slave period指定的值,
  413. # 否则每次主设备和从设备之间的通信量较低时都会检测到超时。
  414. # It is important to make sure that this value is greater than the value
  415. # specified for repl-ping-slave-period otherwise a timeout will be detected
  416. # every time there is low traffic between the master and the slave.
  417. #
  418. # repl-timeout 60
  419. # 同步后在从属套接字上禁用TCP\U节点?
  420. # Disable TCP_NODELAY on the slave socket after SYNC?
  421. #
  422. # 如果您选择“是”,Redis将使用较少的TCP数据包和较少的带宽将数据发送到从属服务器。
  423. # 但是这会增加数据出现在从机端的延迟,对于使用默认配置的Linux内核,最长为40毫秒。
  424. # If you select "yes" Redis will use a smaller number of TCP packets and
  425. # less bandwidth to send data to slaves. But this can add a delay for
  426. # the data to appear on the slave side, up to 40 milliseconds with
  427. # Linux kernels using a default configuration.
  428. #
  429. # 如果选择“否”,则从机端显示数据的延迟将减少,但复制将使用更多带宽。
  430. # If you select "no" the delay for data to appear on the slave side will
  431. # be reduced but more bandwidth will be used for replication.
  432. #
  433. # 默认情况下,我们会针对低延迟进行优化,但是在流量非常大的情况下,
  434. # 或者当主节点和从节点之间有许多跳距时,将此选项改为“是”可能是个好主意。
  435. # By default we optimize for low latency, but in very high traffic conditions
  436. # or when the master and slaves are many hops away, turning this to "yes" may
  437. # be a good idea.
  438. repl-disable-tcp-nodelay no
  439. # 设置复制积压大小。backlog是一个缓冲区,当从机断开连接一段时间后,它会累积从机数据,
  440. # 因此当从机想要再次重新连接时,通常不需要完全重新同步,但部分重新同步就足够了,
  441. # 只需传递从机在断开连接时丢失的部分数据。
  442. # Set the replication backlog size. The backlog is a buffer that accumulates
  443. # slave data when slaves are disconnected for some time, so that when a slave
  444. # wants to reconnect again, often a full resync is not needed, but a partial
  445. # resync is enough, just passing the portion of data the slave missed while
  446. # disconnected.
  447. #
  448. # 复制积压越大,从机可以断开连接的时间就越长,并且以后可以执行部分重新同步。
  449. # The bigger the replication backlog, the longer the time the slave can be
  450. # disconnected and later be able to perform a partial resynchronization.
  451. #
  452. # 只有在至少有一个从机连接时,才会分配backlog。
  453. # The backlog is only allocated once there is at least a slave connected.
  454. #
  455. # repl-backlog-size 1mb
  456. # 在一段时间内主设备不再连接从属设备之后,积压的工作将被释放。
  457. # 以下选项配置从最后一个从机断开连接开始释放积压缓冲区所需的秒数。
  458. # After a master has no longer connected slaves for some time, the backlog
  459. # will be freed. The following option configures the amount of seconds that
  460. # need to elapse, starting from the time the last slave disconnected, for
  461. # the backlog buffer to be freed.
  462. #
  463. # 请注意,从机从不为超时释放backlog,因为它们可能稍后升级为主机,
  464. # 并且应该能够正确地与从机“部分重新同步”:因此它们应该总是累积backlog。
  465. # Note that slaves never free the backlog for timeout, since they may be
  466. # promoted to masters later, and should be able to correctly "partially
  467. # resynchronize" with the slaves: hence they should always accumulate backlog.
  468. #
  469. # 值为0表示从不释放积压工作。
  470. # A value of 0 means to never release the backlog.
  471. #
  472. # repl-backlog-ttl 3600
  473. # slave priority是Redis在INFO输出中发布的整数。
  474. # Redis Sentinel使用它来选择一个从属设备,以便在主设备不再正常工作时升级为主设备。
  475. # The slave priority is an integer number published by Redis in the INFO output.
  476. # It is used by Redis Sentinel in order to select a slave to promote into a
  477. # master if the master is no longer working correctly.
  478. #
  479. # 优先级较低的从机被认为更适合提升,因此,例如,如果有三个优先级为10、100、25的从机,
  480. # Sentinel将选择优先级为10的从机,这是最低的。
  481. # A slave with a low priority number is considered better for promotion, so
  482. # for instance if there are three slaves with priority 10, 100, 25 Sentinel will
  483. # pick the one with priority 10, that is the lowest.
  484. #
  485. # 但是,特殊优先级为0表示从机无法执行主机角色,
  486. # 因此Redis Sentinel永远不会选择优先级为0的从机进行升级。
  487. # However a special priority of 0 marks the slave as not able to perform the
  488. # role of master, so a slave with priority of 0 will never be selected by
  489. # Redis Sentinel for promotion.
  490. #
  491. # 默认情况下,优先级为100。
  492. # By default the priority is 100.
  493. slave-priority 100
  494. # 如果连接的从属设备少于N个,且延迟时间小于或等于M秒,则主设备有可能停止接受写操作。
  495. # It is possible for a master to stop accepting writes if there are less than
  496. # N slaves connected, having a lag less or equal than M seconds.
  497. #
  498. # N个从机需要处于“在线”状态。
  499. # The N slaves need to be in "online" state.
  500. #
  501. # 滞后时间(以秒为单位)必须<=指定值,它是从从从机接收的最后一次ping(通常每秒发送一次)计算出来的。
  502. # The lag in seconds, that must be <= the specified value, is calculated from
  503. # the last ping received from the slave, that is usually sent every second.
  504. #
  505. # 此选项不保证N个复制副本将接受写入,
  506. # 但将在没有足够的从副本可用时将丢失写入的暴露窗口限制在指定的秒数内。
  507. # This option does not GUARANTEE that N replicas will accept the write, but
  508. # will limit the window of exposure for lost writes in case not enough slaves
  509. # are available, to the specified number of seconds.
  510. #
  511. # 例如,要要求至少3个滞后时间小于等于10秒的从机,请使用:
  512. # For example to require at least 3 slaves with a lag <= 10 seconds use:
  513. #
  514. # min-slaves-to-write 3
  515. # min-slaves-max-lag 10
  516. #
  517. # 将其中一个设置为0将禁用该功能。
  518. # Setting one or the other to 0 disables the feature.
  519. #
  520. # 默认情况下,要写入的最小从属设置为0(功能已禁用),最小从属最大滞后设置为10。
  521. # By default min-slaves-to-write is set to 0 (feature disabled) and
  522. # min-slaves-max-lag is set to 10.
  523. # Redis主机能够以不同的方式列出连接的从机的地址和端口。
  524. # 例如,“信息复制”部分提供了这些信息,Redis Sentinel在其他工具中使用这些信息来发现从属实例。
  525. # 另一个可以获得这些信息的地方是主机的“ROLE”命令的输出。
  526. # A Redis master is able to list the address and port of the attached
  527. # slaves in different ways. For example the "INFO replication" section
  528. # offers this information, which is used, among other tools, by
  529. # Redis Sentinel in order to discover slave instances.
  530. # Another place where this info is available is in the output of the
  531. # "ROLE" command of a master.
  532. #
  533. # 从机通常报告的列出的IP和地址通过以下方式获得:
  534. # The listed IP and address normally reported by a slave is obtained
  535. # in the following way:
  536. #
  537. # IP:通过检查从机用于连接主机的套接字的对等地址自动检测地址。
  538. # IP: The address is auto detected by checking the peer address
  539. # of the socket used by the slave to connect with the master.
  540. #
  541. # 端口:端口在复制握手期间由从机通信,通常是从机用于列出连接的端口。
  542. # Port: The port is communicated by the slave during the replication
  543. # handshake, and is normally the port that the slave is using to
  544. # list for connections.
  545. #
  546. # 然而,当使用端口转发或网络地址转换(NAT)时,从机实际上可以通过不同的IP和端口对到达。
  547. # 从属服务器可以使用以下两个选项向其主服务器报告一组特定的IP和端口,以便INFO和ROLE都报告这些值。
  548. # However when port forwarding or Network Address Translation (NAT) is
  549. # used, the slave may be actually reachable via different IP and port
  550. # pairs. The following two options can be used by a slave in order to
  551. # report to its master a specific set of IP and port, so that both INFO
  552. # and ROLE will report those values.
  553. #
  554. # 如果只需要覆盖端口或IP地址,则无需同时使用这两个选项。
  555. # There is no need to use both the options if you need to override just
  556. # the port or the IP address.
  557. #
  558. # slave-announce-ip 5.5.5.5
  559. # slave-announce-port 1234
  560. ################################## SECURITY ###################################
  561. # 要求客户端在处理任何其他命令之前发出AUTH<PASSWORD>。
  562. # 在您不信任其他人可以访问运行redis服务器的主机的环境中,这可能很有用。
  563. # Require clients to issue AUTH <PASSWORD> before processing any other
  564. # commands. This might be useful in environments in which you do not trust
  565. # others with access to the host running redis-server.
  566. #
  567. # 为了向后兼容性和大多数人不需要auth(例如,他们运行自己的服务器),这应该被注释掉。
  568. # This should stay commented out for backward compatibility and because most
  569. # people do not need auth (e.g. they run their own servers).
  570. #
  571. # 警告:由于Redis速度非常快,外部用户可以在一个好的盒子上每秒尝试多达150k个密码。
  572. # 这意味着你应该使用一个非常强大的密码,否则它将很容易被打破。
  573. # Warning: since Redis is pretty fast an outside user can try up to
  574. # 150k passwords per second against a good box. This means that you should
  575. # use a very strong password otherwise it will be very easy to break.
  576. #
  577. # requirepass foobared
  578. # 命令重命名。
  579. # Command renaming.
  580. #
  581. # 可以在共享环境中更改危险命令的名称。例如,CONFIG命令可能会被重命名为一些难以猜测的内容,
  582. # 这样它仍然可以用于内部使用工具,但不可用于一般客户机。
  583. # It is possible to change the name of dangerous commands in a shared
  584. # environment. For instance the CONFIG command may be renamed into something
  585. # hard to guess so that it will still be available for internal-use tools
  586. # but not available for general clients.
  587. #
  588. # 例如:
  589. # Example:
  590. #
  591. # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
  592. #
  593. # 也可以通过将命令重命名为空字符串来完全终止命令:
  594. # It is also possible to completely kill a command by renaming it into
  595. # an empty string:
  596. #
  597. # rename-command CONFIG ""
  598. #
  599. # 请注意,更改登录到AOF文件或传输到从属服务器的命令的名称可能会导致问题。
  600. # Please note that changing the name of commands that are logged into the
  601. # AOF file or transmitted to slaves may cause problems.
  602. ################################### CLIENTS ####################################
  603. # 设置同时连接的最大客户端数。默认情况下,此限制设置为10000个客户端,
  604. # 但是如果Redis服务器无法配置进程文件限制以允许指定的限制,
  605. # 则允许的最大客户端数将设置为当前文件限制减去32(因为Redis保留了一些文件描述符供内部使用)。
  606. # Set the max number of connected clients at the same time. By default
  607. # this limit is set to 10000 clients, however if the Redis server is not
  608. # able to configure the process file limit to allow for the specified limit
  609. # the max number of allowed clients is set to the current file limit
  610. # minus 32 (as Redis reserves a few file descriptors for internal uses).
  611. #
  612. # 一旦达到限制,Redis将关闭所有新连接,并发送一个错误“max number of clients reached”。
  613. # Once the limit is reached Redis will close all the new connections sending
  614. # an error 'max number of clients reached'.
  615. #
  616. # maxclients 10000
  617. ############################## MEMORY MANAGEMENT ################################
  618. # 将内存使用限制设置为指定的字节数。
  619. # 当达到内存限制时,Redis将根据所选的逐出策略(参见maxmemory策略)尝试删除密钥。
  620. # Set a memory usage limit to the specified amount of bytes.
  621. # When the memory limit is reached Redis will try to remove keys
  622. # according to the eviction policy selected (see maxmemory-policy).
  623. #
  624. # 如果Redis无法根据策略删除密钥,或者如果策略设置为“noeviction”,
  625. # Redis将开始以错误的方式答复使用更多内存的命令,如set、LPUSH等,并将继续答复GET等只读命令。
  626. # If Redis can't remove keys according to the policy, or if the policy is
  627. # set to 'noeviction', Redis will start to reply with errors to commands
  628. # that would use more memory, like SET, LPUSH, and so on, and will continue
  629. # to reply to read-only commands like GET.
  630. #
  631. # 当使用Redis作为LRU或LFU缓存,或者为实例设置硬内存限制(使用“noeviction”策略)时,此选项通常很有用
  632. # This option is usually useful when using Redis as an LRU or LFU cache, or to
  633. # set a hard memory limit for an instance (using the 'noeviction' policy).
  634. #
  635. # 警告:如果在maxmemory打开的情况下将从属服务器连接到实例,
  636. # 则从已用内存计数中减去为从属服务器提供数据所需的输出缓冲区的大小,
  637. # 这样网络问题/重新同步就不会触发退出密钥的循环,反过来,从机的输出缓冲区充满了被逐出的密钥的del,
  638. # 从而触发了更多密钥的删除,以此类推,直到数据库完全清空。
  639. # WARNING: If you have slaves attached to an instance with maxmemory on,
  640. # the size of the output buffers needed to feed the slaves are subtracted
  641. # from the used memory count, so that network problems / resyncs will
  642. # not trigger a loop where keys are evicted, and in turn the output
  643. # buffer of slaves is full with DELs of keys evicted triggering the deletion
  644. # of more keys, and so forth until the database is completely emptied.
  645. #
  646. # 总之...如果您连接了从机,建议您设置maxmemory的下限,
  647. # 以便系统上有一些可用RAM用于从机输出缓冲区(但如果策略为“noeviction”,则不需要这样做)。
  648. # In short... if you have slaves attached it is suggested that you set a lower
  649. # limit for maxmemory so that there is some free RAM on the system for slave
  650. # output buffers (but this is not needed if the policy is 'noeviction').
  651. #
  652. # maxmemory <bytes>
  653. # MAXMEMORY策略:当到达MAXMEMORY时,Redis将如何选择要删除的内容。您可以从五种行为中选择:
  654. # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
  655. # is reached. You can select among five behaviors:
  656. #
  657. # 在具有过期集的密钥中使用近似的LRU逐出。
  658. # volatile-lru -> Evict using approximated LRU among the keys with an expire set.
  659. #
  660. # 使用近似的LRU逐出任何密钥。
  661. # allkeys-lru -> Evict any key using approximated LRU.
  662. #
  663. # 在具有过期集的键中使用近似LFU逐出。
  664. # volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
  665. #
  666. # 使用近似LFU逐出任何键。
  667. # allkeys-lfu -> Evict any key using approximated LFU.
  668. #
  669. # 从具有过期集的密钥中移除随机密钥。
  670. # volatile-random -> Remove a random key among the ones with an expire set.
  671. #
  672. # 删除随机键,任意键。
  673. # allkeys-random -> Remove a random key, any key.
  674. #
  675. # 删除过期时间最近的密钥(次要TTL)
  676. # volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
  677. #
  678. # 不逐出任何内容,只返回一个写操作错误。
  679. # noeviction -> Don't evict anything, just return an error on write operations.
  680. #
  681. # LRU表示最近最少使用
  682. # LRU means Least Recently Used
  683. #
  684. # LFU表示使用频率最低
  685. # LFU means Least Frequently Used
  686. #
  687. # LRU、LFU和volatile-ttl均采用近似随机算法实现。
  688. # Both LRU, LFU and volatile-ttl are implemented using approximated
  689. # randomized algorithms.
  690. #
  691. # 注意:对于上述任何策略,Redis都会在写操作时返回一个错误,因为没有合适的键来逐出。
  692. # Note: with any of the above policies, Redis will return an error on write
  693. # operations, when there are no suitable keys for eviction.
  694. #
  695. # 在编写之日,这些命令是:
  696. # At the date of writing these commands are: set setnx setex append
  697. # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
  698. # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
  699. # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
  700. # getset mset msetnx exec sort
  701. #
  702. # 默认值为:
  703. # The default is:
  704. #
  705. # maxmemory-policy noeviction
  706. # LRU、LFU和minimal-TTL算法不是精确算法,而是近似算法(为了节省内存),因此您可以调整它的速度或精度。
  707. # 对于默认Redis将检查五个键并选择最近使用较少的键,您可以使用以下配置指令更改样本大小。
  708. # LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated
  709. # algorithms (in order to save memory), so you can tune it for speed or
  710. # accuracy. For default Redis will check five keys and pick the one that was
  711. # used less recently, you can change the sample size using the following
  712. # configuration directive.
  713. #
  714. # 默认值5会产生足够好的结果。10非常接近真实的LRU,但需要更多的CPU。3更快,但不是很准确。
  715. # The default of 5 produces good enough results. 10 Approximates very closely
  716. # true LRU but costs more CPU. 3 is faster but not very accurate.
  717. #
  718. # maxmemory-samples 5
  719. ############################# LAZY FREEING ####################################
  720. # Redis有两个删除键的原语。一个称为DEL,是对象的阻塞删除。这意味着服务器停止处理新命令,
  721. # 以便以同步方式回收与对象关联的所有内存。如果删除的键与一个小对象相关联,
  722. # 那么执行DEL命令所需的时间非常少,与Redis中的大多数其他O(1)或O(logn)命令相当。
  723. # 但是,如果密钥与包含数百万个元素的聚合值相关联,则服务器可以阻塞很长时间(甚至几秒钟)以完成操作。
  724. # Redis has two primitives to delete keys. One is called DEL and is a blocking
  725. # deletion of the object. It means that the server stops processing new commands
  726. # in order to reclaim all the memory associated with an object in a synchronous
  727. # way. If the key deleted is associated with a small object, the time needed
  728. # in order to execute the DEL command is very small and comparable to most other
  729. # O(1) or O(log_N) commands in Redis. However if the key is associated with an
  730. # aggregated value containing millions of elements, the server can block for
  731. # a long time (even seconds) in order to complete the operation.
  732. #
  733. # 基于上述原因,Redis还提供了UNLINK(non-blocking DEL)和FLUSHDB命令的ASYNC选项等非阻塞删除原语,
  734. # 以便在后台回收内存。这些命令在固定时间内执行。另一个线程将尽可能快地增量释放背景中的对象。
  735. # For the above reasons Redis also offers non blocking deletion primitives
  736. # such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and
  737. # FLUSHDB commands, in order to reclaim memory in background. Those commands
  738. # are executed in constant time. Another thread will incrementally free the
  739. # object in the background as fast as possible.
  740. #
  741. # FLUSHDB和FLUSHDB的DEL、UNLINK和ASYNC选项由用户控制。
  742. # 应用程序的设计决定了何时使用其中一个是好主意。然而,Redis服务器有时不得不删除密钥或刷新整个数据库,
  743. # 作为其他操作的副作用。具体来说,在以下场景中,Redis独立于用户调用删除对象:
  744. # DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled.
  745. # It's up to the design of the application to understand when it is a good
  746. # idea to use one or the other. However the Redis server sometimes has to
  747. # delete keys or flush the whole database as a side effect of other operations.
  748. # Specifically Redis deletes objects independently of a user call in the
  749. # following scenarios:
  750. #
  751. # 逐出时,由于maxmemory和maxmemory策略配置,为了给新数据腾出空间,而不超过指定的内存限制。
  752. # 1) On eviction, because of the maxmemory and maxmemory policy configurations,
  753. # in order to make room for new data, without going over the specified
  754. # memory limit.
  755. #
  756. # 因为expire:当必须从内存中删除具有相关生存时间的密钥(请参阅expire命令)时。
  757. # 2) Because of expire: when a key with an associated time to live (see the
  758. # EXPIRE command) must be deleted from memory.
  759. #
  760. # 因为命令的一个副作用是在一个可能已经存在的键上存储数据。
  761. # 例如,当用另一个密钥内容替换旧密钥内容时,RENAME命令可能会删除它。
  762. # 类似地,SUNIONSTORE或SORT with STORE选项可能会删除现有密钥。
  763. # SET命令本身删除指定键的任何旧内容,以便用指定的字符串替换它。
  764. # 3) Because of a side effect of a command that stores data on a key that may
  765. # already exist. For example the RENAME command may delete the old key
  766. # content when it is replaced with another one. Similarly SUNIONSTORE
  767. # or SORT with STORE option may delete existing keys. The SET command
  768. # itself removes any old content of the specified key in order to replace
  769. # it with the specified string.
  770. #
  771. # 在复制过程中,当从机与其主机执行完全重新同步时,整个数据库的内容将被删除,
  772. # 以便加载刚刚传输的RDB文件。
  773. # 4) During replication, when a slave performs a full resynchronization with
  774. # its master, the content of the whole database is removed in order to
  775. # load the RDB file just transfered.
  776. #
  777. # 在上述所有情况下,默认情况是以阻塞方式删除对象,就像调用DEL一样。
  778. # 但是,您可以使用以下配置指令专门配置每种情况,以非阻塞方式释放内存,就像调用UNLINK一样:
  779. # In all the above cases the default is to delete objects in a blocking way,
  780. # like if DEL was called. However you can configure each case specifically
  781. # in order to instead release memory in a non-blocking way like if UNLINK
  782. # was called, using the following configuration directives:
  783. lazyfree-lazy-eviction no
  784. lazyfree-lazy-expire no
  785. lazyfree-lazy-server-del no
  786. slave-lazy-flush no
  787. ############################## APPEND ONLY MODE ###############################
  788. # 默认情况下,Redis将数据集异步转储到磁盘上。这种模式在许多应用程序中已经足够好了,
  789. # 但是Redis进程出现问题或断电可能会导致几分钟的写丢失(取决于配置的保存点)。
  790. # By default Redis asynchronously dumps the dataset on disk. This mode is
  791. # good enough in many applications, but an issue with the Redis process or
  792. # a power outage may result into a few minutes of writes lost (depending on
  793. # the configured save points).
  794. #
  795. # 仅附加文件是一种可选的持久性模式,它提供了更好的持久性。
  796. # 例如,如果使用默认的数据fsync策略(见后面的配置文件),
  797. # Redis可能会在服务器断电之类的戏剧性事件中丢失一秒钟的写操作,或者如果Redis进程本身发生错误,
  798. # 但操作系统仍然正常运行,则会丢失一次写操作。
  799. # The Append Only File is an alternative persistence mode that provides
  800. # much better durability. For instance using the default data fsync policy
  801. # (see later in the config file) Redis can lose just one second of writes in a
  802. # dramatic event like a server power outage, or a single write if something
  803. # wrong with the Redis process itself happens, but the operating system is
  804. # still running correctly.
  805. #
  806. # AOF和RDB持久性可以同时启用而不会出现问题。
  807. # 如果启动时启用了AOF,Redis将加载AOF,即具有更好持久性保证的文件。
  808. # AOF and RDB persistence can be enabled at the same time without problems.
  809. # If the AOF is enabled on startup Redis will load the AOF, that is the file
  810. # with the better durability guarantees.
  811. #
  812. # Please check http://redis.io/topics/persistence for more information.
  813. appendonly no
  814. # 仅附加文件的名称(默认值:“appendonly.aof”)
  815. # The name of the append only file (default: "appendonly.aof")
  816. appendfilename "appendonly.aof"
  817. # fsync()调用告诉操作系统实际将数据写入磁盘,而不是等待输出缓冲区中的更多数据。
  818. # 有些操作系统真的会在磁盘上刷新数据,有些操作系统只会尝试尽快这样做。
  819. # The fsync() call tells the Operating System to actually write data on disk
  820. # instead of waiting for more data in the output buffer. Some OS will really flush
  821. # data on disk, some other OS will just try to do it ASAP.
  822. #
  823. # Redis支持三种不同的模式:
  824. # Redis supports three different modes:
  825. #
  826. # 否:不要fsync,只要让操作系统在需要时刷新数据即可。更快。
  827. # 总是:每次写入仅附加日志后进行fsync。慢,最安全。
  828. # everysec: fsync每秒只同步一次。妥协。
  829. # no: don't fsync, just let the OS flush the data when it wants. Faster.
  830. # always: fsync after every write to the append only log. Slow, Safest.
  831. # everysec: fsync only one time every second. Compromise.
  832. #
  833. # 默认值是“everysec”,因为这通常是速度和数据安全之间的正确折衷。这是由你来理解,
  834. # 如果你可以放松这个“否”,这将让操作系统刷新输出缓冲器当它想要的,
  835. # 为了更好的性能(但如果你能生活在一些数据丢失的想法,考虑默认持久模式的快照),或相反,
  836. # 使用“总是”这是非常缓慢,但有点比everysec安全。
  837. # The default is "everysec", as that's usually the right compromise between
  838. # speed and data safety. It's up to you to understand if you can relax this to
  839. # "no" that will let the operating system flush the output buffer when
  840. # it wants, for better performances (but if you can live with the idea of
  841. # some data loss consider the default persistence mode that's snapshotting),
  842. # or on the contrary, use "always" that's very slow but a bit safer than
  843. # everysec.
  844. #
  845. # 更多详情请查看以下文章:
  846. # More details please check the following article:
  847. # http://antirez.com/post/redis-persistence-demystified.html
  848. #
  849. # 如果不确定,请使用“everysec”。
  850. # If unsure, use "everysec".
  851. # appendfsync always
  852. appendfsync everysec
  853. # appendfsync no
  854. # 当AOF fsync策略设置为always或everysec,并且后台保存进程(后台保存或AOF日志后台重写)
  855. # 正在对磁盘执行大量I/O时,在某些Linux配置中,Redis可能会在fsync()调用上阻塞太长时间。
  856. # 请注意,目前还没有解决此问题的方法,因为即使在不同的线程中执行fsync,
  857. # 也会阻止我们的同步写入(2)调用。
  858. # When the AOF fsync policy is set to always or everysec, and a background
  859. # saving process (a background save or AOF log background rewriting) is
  860. # performing a lot of I/O against the disk, in some Linux configurations
  861. # Redis may block too long on the fsync() call. Note that there is no fix for
  862. # this currently, as even performing fsync in a different thread will block
  863. # our synchronous write(2) call.
  864. #
  865. # 为了缓解此问题,可以使用以下选项,以防止在进行BGSAVE或BGREWRITEAOF时在主进程中调用fsync()。
  866. # In order to mitigate this problem it's possible to use the following option
  867. # that will prevent fsync() from being called in the main process while a
  868. # BGSAVE or BGREWRITEAOF is in progress.
  869. #
  870. # 这意味着,当另一个孩子在储蓄时,Redis的持久性与“appendfsync none”相同。
  871. # 实际上,这意味着在最坏的情况下(使用默认的Linux设置),可能会丢失最多30秒的日志。
  872. # This means that while another child is saving, the durability of Redis is
  873. # the same as "appendfsync none". In practical terms, this means that it is
  874. # possible to lose up to 30 seconds of log in the worst scenario (with the
  875. # default Linux settings).
  876. #
  877. # 如果您有延迟问题,请将此设置为“是”。否则,从耐久性的角度来看,选择“否”是最安全的。
  878. # If you have latency problems turn this to "yes". Otherwise leave it as
  879. # "no" that is the safest pick from the point of view of durability.
  880. no-appendfsync-on-rewrite no
  881. # 自动重写仅附加的文件。
  882. # Redis能够在AOF日志大小以指定的百分比增长时自动重写隐式调用BGREWRITEAOF的日志文件。
  883. # Automatic rewrite of the append only file.
  884. # Redis is able to automatically rewrite the log file implicitly calling
  885. # BGREWRITEAOF when the AOF log size grows by the specified percentage.
  886. #
  887. # 工作原理是这样的:Redis会记住最近一次重写后AOF文件的大小
  888. # (如果重启后没有发生重写,则使用启动时AOF的大小)。
  889. # This is how it works: Redis remembers the size of the AOF file after the
  890. # latest rewrite (if no rewrite has happened since the restart, the size of
  891. # the AOF at startup is used).
  892. #
  893. # 此基本大小与当前大小进行比较。如果当前大小大于指定的百分比,则会触发重写。
  894. # 您还需要为要重写的AOF文件指定一个最小大小,这对于避免重写AOF文件非常有用,
  895. # 即使达到了百分比增加,但仍然非常小。
  896. # This base size is compared to the current size. If the current size is
  897. # bigger than the specified percentage, the rewrite is triggered. Also
  898. # you need to specify a minimal size for the AOF file to be rewritten, this
  899. # is useful to avoid rewriting the AOF file even if the percentage increase
  900. # is reached but it is still pretty small.
  901. #
  902. # 指定0的百分比以禁用自动AOF重写功能。
  903. # Specify a percentage of zero in order to disable the automatic AOF
  904. # rewrite feature.
  905. auto-aof-rewrite-percentage 100
  906. auto-aof-rewrite-min-size 64mb
  907. # 在Redis启动过程的最后,当AOF数据被加载回内存时,可能会发现AOF文件被截断。
  908. # 当运行Redis的系统崩溃时,尤其是在没有data=ordered选项的情况下挂载ext4文件系统时,
  909. # 可能会发生这种情况(但是当Redis本身崩溃或中止但操作系统仍然正常工作时,这种情况就不会发生)。
  910. # An AOF file may be found to be truncated at the end during the Redis
  911. # startup process, when the AOF data gets loaded back into memory.
  912. # This may happen when the system where Redis is running
  913. # crashes, especially when an ext4 filesystem is mounted without the
  914. # data=ordered option (however this can't happen when Redis itself
  915. # crashes or aborts but the operating system still works correctly).
  916. #
  917. # Redis可以在发生这种情况时带着错误退出,也可以加载尽可能多的数据(现在是默认值),
  918. # 如果发现AOF文件在末尾被截断,就可以启动。以下选项控制此行为。
  919. # Redis can either exit with an error when this happens, or load as much
  920. # data as possible (the default now) and start if the AOF file is found
  921. # to be truncated at the end. The following option controls this behavior.
  922. #
  923. # 如果aof load TREATED设置为“是”,则加载截断的aof文件,Redis服务器将开始发出日志,以通知用户事件。
  924. # 否则,如果选项设置为“否”,则服务器会因错误中止,拒绝启动。
  925. # 当选项设置为否时,用户需要在重新启动服务器之前使用“redis check AOF”实用程序修复AOF文件。
  926. # If aof-load-truncated is set to yes, a truncated AOF file is loaded and
  927. # the Redis server starts emitting a log to inform the user of the event.
  928. # Otherwise if the option is set to no, the server aborts with an error
  929. # and refuses to start. When the option is set to no, the user requires
  930. # to fix the AOF file using the "redis-check-aof" utility before to restart
  931. # the server.
  932. #
  933. # 注意,如果发现AOF文件在中间被损坏,服务器仍将退出一个错误。
  934. # 此选项仅适用于Redis尝试从AOF文件读取更多数据但找不到足够字节的情况。
  935. # Note that if the AOF file will be found to be corrupted in the middle
  936. # the server will still exit with an error. This option only applies when
  937. # Redis will try to read more data from the AOF file but not enough bytes
  938. # will be found.
  939. aof-load-truncated yes
  940. # 当重写AOF文件时,Redis能够在AOF文件中使用RDB前导码,以实现更快的重写和恢复。
  941. # 启用此选项后,重写的AOF文件由两个不同的节组成:
  942. # When rewriting the AOF file, Redis is able to use an RDB preamble in the
  943. # AOF file for faster rewrites and recoveries. When this option is turned
  944. # on the rewritten AOF file is composed of two different stanzas:
  945. #
  946. # [RDB file][AOF tail]
  947. #
  948. # 加载Redis时,会识别出AOF文件以“Redis”字符串开头,并加载前缀RDB文件,然后继续加载AOF尾部。
  949. # When loading Redis recognizes that the AOF file starts with the "REDIS"
  950. # string and loads the prefixed RDB file, and continues loading the AOF
  951. # tail.
  952. #
  953. # 当前默认情况下,此选项处于关闭状态,以避免格式更改带来的意外情况,但在某些时候将用作默认值。
  954. # This is currently turned off by default in order to avoid the surprise
  955. # of a format change, but will at some point be used as the default.
  956. aof-use-rdb-preamble no
  957. ################################ LUA SCRIPTING ###############################
  958. # Lua脚本的最大执行时间(毫秒)。
  959. # Max execution time of a Lua script in milliseconds.
  960. #
  961. # 如果达到最大执行时间,Redis将记录在允许的最长时间之后脚本仍在执行中,并将开始回复有错误的查询。
  962. # If the maximum execution time is reached Redis will log that a script is
  963. # still in execution after the maximum allowed time and will start to
  964. # reply to queries with an error.
  965. #
  966. # 当长时间运行的脚本超过最大执行时间时,只有脚本KILL和SHUTDOWN NOSAVE命令可用。
  967. # 第一个命令可用于停止尚未调用write命令的脚本。
  968. # 第二种方法是在脚本已经发出写入命令但用户不想等待脚本自然终止的情况下关闭服务器的唯一方法。
  969. # When a long running script exceeds the maximum execution time only the
  970. # SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
  971. # used to stop a script that did not yet called write commands. The second
  972. # is the only way to shut down the server in the case a write command was
  973. # already issued by the script but the user doesn't want to wait for the natural
  974. # termination of the script.
  975. #
  976. # 将其设置为0或负值,以便在没有警告的情况下无限执行。
  977. # Set it to 0 or a negative value for unlimited execution without warnings.
  978. lua-time-limit 5000
  979. ################################ REDIS CLUSTER ###############################
  980. #
  981. # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  982. # 警告:Redis集群被认为是稳定的代码,但是为了将其标记为“成熟”,
  983. # 我们需要等待相当一部分用户将其部署到生产环境中。
  984. # WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however
  985. # in order to mark it as "mature" we need to wait for a non trivial percentage
  986. # of users to deploy it in production.
  987. # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  988. #
  989. # 普通Redis实例不能是Redis集群的一部分;只有作为群集节点启动的节点才能启动。
  990. # 要将Redis实例启动为群集节点,请启用群集支持,取消注释以下内容:
  991. # Normal Redis instances can't be part of a Redis Cluster; only nodes that are
  992. # started as cluster nodes can. In order to start a Redis instance as a
  993. # cluster node enable the cluster support uncommenting the following:
  994. #
  995. # cluster-enabled yes
  996. # 每个集群节点都有一个集群配置文件。此文件不可手动编辑。它由Redis节点创建和更新。
  997. # 每个Redis集群节点都需要不同的集群配置文件。
  998. # 确保在同一系统中运行的实例没有重叠的群集配置文件名。
  999. # Every cluster node has a cluster configuration file. This file is not
  1000. # intended to be edited by hand. It is created and updated by Redis nodes.
  1001. # Every Redis Cluster node requires a different cluster configuration file.
  1002. # Make sure that instances running in the same system do not have
  1003. # overlapping cluster configuration file names.
  1004. #
  1005. # cluster-config-file nodes-6379.conf
  1006. # Cluster node timeout是节点必须无法访问才能被视为处于故障状态的毫秒数。
  1007. # 大多数其他内部时间限制是节点超时的倍数。
  1008. # Cluster node timeout is the amount of milliseconds a node must be unreachable
  1009. # for it to be considered in failure state.
  1010. # Most other internal time limits are multiple of the node timeout.
  1011. #
  1012. # cluster-node-timeout 15000
  1013. #如果发生故障的主设备的从属设备的数据看起来太旧,它将避免启动故障转移。
  1014. # A slave of a failing master will avoid to start a failover if its data
  1015. # looks too old.
  1016. #
  1017. # 从机没有简单的方法可以精确测量其“数据年龄”,因此执行以下两项检查:
  1018. # There is no simple way for a slave to actually have an exact measure of
  1019. # its "data age", so the following two checks are performed:
  1020. #
  1021. # 如果有多个从属设备能够进行故障切换,它们会交换消息,
  1022. # 以便尝试为具有最佳复制偏移量的从属设备提供优势(从主设备处理更多数据)。
  1023. # 从属服务器将尝试通过偏移量获得它们的秩,并在故障转移开始时应用与它们的秩成比例的延迟。
  1024. # 1) If there are multiple slaves able to failover, they exchange messages
  1025. # in order to try to give an advantage to the slave with the best
  1026. # replication offset (more data from the master processed).
  1027. # Slaves will try to get their rank by offset, and apply to the start
  1028. # of the failover a delay proportional to their rank.
  1029. #
  1030. # 每个从机计算最后一次与主机交互的时间。这可以是接收到的最后一次ping或命令
  1031. # (如果主机仍处于“已连接”状态),也可以是与主机断开连接后经过的时间(如果复制链路当前已关闭)。
  1032. # 如果上一次交互太旧,从机将根本不尝试故障转移。
  1033. # 2) Every single slave computes the time of the last interaction with
  1034. # its master. This can be the last ping or command received (if the master
  1035. # is still in the "connected" state), or the time that elapsed since the
  1036. # disconnection with the master (if the replication link is currently down).
  1037. # If the last interaction is too old, the slave will not try to failover
  1038. # at all.
  1039. #
  1040. # 点“2”可由用户调整。具体来说,如果自上次与主设备交互以来,所用时间大于以下时间,
  1041. # 则从设备将不会执行故障转移:
  1042. # The point "2" can be tuned by user. Specifically a slave will not perform
  1043. # the failover if, since the last interaction with the master, the time
  1044. # elapsed is greater than:
  1045. #
  1046. # (node-timeout * slave-validity-factor) + repl-ping-slave-period
  1047. #
  1048. # 因此,例如,如果节点超时为30秒,从机有效性系数为10,并且假设默认的repl ping slave周期为10秒,
  1049. # 那么如果从机无法与主机通信的时间超过310秒,它将不会尝试故障转移。
  1050. # So for example if node-timeout is 30 seconds, and the slave-validity-factor
  1051. # is 10, and assuming a default repl-ping-slave-period of 10 seconds, the
  1052. # slave will not try to failover if it was not able to talk with the master
  1053. # for longer than 310 seconds.
  1054. #
  1055. # 较大的从属有效性因子可能允许数据太旧的从属设备故障切换到主设备,
  1056. # 而太小的值可能会阻止集群选择从属设备。
  1057. # A large slave-validity-factor may allow slaves with too old data to failover
  1058. # a master, while a too small value may prevent the cluster from being able to
  1059. # elect a slave at all.
  1060. #
  1061. # 为了获得最大可用性,可以将从属有效性因子设置为0,这意味着从属服务器将始终尝试故障转移主服务器,
  1062. # 而不管它们上次与主服务器交互的时间是什么时候。
  1063. #(然而,他们总是尝试应用与他们的偏移等级成比例的延迟)。
  1064. # For maximum availability, it is possible to set the slave-validity-factor
  1065. # to a value of 0, which means, that slaves will always try to failover the
  1066. # master regardless of the last time they interacted with the master.
  1067. # (However they'll always try to apply a delay proportional to their
  1068. # offset rank).
  1069. #
  1070. # 零是唯一一个能够保证当所有分区恢复时,集群始终能够继续的值。
  1071. # Zero is the only value able to guarantee that when all the partitions heal
  1072. # the cluster will always be able to continue.
  1073. #
  1074. # cluster-slave-validity-factor 10
  1075. # 集群从机能够迁移到孤立的主机,即没有工作从机的主机。这提高了集群抵抗失败的能力,
  1076. # 因为如果孤立的主服务器没有工作的从属服务器,那么它就不能在发生故障时进行故障转移。
  1077. # Cluster slaves are able to migrate to orphaned masters, that are masters
  1078. # that are left without working slaves. This improves the cluster ability
  1079. # to resist to failures as otherwise an orphaned master can't be failed over
  1080. # in case of failure if it has no working slaves.
  1081. #
  1082. # 只有当他们的老主人至少还有一定数量的其他奴隶在工作时,奴隶才会迁移到孤儿主人那里。
  1083. # 这个数字就是“移民壁垒”。迁移屏障为1意味着一个从机只有在其主机至少有一个其他工作从机时才会迁移,
  1084. # 以此类推。它通常反映集群中每个主服务器所需的从属服务器数量。
  1085. # Slaves migrate to orphaned masters only if there are still at least a
  1086. # given number of other working slaves for their old master. This number
  1087. # is the "migration barrier". A migration barrier of 1 means that a slave
  1088. # will migrate only if there is at least 1 other working slave for its master
  1089. # and so forth. It usually reflects the number of slaves you want for every
  1090. # master in your cluster.
  1091. #
  1092. # 默认值为1(从属服务器仅在其主服务器至少保留一个从属服务器时迁移)。
  1093. # 要禁用迁移,只需将其设置为非常大的值。
  1094. # 可以设置值0,但仅对调试有用,在生产中很危险。
  1095. # Default is 1 (slaves migrate only if their masters remain with at least
  1096. # one slave). To disable migration just set it to a very large value.
  1097. # A value of 0 can be set but is useful only for debugging and dangerous
  1098. # in production.
  1099. #
  1100. # cluster-migration-barrier 1
  1101. # 默认情况下,如果Redis集群节点检测到至少有一个散列槽未覆盖(没有可用的节点为其提供服务),
  1102. # 那么它们将停止接受查询。
  1103. # 这样,如果集群部分关闭(例如,一系列哈希槽不再覆盖),那么所有集群最终都将不可用。
  1104. # 一旦所有插槽被覆盖,它就会自动返回可用状态。
  1105. # By default Redis Cluster nodes stop accepting queries if they detect there
  1106. # is at least an hash slot uncovered (no available node is serving it).
  1107. # This way if the cluster is partially down (for example a range of hash slots
  1108. # are no longer covered) all the cluster becomes, eventually, unavailable.
  1109. # It automatically returns available as soon as all the slots are covered again.
  1110. #
  1111. # 但是,有时您希望正在工作的集群的子集继续接受对仍然覆盖的密钥空间部分的查询。
  1112. # 为此,只需将cluster require full coverage选项设置为no。
  1113. # However sometimes you want the subset of the cluster which is working,
  1114. # to continue to accept queries for the part of the key space that is still
  1115. # covered. In order to do so, just set the cluster-require-full-coverage
  1116. # option to no.
  1117. #
  1118. # cluster-require-full-coverage yes
  1119. # 此选项设置为“是”时,可防止从机在主机故障期间尝试故障转移其主机。
  1120. # 但是,如果强制执行手动故障切换,则主设备仍然可以执行手动故障切换。
  1121. # This option, when set to yes, prevents slaves from trying to failover its
  1122. # master during master failures. However the master can still perform a
  1123. # manual failover, if forced to do so.
  1124. #
  1125. # 这在不同的场景中非常有用,特别是在多个数据中心操作的情况下,如果没有发生完全的DC故障,
  1126. # 我们希望其中一方永远不会得到提升。
  1127. # This is useful in different scenarios, especially in the case of multiple
  1128. # data center operations, where we want one side to never be promoted if not
  1129. # in the case of a total DC failure.
  1130. #
  1131. # cluster-slave-no-failover no
  1132. # 为了设置集群,请务必阅读文档
  1133. # In order to setup your cluster make sure to read the documentation
  1134. # available at http://redis.io web site.
  1135. ########################## CLUSTER DOCKER/NAT support ########################
  1136. # 在某些部署中,Redis集群节点地址发现失败,原因是地址被NAT-ted或端口被转发
  1137. # (典型的情况是Docker和其他容器)。
  1138. # In certain deployments, Redis Cluster nodes address discovery fails, because
  1139. # addresses are NAT-ted or because ports are forwarded (the typical case is
  1140. # Docker and other containers).
  1141. #
  1142. # 为了使Redis集群在这样的环境中工作,需要一个静态配置,其中每个节点都知道自己的公共地址。
  1143. # 以下两个选项用于此范围,分别是:
  1144. # In order to make Redis Cluster working in such environments, a static
  1145. # configuration where each node knows its public address is needed. The
  1146. # following two options are used for this scope, and are:
  1147. #
  1148. # * cluster-announce-ip
  1149. # * cluster-announce-port
  1150. # * cluster-announce-bus-port
  1151. #
  1152. # 每个节点都指示节点其地址、客户机端口和集群消息总线端口。然后在总线包的报头中发布信息,
  1153. # 以便其他节点能够正确映射发布信息的节点的地址。
  1154. # Each instruct the node about its address, client port, and cluster message
  1155. # bus port. The information is then published in the header of the bus packets
  1156. # so that other nodes will be able to correctly map the address of the node
  1157. # publishing the information.
  1158. #
  1159. # 如果不使用上述选项,将使用正常的Redis集群自动检测。
  1160. # If the above options are not used, the normal Redis Cluster auto-detection
  1161. # will be used instead.
  1162. #
  1163. # 请注意,重新映射时,总线端口可能不在客户端端口+10000的固定偏移量处,
  1164. # 因此您可以根据重新映射的方式指定任何端口和总线端口。如果没有设置总线端口,
  1165. # 则通常使用10000的固定偏移量。
  1166. # Note that when remapped, the bus port may not be at the fixed offset of
  1167. # clients port + 10000, so you can specify any port and bus-port depending
  1168. # on how they get remapped. If the bus-port is not set, a fixed offset of
  1169. # 10000 will be used as usually.
  1170. #
  1171. # Example:
  1172. #
  1173. # cluster-announce-ip 10.1.1.5
  1174. # cluster-announce-port 6379
  1175. # cluster-announce-bus-port 6380
  1176. ################################## SLOW LOG ###################################
  1177. # Redis Slow Log是一个系统,用于记录超出指定执行时间的查询。
  1178. # 执行时间不包括与客户端交谈、发送应答等I/O操作,而是实际执行命令所需的时间
  1179. # (这是命令执行的唯一阶段,线程被阻塞,同时无法服务其他请求)。
  1180. # The Redis Slow Log is a system to log queries that exceeded a specified
  1181. # execution time. The execution time does not include the I/O operations
  1182. # like talking with the client, sending the reply and so forth,
  1183. # but just the time needed to actually execute the command (this is the only
  1184. # stage of command execution where the thread is blocked and can not serve
  1185. # other requests in the meantime).
  1186. #
  1187. # 您可以使用两个参数来配置慢日志:一个参数告诉Redis为了记录命令要超过的执行时间(以微秒为单位),
  1188. # 另一个参数是慢日志的长度。记录新命令时,将从记录的命令队列中删除最旧的命令。
  1189. # You can configure the slow log with two parameters: one tells Redis
  1190. # what is the execution time, in microseconds, to exceed in order for the
  1191. # command to get logged, and the other parameter is the length of the
  1192. # slow log. When a new command is logged the oldest one is removed from the
  1193. # queue of logged commands.
  1194. #下面的时间以微秒表示,因此1000000相当于1秒。请注意,负数将禁用慢速日志,而零值将强制记录每个命令。
  1195. # The following time is expressed in microseconds, so 1000000 is equivalent
  1196. # to one second. Note that a negative number disables the slow log, while
  1197. # a value of zero forces the logging of every command.
  1198. slowlog-log-slower-than 10000
  1199. # 这个长度没有限制。只是要注意它会消耗内存。
  1200. # 您可以通过SLOWLOG RESET回收慢日志使用的内存。
  1201. # There is no limit to this length. Just be aware that it will consume memory.
  1202. # You can reclaim memory used by the slow log with SLOWLOG RESET.
  1203. slowlog-max-len 128
  1204. ################################ LATENCY MONITOR ##############################
  1205. # Redis延迟监控子系统在运行时对不同的操作进行采样,以便收集与Redis实例的可能延迟源相关的数据。
  1206. # The Redis latency monitoring subsystem samples different operations
  1207. # at runtime in order to collect data related to possible sources of
  1208. # latency of a Redis instance.
  1209. #
  1210. # 通过LATENCY命令,该信息可供可以打印图形和获取报告的用户使用。
  1211. # Via the LATENCY command this information is available to the user that can
  1212. # print graphs and obtain reports.
  1213. #
  1214. # 系统仅记录在等于或大于通过延迟监视器阈值配置指令指定的毫秒数的时间内执行的操作。
  1215. # 当其值设置为零时,延迟监视器将关闭。
  1216. # The system only logs operations that were performed in a time equal or
  1217. # greater than the amount of milliseconds specified via the
  1218. # latency-monitor-threshold configuration directive. When its value is set
  1219. # to zero, the latency monitor is turned off.
  1220. #
  1221. # 默认情况下,延迟监视是禁用的,因为如果没有延迟问题,通常不需要延迟监视,
  1222. # 并且收集数据会对性能产生影响,虽然影响很小,但可以在大负载下进行测量。
  1223. #如果需要,可以在运行时使用命令“CONFIG SET Latency monitor threshold<millishes>”轻松启用延迟监视
  1224. # By default latency monitoring is disabled since it is mostly not needed
  1225. # if you don't have latency issues, and collecting data has a performance
  1226. # impact, that while very small, can be measured under big load. Latency
  1227. # monitoring can easily be enabled at runtime using the command
  1228. # "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
  1229. latency-monitor-threshold 0
  1230. ############################# EVENT NOTIFICATION ##############################
  1231. # Redis可以将密钥空间中发生的事件通知Pub/Sub客户机。
  1232. # 此功能记录在http://redis.io/topics/notifications
  1233. # Redis can notify Pub/Sub clients about events happening in the key space.
  1234. # This feature is documented at http://redis.io/topics/notifications
  1235. #
  1236. # 例如,如果启用了keyspace events通知,并且客户端对存储在数据库0中的键“foo”执行DEL操作,
  1237. # 则将通过Pub/Sub发布两条消息:
  1238. # For instance if keyspace events notification is enabled, and a client
  1239. # performs a DEL operation on key "foo" stored in the Database 0, two
  1240. # messages will be published via Pub/Sub:
  1241. #
  1242. # PUBLISH __keyspace@0__:foo del
  1243. # PUBLISH __keyevent@0__:del foo
  1244. #
  1245. # 可以在一组类中选择Redis将通知的事件。每个类都由一个字符标识:
  1246. # It is possible to select the events that Redis will notify among a set
  1247. # of classes. Every class is identified by a single character:
  1248. #
  1249. # K Keyspace events, published with __keyspace@<db>__ prefix.
  1250. # E Keyevent events, published with __keyevent@<db>__ prefix.
  1251. # g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
  1252. # $ String commands
  1253. # l List commands
  1254. # s Set commands
  1255. # h Hash commands
  1256. # z Sorted set commands
  1257. # x Expired events (events generated every time a key expires)
  1258. # e Evicted events (events generated when a key is evicted for maxmemory)
  1259. # A Alias for g$lshzxe, so that the "AKE" string means all the events.
  1260. #
  1261. # “notify keyspace events”将由零个或多个字符组成的字符串作为参数。空字符串表示已禁用通知。
  1262. # The "notify-keyspace-events" takes as argument a string that is composed
  1263. # of zero or multiple characters. The empty string means that notifications
  1264. # are disabled.
  1265. #
  1266. # 示例:要启用列表和常规事件,请从事件名称的角度使用:
  1267. # Example: to enable list and generic events, from the point of view of the
  1268. # event name, use:
  1269. #
  1270. # notify-keyspace-events Elg
  1271. #
  1272. # 示例2:获取订阅频道名称的过期密钥流__keyevent@0__:过期使用:
  1273. # Example 2: to get the stream of the expired keys subscribing to channel
  1274. # name __keyevent@0__:expired use:
  1275. #
  1276. # notify-keyspace-events Ex
  1277. #
  1278. # 默认情况下,所有通知都被禁用,因为大多数用户不需要此功能,而且该功能有一些开销。
  1279. # 注意,如果您没有指定至少一个K或E,则不会传递任何事件。
  1280. # By default all notifications are disabled because most users don't need
  1281. # this feature and the feature has some overhead. Note that if you don't
  1282. # specify at least one of K or E, no events will be delivered.
  1283. notify-keyspace-events ""
  1284. ############################### ADVANCED CONFIG ###############################
  1285. # 哈希在具有少量条目时使用内存高效的数据结构进行编码,最大条目不超过给定的阈值。
  1286. # 这些阈值可以使用以下指令进行配置。
  1287. # Hashes are encoded using a memory efficient data structure when they have a
  1288. # small number of entries, and the biggest entry does not exceed a given
  1289. # threshold. These thresholds can be configured using the following directives.
  1290. hash-max-ziplist-entries 512
  1291. hash-max-ziplist-value 64
  1292. # 列表也以一种特殊的方式编码以节省大量空间。
  1293. # 每个内部列表节点允许的条目数可以指定为固定的最大大小或最大元素数。
  1294. # 对于固定的最大大小,使用-5到-1,意思是:
  1295. # Lists are also encoded in a special way to save a lot of space.
  1296. # The number of entries allowed per internal list node can be specified
  1297. # as a fixed maximum size or a maximum number of elements.
  1298. # For a fixed maximum size, use -5 through -1, meaning:
  1299. # -5: max size: 64 Kb <-- not recommended for normal workloads ## 不建议用于正常工作负载
  1300. # -4: max size: 32 Kb <-- not recommended ## 未推荐的
  1301. # -3: max size: 16 Kb <-- probably not recommended ## 可能不推荐
  1302. # -2: max size: 8 Kb <-- good
  1303. # -1: max size: 4 Kb <-- good
  1304. #
  1305. # 正数表示每个列表节点最多可存储的元素数。
  1306. # Positive numbers mean store up to _exactly_ that number of elements
  1307. # per list node.
  1308. #
  1309. # 最高性能的选项通常是-2(8KB大小)或-1(4KB大小),
  1310. # 但是如果您的用例是唯一的,则根据需要调整设置。
  1311. # The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
  1312. # but if your use case is unique, adjust the settings as necessary.
  1313. list-max-ziplist-size -2
  1314. # 列表也可以被压缩。
  1315. # Compress depth是要从压缩中*排除*的列表*每*侧的quicklist ziplist节点数。名单的头尾
  1316. # 对于快速的push/pop操作总是解压缩的。设置为:
  1317. # Lists may also be compressed.
  1318. # Compress depth is the number of quicklist ziplist nodes from *each* side of
  1319. # the list to *exclude* from compression. The head and tail of the list
  1320. # are always uncompressed for fast push/pop operations. Settings are:
  1321. # 0: disable all list compression ## 禁用所有列表压缩
  1322. #
  1323. # 深度1表示“在列表中的1个节点之后才开始压缩,从头部或尾部开始”
  1324. # 1: depth 1 means "don't start compressing until after 1 node into the list,
  1325. # going from either the head or tail"
  1326. # So: [head]->node->node->...->node->[tail]
  1327. # [head], [tail] will always be uncompressed; inner nodes will compress.
  1328. # 2: [head]->[next]->node->node->...->node->[prev]->[tail]
  1329. # 这里的意思是:不压缩head或head->next或tail->prev或tail,而是压缩它们之间的所有节点。
  1330. # 2 here means: don't compress head or head->next or tail->prev or tail,
  1331. # but compress all nodes between them.
  1332. # 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
  1333. # etc.
  1334. list-compress-depth 0
  1335. # 在一种情况下,集合有一种特殊的编码方式:当一个集合由恰好是基数10中的整数的字符串组成时,
  1336. # 这些字符串的范围是64位有符号整数。
  1337. # 以下配置设置设置集合大小的限制,以便使用此特殊的内存节省编码。
  1338. # Sets have a special encoding in just one case: when a set is composed
  1339. # of just strings that happen to be integers in radix 10 in the range
  1340. # of 64 bit signed integers.
  1341. # The following configuration setting sets the limit in the size of the
  1342. # set in order to use this special memory saving encoding.
  1343. set-max-intset-entries 512
  1344. # 与散列和列表类似,排序集也经过特殊编码以节省大量空间。
  1345. # 此编码仅在排序集的长度和元素低于以下限制时使用:
  1346. # Similarly to hashes and lists, sorted sets are also specially encoded in
  1347. # order to save a lot of space. This encoding is only used when the length and
  1348. # elements of a sorted set are below the following limits:
  1349. zset-max-ziplist-entries 128
  1350. zset-max-ziplist-value 64
  1351. # HyperLogLog稀疏表示字节数限制。限制包括16字节头。
  1352. # 当使用稀疏表示的超对数超过这个极限时,它将转换为稠密表示。
  1353. # HyperLogLog sparse representation bytes limit. The limit includes the
  1354. # 16 bytes header. When an HyperLogLog using the sparse representation crosses
  1355. # this limit, it is converted into the dense representation.
  1356. #
  1357. # 大于16000的值是完全无用的,因为在这一点上,密集表示更高效。
  1358. # A value greater than 16000 is totally useless, since at that point the
  1359. # dense representation is more memory efficient.
  1360. #
  1361. # 建议值为~3000,以便在不减慢太多PFADD的情况下具有节省空间的编码的优点,这对于稀疏编码是O(N)。
  1362. # 当CPU不是问题,但空间是问题,并且数据集由基数在0-15000范围内的许多超日志组成时,
  1363. # 该值可以提高到~10000。
  1364. # The suggested value is ~ 3000 in order to have the benefits of
  1365. # the space efficient encoding without slowing down too much PFADD,
  1366. # which is O(N) with the sparse encoding. The value can be raised to
  1367. # ~ 10000 when CPU is not a concern, but space is, and the data set is
  1368. # composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
  1369. hll-sparse-max-bytes 3000
  1370. # 活动重新灰化使用每100毫秒CPU时间1毫秒,以帮助重新设置主Redis哈希表(将顶级键映射到值的表)。
  1371. # 哈希表实现Redis使用(请参见dict.c)执行惰性重灰化:当您遇到正在重新灰化的哈希表中的操作越多,
  1372. # 执行的“步骤”就越多,因此如果服务器空闲,则重新灰化永远不会完成,哈希表将使用更多内存。
  1373. # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
  1374. # order to help rehashing the main Redis hash table (the one mapping top-level
  1375. # keys to values). The hash table implementation Redis uses (see dict.c)
  1376. # performs a lazy rehashing: the more operation you run into a hash table
  1377. # that is rehashing, the more rehashing "steps" are performed, so if the
  1378. # server is idle the rehashing is never complete and some more memory is used
  1379. # by the hash table.
  1380. #
  1381. # 默认情况下,每秒使用10次此毫秒,以便主动地重新刷新主词典,尽可能释放内存。
  1382. # The default is to use this millisecond 10 times every second in order to
  1383. # actively rehash the main dictionaries, freeing memory when possible.
  1384. #
  1385. # 如果不确定:
  1386. # 如果您有严格的延迟要求,那么使用“activerehashing no”,在您的环境中,
  1387. # Redis可以不时地以2毫秒的延迟回复查询并不是一件好事。
  1388. # If unsure:
  1389. # use "activerehashing no" if you have hard latency requirements and it is
  1390. # not a good thing in your environment that Redis can reply from time to time
  1391. # to queries with 2 milliseconds delay.
  1392. #
  1393. # 如果您没有这样的硬性要求,但希望尽快释放内存,请使用“activerehashing yes”。
  1394. # use "activerehashing yes" if you don't have such hard requirements but
  1395. # want to free memory asap when possible.
  1396. activerehashing yes
  1397. # 客户机输出缓冲区限制可用于强制断开由于某种原因从服务器读取数据速度不够快的客户机的连接
  1398. # (一个常见的原因是Pub/Sub客户机不能像发布服务器生成消息那样快地使用消息)。
  1399. # The client output buffer limits can be used to force disconnection of clients
  1400. # that are not reading data from the server fast enough for some reason (a
  1401. # common reason is that a Pub/Sub client can't consume messages as fast as the
  1402. # publisher can produce them).
  1403. #
  1404. # 对于三种不同类型的客户端,可以设置不同的限制:
  1405. # The limit can be set differently for the three different classes of clients:
  1406. #
  1407. # normal -> normal clients including MONITOR clients ## 普通客户端包括监控客户端
  1408. # slave -> slave clients ## 从属客户端
  1409. # pubsub -> clients subscribed to at least one pubsub channel or pattern
  1410. # ## 客户端订阅了至少一个子频道或模式
  1411. #
  1412. # 每个客户端输出缓冲区限制指令的语法如下:
  1413. # The syntax of every client-output-buffer-limit directive is the following:
  1414. #
  1415. # client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
  1416. #
  1417. # 一旦达到硬限制,或者如果达到软限制并保持达到指定秒数(连续),客户端将立即断开连接。
  1418. # A client is immediately disconnected once the hard limit is reached, or if
  1419. # the soft limit is reached and remains reached for the specified number of
  1420. # seconds (continuously).
  1421. #
  1422. # 因此,例如,如果硬限制为32兆字节,软限制为16兆字节/10秒,则如果输出缓冲区的大小达到32兆字节,
  1423. # 客户端将立即断开连接,但如果客户端达到16兆字节并连续克服限制10秒,客户端也将断开连接。
  1424. # So for instance if the hard limit is 32 megabytes and the soft limit is
  1425. # 16 megabytes / 10 seconds, the client will get disconnected immediately
  1426. # if the size of the output buffers reach 32 megabytes, but will also get
  1427. # disconnected if the client reaches 16 megabytes and continuously overcomes
  1428. # the limit for 10 seconds.
  1429. #
  1430. # 默认情况下,普通客户机不受限制,因为它们不会在没有请求(以推送方式)的情况下接收数据,
  1431. # 而是在请求之后接收数据,因此只有异步客户机可能会创建这样一种场景,
  1432. # 即请求数据的速度比读取数据的速度快。
  1433. # By default normal clients are not limited because they don't receive data
  1434. # without asking (in a push way), but just after a request, so only
  1435. # asynchronous clients may create a scenario where data is requested faster
  1436. # than it can read.
  1437. #
  1438. # 相反,对于pubsub和slave客户机有一个默认限制,因为订阅者和从属客户端以推送方式接收数据。
  1439. # Instead there is a default limit for pubsub and slave clients, since
  1440. # subscribers and slaves receive data in a push fashion.
  1441. #
  1442. # 硬限制或软限制都可以通过将其设置为零来禁用。
  1443. # Both the hard or the soft limit can be disabled by setting them to zero.
  1444. client-output-buffer-limit normal 0 0 0
  1445. client-output-buffer-limit slave 256mb 64mb 60
  1446. client-output-buffer-limit pubsub 32mb 8mb 60
  1447. # 客户端查询缓冲区积累新命令。默认情况下,它们被限制为固定数量,以避免协议取消同步
  1448. #(例如,由于客户端中的错误)将导致查询缓冲区中未绑定的内存使用。但是,如果您有非常特殊的需求,
  1449. # 比如我们的multi/exec请求或类似请求,您可以在这里配置它。
  1450. # Client query buffers accumulate new commands. They are limited to a fixed
  1451. # amount by default in order to avoid that a protocol desynchronization (for
  1452. # instance due to a bug in the client) will lead to unbound memory usage in
  1453. # the query buffer. However you can configure it here if you have very special
  1454. # needs, such us huge multi/exec requests or alike.
  1455. #
  1456. # client-query-buffer-limit 1gb
  1457. # 在Redis协议中,批量请求(即表示单个字符串的元素)通常限制在512MB。但是你可以在这里改变这个限制。
  1458. # In the Redis protocol, bulk requests, that are, elements representing single
  1459. # strings, are normally limited ot 512 mb. However you can change this limit
  1460. # here.
  1461. #
  1462. # proto-max-bulk-len 512mb
  1463. # Redis调用一个内部函数来执行许多后台任务,比如在超时时关闭客户端的连接,清除从未请求的过期密钥,
  1464. # 等等。
  1465. # Redis calls an internal function to perform many background tasks, like
  1466. # closing connections of clients in timeout, purging expired keys that are
  1467. # never requested, and so forth.
  1468. #
  1469. # 并非所有任务都以相同的频率执行,但是Redis会根据指定的“hz”值检查要执行的任务。
  1470. # Not all tasks are performed with the same frequency, but Redis checks for
  1471. # tasks to perform according to the specified "hz" value.
  1472. #
  1473. # 默认情况下“hz”设置为10。当Redis空闲时,提高该值将使用更多的CPU,
  1474. # 但同时会使Redis在多个键同时过期时更具响应性,超时处理可能会更精确。
  1475. # By default "hz" is set to 10. Raising the value will use more CPU when
  1476. # Redis is idle, but at the same time will make Redis more responsive when
  1477. # there are many keys expiring at the same time, and timeouts may be
  1478. # handled with more precision.
  1479. #
  1480. # 范围在1到500之间,但是值超过100通常不是一个好主意。大多数用户应该使用默认值10,
  1481. # 并且仅在需要非常低延迟的环境中才将其提高到100。
  1482. # The range is between 1 and 500, however a value over 100 is usually not
  1483. # a good idea. Most users should use the default of 10 and raise this up to
  1484. # 100 only in environments where very low latency is required.
  1485. hz 10
  1486. # 当子级重写AOF文件时,如果启用以下选项,则该文件将每生成32mb的数据进行一次fsync。
  1487. # 这对于以更增量的方式将文件提交到磁盘和避免较大的延迟峰值非常有用。
  1488. # When a child rewrites the AOF file, if the following option is enabled
  1489. # the file will be fsync-ed every 32 MB of data generated. This is useful
  1490. # in order to commit the file to the disk more incrementally and avoid
  1491. # big latency spikes.
  1492. aof-rewrite-incremental-fsync yes
  1493. # Redis LFU逐出(参见maxmemory设置)可以进行调优。但是,最好从默认设置开始,
  1494. # 在研究如何提高性能以及键LFU如何随时间变化后才进行更改,这可以通过OBJECT FREQ命令进行检查。
  1495. # Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
  1496. # idea to start with the default settings and only change them after investigating
  1497. # how to improve the performances and how the keys LFU change over time, which
  1498. # is possible to inspect via the OBJECT FREQ command.
  1499. #
  1500. # Redis LFU实现中有两个可调参数:计数器对数因子和计数器衰减时间。在改变这两个参数之前,
  1501. # 了解这两个参数的含义是很重要的。
  1502. # There are two tunable parameters in the Redis LFU implementation: the
  1503. # counter logarithm factor and the counter decay time. It is important to
  1504. # understand what the two parameters mean before changing them.
  1505. #
  1506. # LFU计数器每个键只有8位,它的最大值是255,所以Redis使用了对数行为的概率增量。
  1507. # 给定旧计数器的值,当访问键时,计数器按以下方式递增:
  1508. # The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis
  1509. # uses a probabilistic increment with logarithmic behavior. Given the value
  1510. # of the old counter, when a key is accessed, the counter is incremented in
  1511. # this way:
  1512. #
  1513. # 提取0到1之间的随机数R。
  1514. # 1. A random number R between 0 and 1 is extracted.
  1515. #
  1516. # 概率P的计算公式为1/(old_value*lfu_log_factor+1).
  1517. # 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1).
  1518. #
  1519. # 只有当R<P时,计数器才递增。
  1520. # 3. The counter is incremented only if R < P.
  1521. #
  1522. # 默认的lfu log factor是10。
  1523. # 这是一个关于频率计数器如何随着具有不同对数因子的不同访问次数而变化的表:
  1524. # The default lfu-log-factor is 10. This is a table of how the frequency
  1525. # counter changes with a different number of accesses with different
  1526. # logarithmic factors:
  1527. #
  1528. # +--------+------------+------------+------------+------------+------------+
  1529. # | factor | 100 hits | 1000 hits | 100K hits | 1M hits | 10M hits |
  1530. # +--------+------------+------------+------------+------------+------------+
  1531. # | 0 | 104 | 255 | 255 | 255 | 255 |
  1532. # +--------+------------+------------+------------+------------+------------+
  1533. # | 1 | 18 | 49 | 255 | 255 | 255 |
  1534. # +--------+------------+------------+------------+------------+------------+
  1535. # | 10 | 10 | 18 | 142 | 255 | 255 |
  1536. # +--------+------------+------------+------------+------------+------------+
  1537. # | 100 | 8 | 11 | 49 | 143 | 255 |
  1538. # +--------+------------+------------+------------+------------+------------+
  1539. #
  1540. # 注:上表是通过运行以下命令获得的:
  1541. # NOTE: The above table was obtained by running the following commands:
  1542. #
  1543. # redis-benchmark -n 1000000 incr foo
  1544. # redis-cli object freq foo
  1545. #
  1546. # 注2:计数器初始值为5,以便给新对象一个累积命中的机会。
  1547. # NOTE 2: The counter initial value is 5 in order to give new objects a chance
  1548. # to accumulate hits.
  1549. #
  1550. # #计数器衰减时间是键计数器除以2所必须经过的时间,单位为分钟(如果值小于等于10,则递减)。
  1551. # The counter decay time is the time, in minutes, that must elapse in order
  1552. # for the key counter to be divided by two (or decremented if it has a value
  1553. # less <= 10).
  1554. #
  1555. # lfu衰减时间的默认值为1。特殊值0意味着每次扫描计数器时都会衰减计数器。
  1556. # The default value for the lfu-decay-time is 1. A Special value of 0 means to
  1557. # decay the counter every time it happens to be scanned.
  1558. #
  1559. # lfu-log-factor 10
  1560. # lfu-decay-time 1
  1561. ########################### ACTIVE DEFRAGMENTATION #######################
  1562. #
  1563. # 警告:此功能是实验性的。然而,它甚至在生产中也进行了压力测试,
  1564. # 并由多名工程师进行了一段时间的手动测试。
  1565. # WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested
  1566. # even in production and manually tested by multiple engineers for some
  1567. # time.
  1568. #
  1569. # 什么是活动碎片整理?
  1570. # What is active defragmentation?
  1571. # -------------------------------
  1572. #
  1573. # 主动(在线)碎片整理允许Redis服务器压缩内存中数据的小分配和释放之间的空间,从而允许回收内存。
  1574. # Active (online) defragmentation allows a Redis server to compact the
  1575. # spaces left between small allocations and deallocations of data in memory,
  1576. # thus allowing to reclaim back memory.
  1577. #
  1578. # 碎片化是每个分配器(幸运的是Jemalloc)和某些工作负载都会发生的自然过程。
  1579. # 通常需要重新启动服务器以降低碎片,或者至少清除所有数据并重新创建。
  1580. # 不过,由于OranAgraforRedis4.0实现了这个特性,这个过程可以在服务器运行时以“热”的方式在运行时发生。
  1581. # Fragmentation is a natural process that happens with every allocator (but
  1582. # less so with Jemalloc, fortunately) and certain workloads. Normally a server
  1583. # restart is needed in order to lower the fragmentation, or at least to flush
  1584. # away all the data and create it again. However thanks to this feature
  1585. # implemented by Oran Agra for Redis 4.0 this process can happen at runtime
  1586. # in an "hot" way, while the server is running.
  1587. #
  1588. # 基本上,当碎片超过某个级别(见下面的配置选项)时,
  1589. # Redis将开始利用某些特定的Jemalloc特性在连续内存区域中创建值的新副本
  1590. # (以便了解分配是否导致碎片并将其分配到更好的位置),同时,将发布数据的旧拷贝。
  1591. # 这个过程,对所有键进行增量重复,将导致碎片降回正常值。
  1592. # Basically when the fragmentation is over a certain level (see the
  1593. # configuration options below) Redis will start to create new copies of the
  1594. # values in contiguous memory regions by exploiting certain specific Jemalloc
  1595. # features (in order to understand if an allocation is causing fragmentation
  1596. # and to allocate it in a better place), and at the same time, will release the
  1597. # old copies of the data. This process, repeated incrementally for all the keys
  1598. # will cause the fragmentation to drop back to normal values.
  1599. #
  1600. # 需要了解的重要事项:
  1601. # Important things to understand:
  1602. #
  1603. # 此功能在默认情况下是禁用的,
  1604. # 并且仅当您编译Redis以使用我们随Redis源代码提供的Jemalloc副本时才起作用。
  1605. # 这是Linux版本的默认设置。
  1606. # 1. This feature is disabled by default, and only works if you compiled Redis
  1607. # to use the copy of Jemalloc we ship with the source code of Redis.
  1608. # This is the default with Linux builds.
  1609. #
  1610. # 如果没有碎片问题,就不需要启用此功能
  1611. # 2. You never need to enable this feature if you don't have fragmentation
  1612. # issues.
  1613. #
  1614. # 一旦遇到碎片,可以在需要时使用命令“CONFIG SET activedefrag yes”启用此功能。
  1615. # 3. Once you experience fragmentation, you can enable this feature when
  1616. # needed with the command "CONFIG SET activedefrag yes".
  1617. #
  1618. # 配置参数能够微调碎片整理过程的行为。如果您不确定它们的含义,那么最好保持默认值不变。
  1619. # The configuration parameters are able to fine tune the behavior of the
  1620. # defragmentation process. If you are not sure about what they mean it is
  1621. # a good idea to leave the defaults untouched.
  1622. # 已启用活动碎片整理
  1623. # Enabled active defragmentation
  1624. # activedefrag yes
  1625. # 启动活动碎片整理的最小碎片浪费量
  1626. # Minimum amount of fragmentation waste to start active defrag
  1627. # active-defrag-ignore-bytes 100mb
  1628. # 启动活动碎片整理的最小碎片百分比
  1629. # Minimum percentage of fragmentation to start active defrag
  1630. # active-defrag-threshold-lower 10
  1631. # 使用最大努力的最大碎片百分比
  1632. # Maximum percentage of fragmentation at which we use maximum effort
  1633. # active-defrag-threshold-upper 100
  1634. # 以CPU百分比表示的最小碎片整理工作量
  1635. # Minimal effort for defrag in CPU percentage
  1636. # active-defrag-cycle-min 25
  1637. # 以CPU百分比表示的碎片整理最大工作量
  1638. # Maximal effort for defrag in CPU percentage
  1639. # active-defrag-cycle-max 75
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/591341
推荐阅读
相关标签
  

闽ICP备14008679号