Percona Cluster - 主节点失败,如何进行

Percona Cluster - Master node failed, how to proceed

我有一个 5 节点的 Percona Galera Mysql 集群。

真正的主节点和一个从节点死了(服务器关闭),我假设,现在其中一个从节点是主节点,我检查了它们的状态(网站关闭)并且它们都同步并且没有改变,我想开始备份主节点并重新获得其 "master-ish" 状态并获取更新后的数据,这些数据已经存在了几个小时。

这是一个活跃的高事务数据库,因此数据 100% 重要。

我可以正常启动master,还是should/could我从更新的slave上复制数据粘贴到master上? (我知道所有东西在哪里)。

最好的做法是什么?

这里有一些来自 MariaDB 的东西

MariaDB Galera Cluster is a synchronous multi-master cluster for MariaDB. It is available on Linux only, and only supports the XtraDB/InnoDB storage engines (although there is experimental support for MyISAM - see the wsrep_replicate_myisam system variable).

Starting with MariaDB 10.1, the wsrep API for Galera Cluster is included by default. This is available as a separate download for MariaDB 10.0 and MariaDB 5.5

特点

  • Synchronous replication
  • Active-active multi-master topology
  • Read and write to any cluster node
  • Automatic membership control, failed nodes drop from the cluster
  • Automatic node joining
  • True parallel replication, on row level
  • Direct client connections, native MariaDB

外观优势

上述功能为

带来了几个好处

DBMS clustering solution, including:

  • No slave lag
  • No lost transactions
  • Both read and write scalability
  • Smaller client latencies

它与 MaxScale 数据库代理完美配合。

这里还有来自 FromDual 的概述,它不是最新的,但你可以看到 Galera 的作品非常好。

https://www.fromdual.com/sites/default/files/galera_fromdual_cm_2013.pdf

鉴于您有 5 个节点集群和 2 个节点死亡,您仍然有法定人数,这意味着您的集群仍然处于活动状态并且可以为查询服务。 所有节点都应该同步,这样您就可以将任何活动节点设为主节点,并重新启动失败的节点。 (没有 master 的概念,但上面的 master 意味着你可以让你的应用程序指向它作为主节点)。

如果活动节点(集群)上的 activity 不多,那么失败的节点将执行 IST 来赶上进度。如果 activity 太多,这意味着写集在活动节点 gcache 中不再可用,那么 SST 将完成。

一个可以把加莱拉当作主人+N-1个奴隶。但是,如果指定的 Master 死亡,您将失去一些正常运行时间——正如您发现的那样。使用这样的配置有一些 'valid' 原因,但将所有节点都视为读写是正常的,在这种情况下,一个节点的死亡几乎不会被注意到。

如果您可以简单地重启死掉的主机,它将与其他节点通信,并可能执行快速 IST 来修复数据。

如果你必须用一个新的盒子来代替死掉的Master,那么就需要一个SST来加载数据。那是自动的;你什么都不做(或几乎什么都不做)。由于 SST 花费的时间与数据量成正比,因此这可能需要很长时间。 你不应该自己复制数据。

如果您有计划在主节点死后将写入路由到另一个节点,那就更好了。这可能会导致对整个系统的干扰最少。

另一种选择是更改节点的IP地址,以欺骗客户端以为它是旧Master。

还有一个想法是在5个节点前使用Proxy(MaxScale、HAProxy等),重新配置建立新的Master节点。