Redis5.0.3配置文件详解(易读白话翻译)Lua与Cluster
################################ LUA SCRIPTING LUA脚本 ################################ LUA脚本我没有研究过,简单说下这个配置项是设置LUA脚本最大执行时间
# 另外LUA脚本执行是原子的,因此可以用它做一些特殊的实现,不过就像Oracle的存储过程一样,维护不方便,比较这个脚本语言会的人太少了
# 如果确实有需要,在考虑运维的情况下可以使用它来实现原子性等操作,慎用
# Max execution time of a Lua script in milliseconds.
#
# If the maximum execution time is reached Redis will log that a script is
# still in execution after the maximum allowed time and will start to
# reply to queries with an error.
#
# When a long running script exceeds the maximum execution time only the
# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
# used to stop a script that did not yet called write commands. The second
# is the only way to shut down the server in the case a write command was
# already issued by the script but the user doesn"t want to wait for the natural
# termination of the script.
#
# Set it to 0 or a negative value for unlimited execution without warnings.
# 如果设置为0或者负值,表示不限制执行时间
lua-time-limit 5000
################################ REDIS CLUSTER 集群 ###############################
# 在看下面的内容之前建议先去百度一下redis hash slots,以及集群的架构图
#
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 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被认为是稳定的,但是依然需要大量的用户在生产环境中使用它。。。这段注释应该从redis.conf中删除了,全世界已经有知名的大企业使用了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:
# 将"cluster-enabled"设置为yes,redis instance才能成为集群的一部分,但集群要真正开始工作,还需要将
# 所有的slots分配给cluster node
#
# cluster-enabled yes
# Every cluster node has a cluster configuration file. This file is not
# intended to be edited by hand. It is created and updated by Redis nodes.
# Every Redis Cluster node requires a different cluster configuration file.
# Make sure that instances running in the same system do not have
# overlapping cluster configuration file names.
# 每个cluster node有自己的cluster configuration file,且该配置文件不能手工编辑,而是自动创建和更新的
# cluster configuration file不能重名
#
# 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"规定的超时时间内,如果不可达,则被认为是失败状态
# 注意:集群内的大多数其他内部时间限制是"cluster-node-timeout"的倍数
#
# cluster-node-timeout 15000
# A replica of a failing master will avoid to start a failover if its data
# looks too old.
# 如果一个掉线主节点的从节点数据太老了,是不允许参与故障转移的
#
# There is no simple way for a replica to actually have an exact measure of
# its "data age", so the following two checks are performed:
# 没得撒子简单的办法可以一下计算出数据的年龄,因此Redis提供下面的两点来校验数据年龄,以决定集群节点是否参与故障转移过程:
#
# 1) If there are multiple replicas able to failover, they exchange messages
# in order to try to give an advantage to the replica with the best
# replication offset (more data from the master processed).
# Replicas will try to get their rank by offset, and apply to the start
# of the failover a delay proportional to their rank.
# 根据从节点的偏移量(主从复制-复制挤压缓冲区里面的偏移量,这个偏移量会跟着命令发给从节点,并保存下来)谁是最新的,并且根据偏移量排序,根据这个排序结果将从节点作为候选主节点
#
# 2) Every single replica computes the time of the last interaction with
# its master. This can be the last ping or command received (if the master
# is still in the "connected" state), or the time that elapsed since the
# disconnection with the master (if the replication link is currently down).
# If the last interaction is too old, the replica will not try to failover
# at all.
# 每个从节点都会计算它与主节点最后一次交互时间,比如最后一次ping时间、最后一次接收命令时间、与主节点断开连接过去的时长
# 如果最后一次交互时间太长,那么这个从节点也不会参与故障转移过程
#
# The point "2" can be tuned by user. Specifically a replica will not perform
# the failover if, since the last interaction with the master, the time
# elapsed is greater than:
# 前面讲到的第2点有一个计算公式来衡量"最后一次交互时间"是否太长
#
# (node-timeout * replica-validity-factor) + repl-ping-replica-period
#
# So for example if node-timeout is 30 seconds, and the replica-validity-factor
# is 10, and assuming a default repl-ping-replica-period of 10 seconds, the
# replica will not try to failover if it was not able to talk with the master
# for longer than 310 seconds.
# 假设"cluster-node-timeout"是30S,"replica-validity-factor"是10,"repl-ping-replica-period"是10S
# 如果"最后一次交互"时间超过"30*10+10=310"就被认为太长,而不能参与故障转移
#
# A large replica-validity-factor may allow replicas with too old data to failover
# a master, while a too small value may prevent the cluster from being able to
# elect a replica at all.
# "replica-validity-factor"太大,从节点数据可能会太久,如果太小可能选举不成功,集群不可用,所以要根据实际情况设置
#
# For maximum availability, it is possible to set the replica-validity-factor
# to a value of 0, which means, that replicas will always try to failover the
# master regardless of the last time they interacted with the master.
# (However they"ll always try to apply a delay proportional to their
# offset rank).
# 如果为了保证最大的可用性,可以将"cluster-replica-validity-factor"设置为0。此时所有的从节点考虑最后一次交互时间的大小,总是会参与故障转移过程
#
# Zero is the only value able to guarantee that when all the partitions heal
# the cluster will always be able to continue.
# "cluster-replica-validity-factor"的"0"是唯一可以让集群总是可用的选项值
#
# cluster-replica-validity-factor 10
# Cluster replicas are able to migrate to orphaned masters, that are masters
# that are left without working replicas. This improves the cluster ability
# to resist to failures as otherwise an orphaned master can"t be failed over
# in case of failure if it has no working replicas.
# 再不看下面的配置项功能时,有可能集群从节点会变成一个孤立的从节点,针对这种情况,如果它再发生故障,因为没有备选的从节点,所以故障转移动作没法完成。
#
# Replicas migrate to orphaned masters only if there are still at least a
# given number of other working replicas for their old master. This number
# is the "migration barrier". A migration barrier of 1 means that a replica
# will migrate only if there is at least 1 other working replica for its master
# and so forth. It usually reflects the number of replicas you want for every
# master in your cluster.
# 为了避免上面的情况发生,Redis Cluster默认配置要求一个主节点至少有两个从节点,一旦主节点挂了被新选举出来的主节点至少有一个从节点在工作。"cluster-migration-barrier"可以指定该值的大小,默认值是"1"
#
# Default is 1 (replicas migrate only if their masters remain with at least
# one replica). To disable migration just set it to a very large value.
# A value of 0 can be set but is useful only for debugging and dangerous
# in production.
# 默认值是1,如果要想禁止"migration",可以将"cluster-migration-barrier"设置为一个超大的值
# 可以为了调试或者你想让自己的系统存在高风险的运行,可以设置为0。。。no zuo no die
#
# 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 Cluster默认情况下如果有一个hash slot没有被分配(用一个Cluster Node接收它),那么整个集群是不可用的
# 在这种模式下,一旦出现网络分区(一段hash slots 就变成未分配),整个集群就不可用了,直到所有hash slots被分配,集群会自动变得可用
#
# 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.
# 也许有时你想即使出现hash slots unconverd,而集群的部分节点仍然是可用的,可以将"cluster-require-full-coverage"设置为no
#
# cluster-require-full-coverage yes
# This option, when set to yes, prevents replicas from trying to failover its
# master during master failures. However the master can still perform a
# manual failover, if forced to do so.
# 如果将"cluster-replica-no-failover"设置为yes,那么该集群从节点不会参与自动故障转移过程,但是可以手动强制执行故障转移
#
# 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.
# 在不同场景可能非常有用,比如有多个数据中心,而我们又不希望整个集群中的某一个数据中心的从节点被提升为主节点
#
# cluster-replica-no-failover no
# In order to setup your cluster make sure to read the documentation
# available at http://redis.io web site.
以上是 Redis5.0.3配置文件详解(易读白话翻译)Lua与Cluster 的全部内容, 来源链接: utcz.com/z/513253.html