如何缩小CrateDB集群?

时间:2016-12-08 15:25:54

标签: sql database crate

为了进行测试,我想将我的3节点集群缩减为2个节点,以后再为我的5节点集群做同样的事情。

然而,在遵循缩小群集的最佳做法之后:

  
      
  1. 备份所有表格
  2.   
  3. 对于所有表格:alter table xyz set (number_of_replicas=2)如果
  4. 之前小于2   
  5. SET GLOBAL PERSISTENT discovery.zen.minimum_master_nodes = <half of the cluster + 1>;
      3 a。如果数据检查应始终为绿色,请将min_availability设置为“完全”&#39;:   https://crate.io/docs/reference/configuration.html#graceful-stop
  6.   
  7. 在一个节点上启动正常停止
  8.   
  9. 等待数据检查变为绿色
  10.   
  11. 从3开始重复。
  12.   
  13. 完成后,在crate.yml中保留节点配置:    gateway.recover_after_nodes: n discovery.zen.minimum_master_nodes:[![enter image description here][1]][1] (n/2) +1 gateway.expected_nodes: n
  14.   

我的群集从未回到&#34;绿色&#34;再次,我也有一个关键节点检查失败。

这里出了什么问题?

crate.yml:

  ... 
  ################################## Discovery ##################################

  # Discovery infrastructure ensures nodes can be found within a cluster
  # and master node is elected. Multicast discovery is the default.

  # Set to ensure a node sees M other master eligible nodes to be considered
  # operational within the cluster. Its recommended to set it to a higher value
  # than 1 when running more than 2 nodes in the cluster.
  #
  # We highly recommend to set the minimum master nodes as follows:
  #   minimum_master_nodes: (N / 2) + 1 where N is the cluster size
  # That will ensure a full recovery of the cluster state.
  #
  discovery.zen.minimum_master_nodes: 2

  # Set the time to wait for ping responses from other nodes when discovering.
  # Set this option to a higher value on a slow or congested network
  # to minimize discovery failures:
  #
  # discovery.zen.ping.timeout: 3s
  #

  # Time a node is waiting for responses from other nodes to a published
  # cluster state.
  #
  # discovery.zen.publish_timeout: 30s

  # Unicast discovery allows to explicitly control which nodes will be used
  # to discover the cluster. It can be used when multicast is not present,
  # or to restrict the cluster communication-wise.
  # For example, Amazon Web Services doesn't support multicast discovery.
  # Therefore, you need to specify the instances you want to connect to a
  # cluster as described in the following steps:
  #
  # 1. Disable multicast discovery (enabled by default):
  #
  discovery.zen.ping.multicast.enabled: false
  #
  # 2. Configure an initial list of master nodes in the cluster
  #    to perform discovery when new nodes (master or data) are started:
  #
  # If you want to debug the discovery process, you can set a logger in
  # 'config/logging.yml' to help you doing so.
  #
  ################################### Gateway ###################################

  # The gateway persists cluster meta data on disk every time the meta data
  # changes. This data is stored persistently across full cluster restarts
  # and recovered after nodes are started again.

  # Defines the number of nodes that need to be started before any cluster
  # state recovery will start.
  #
  gateway.recover_after_nodes: 3

  # Defines the time to wait before starting the recovery once the number
  # of nodes defined in gateway.recover_after_nodes are started.
  #
  #gateway.recover_after_time: 5m

  # Defines how many nodes should be waited for until the cluster state is
  # recovered immediately. The value should be equal to the number of nodes
  # in the cluster.
  #
  gateway.expected_nodes: 3

1 个答案:

答案 0 :(得分:1)

所以有两件事是重要的:

  • 副本的数量本质上是您在典型设置中可以丢失的节点数量(建议使用2个,以便您可以在此过程中缩小和松散节点,并且仍然可以正常运行)
  • 推荐用于群集的程序&gt; 2个节点;)

CrateDB将以不使副本和主节点共享节点的方式自动在群集中分发分片。如果不可能(如果您有2个节点和1个主要有2个副本的情况,则数据检查将永远不会返回到&#39;绿色&#39;。因此,在您的情况下,将副本数设置为1为了使群集恢复绿色(alter table mytable set (number_of_replicas = 1))。

关键节点检查是由于集群尚未收到更新的crate.yml:您的文件仍然具有3节点集群的配置,因此消息。由于CrateDB仅在启动时加载expected_nodes(它是not a runtime setting),因此需要重新启动整个集群才能完成按比例缩小。可以通过滚动重启完成,但一定要正确设置SET GLOBAL PERSISTENT discovery.zen.minimum_master_nodes = <half of the cluster + 1>;,否则协商一致将不起作用......

此外,建议逐个缩小,以避免因重新平衡和意外丢失数据而导致群集过载。