美文网首页
REDIS----配置文件----REDIS CLUSTER

REDIS----配置文件----REDIS CLUSTER

作者: JuMinggniMuJ | 来源:发表于2020-06-06 20:27 被阅读0次

    REDIS CLUSTER部分:

    1.是否开启集群:
    # 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实例不能是Redis集群的一部分;只有作为集群节点启动的节点才可以。为了将Redis实例作为群集节点启动,请启用群集支持取消注释以下内容:

    2.集群配置文件:
    # 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-config-file nodes-6379.conf
    

    每个群集节点都有一个群集配置文件。此文件不打算手动编辑。它由Redis节点创建和更新。每个Redis集群节点都需要不同的集群配置文件。请确保在同一系统中运行的实例没有重叠的群集配置文件名。

    3.集群节点超时时间:
    # Cluster node timeout is the amount of milliseconds a node must be unreachable
    # for it to be considered in failure state.
    # Most other internal time limits are multiple of the node timeout.
    cluster-node-timeout 15000
    

    Cluster node timeout是节点在故障状态下必须不可访问的毫秒数。大多数其他内部时间限制是节点超时的倍数。

    4.群集副本有效因子:
    # A replica of a failing master will avoid to start a failover if its data
    # looks too old.
    # There is no simple way for a replica to actually have an exact measure of
    # its "data age", so the following two checks are performed:
    # 1) If there are multiple replicas able to failover, they exchange messages
    #    in order to try to give an advantage to the replica with the best
    #    replication offset (more data from the master processed).
    #    Replicas will try to get their rank by offset, and apply to the start
    #    of the failover a delay proportional to their rank.
    # 2) Every single replica computes the time of the last interaction with
    #    its master. This can be the last ping or command received (if the master
    #    is still in the "connected" state), or the time that elapsed since the
    #    disconnection with the master (if the replication link is currently down).
    #    If the last interaction is too old, the replica will not try to failover
    #    at all.
    # The point "2" can be tuned by user. Specifically a replica will not perform
    # the failover if, since the last interaction with the master, the time
    # elapsed is greater than:
    #   (node-timeout * 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.
    # 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.
    # 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).
    # Zero is the only value able to guarantee that when all the partitions heal
    # the cluster will always be able to continue.
     cluster-replica-validity-factor 10
    

    如果发生故障的主服务器的数据看起来太旧,则其副本将避免启动故障转移。
    对于副本来说,没有一种简单的方法可以精确测量其“数据期限”,因此执行以下两项检查:
    1.如果有多个副本能够进行故障切换,则它们会交换消息,以便尝试利用具有最佳复制偏移量的副本(来自已处理主服务器的更多数据)。副本将尝试按偏移量获取其列组,并在故障转移开始时应用与其列组成比例的延迟。
    2.每个副本都计算最后一次与其主副本交互的时间。这可以是最后收到的ping或命令(如果主服务器仍处于“已连接”状态),也可以是自与主服务器断开连接以来经过的时间(如果复制链接当前已关闭)。如果上一次交互太旧,则复制副本根本不会尝试故障转移。
    点“2”可以由用户调整。特别是,如果自上次与主服务器交互以来,经过的时间大于:
    (节点超时时间乘以集群副本有效因子)+ping周期
    因此,例如,如果节点超时时间为30秒,副本有效性系数为10,并且假设默认的repl ping副本周期为10秒,则如果副本无法与主副本通信超过310秒,则副本将不会尝试故障转移。
    较大的复制副本有效性因子可能允许具有太旧数据的复制副本故障转移主服务器,而太小的值可能会阻止群集完全选择复制副本。
    为了获得最大的可用性,可以将副本有效性因子设置为0,这意味着,无论副本上次与主副本交互的时间如何,副本都将始终尝试故障转移主副本。(然而,他们总是试图应用一个与其偏移秩成比例的延迟)。
    零是唯一能够保证当所有分区运行状况群集将始终能够继续的值

    5.集群迁移障碍:
    # Replicas migrate to orphaned masters only if there are still at least a
    # given number of other working replicas for their old master. This number
    # is the "migration barrier". A migration barrier of 1 means that a replica
    # will migrate only if there is at least 1 other working replica for its master
    # and so forth. It usually reflects the number of replicas you want for every
    # master in your cluster.
    # Default is 1 (replicas migrate only if their masters remain with at least
    # one replica). To disable migration just set it to a very large value.
    # A value of 0 can be set but is useful only for debugging and dangerous
    # in production.
    cluster-migration-barrier 1
    

    只有当旧主服务器仍有至少给定数量的其他工作副本时,副本才会迁移到孤立主服务器。这个数字就是“移民壁垒”。迁移屏障为1意味着只有当主副本至少有一个其他工作副本时,副本才会迁移,以此类推。它通常反映集群中每个主节点所需的副本数量。
    默认值为1(副本仅在其主副本至少保留一个副本时迁移)。要禁用迁移,只需将其设置为一个非常大的值。可以设置值0,但该值仅用于调试和生产中的危险。

    6.集群需要全覆盖:
    # By default Redis Cluster nodes stop accepting queries if they detect there
    # is at least an hash slot uncovered (no available node is serving it).
    # This way if the cluster is partially down (for example a range of hash slots
    # are no longer covered) all the cluster becomes, eventually, unavailable.
    # It automatically returns available as soon as all the slots are covered again.
    #
    # However sometimes you want the subset of the cluster which is working,
    # to continue to accept queries for the part of the key space that is still
    # covered. In order to do so, just set the cluster-require-full-coverage
    # option to no.
    cluster-require-full-coverage yes
    

    默认情况下,如果Redis集群节点检测到至少有一个未覆盖的哈希槽(没有可用的节点为其提供服务),那么它们将停止接受查询。这样,如果集群部分关闭(例如不再覆盖一系列散列槽),那么所有集群最终都将不可用。一旦所有插槽都被覆盖,它就会自动返回可用。
    但是,有时您希望正在工作的集群的子集继续接受对仍然覆盖的部分密钥空间的查询。为此,只需将cluster require full coverage选项设置为no。

    7.群集副本无故障转移:
    # This option, when set to yes, prevents replicas from trying to failover its
    # master during master failures. However the master can still perform a
    # manual failover, if forced to do so.
    #
    # This is useful in different scenarios, especially in the case of multiple
    # data center operations, where we want one side to never be promoted if not
    # in the case of a total DC failure.
     cluster-replica-no-failover no
    

    当设置为“是”时,此选项可防止复制副本在主服务器故障期间尝试故障转移其主服务器。但是,如果强制执行手动故障转移,主服务器仍然可以执行手动故障转移。
    这在不同的情况下非常有用,特别是在多个数据中心操作的情况下,如果在整个DC故障的情况下不希望一方被提升,我们希望它永远不会被提升。

    相关文章

      网友评论

          本文标题:REDIS----配置文件----REDIS CLUSTER

          本文链接:https://www.haomeiwen.com/subject/ltsftktx.html