知识库

一种以最短停机时间将因果集群复制到新硬件的方法

如果您需要将现有因果集群复制到新的硬件设置,可以使用以下方法将停机时间降至最低。

我们首先从一个具有以下特征的现有 3 实例集群开始:

neo4j> call dbms.cluster.overview
+---------------------------------------------------------------------------------------------------------------------------------------------+
| id                                     | addresses                                                                    | role       | groups |
+---------------------------------------------------------------------------------------------------------------------------------------------+
| "ffc16977-4ab8-41b5-a4e2-e0e32e8abd6f" | ["bolt://10.1.1.1:7617", "http://10.1.1.1:7474", "https://10.1.1.1:7473"] | "LEADER"   | []     |
| "f0a78cd1-7ba3-45f6-aba3-0abb60d785ef" | ["bolt://10.1.1.2:7627", "http://10.1.1.2:7474", "https://10.1.1.2:7473"] | "FOLLOWER" | []     |
| "2fe26571-6fcc-4d1e-9f42-b81d08579057" | ["bolt://10.1.1.3:7637", "http://10.1.1.3:7474", "https://10.1.1.3:7473"] | "FOLLOWER" | []     |
+---------------------------------------------------------------------------------------------------------------------------------------------+
causal_clustering.expected_core_cluster_size=3
causal_clustering.initial_discovery_members=10.1.1.1:5001,10.1.1.2:5002,10.1.1.3:5003

所有其他引用的端口都使用默认值。

要添加 3 个新实例,例如 IP 地址为 10.2.2.1、10.2.2.2 和 10.2.2.3,请执行以下步骤:

  1. 在 IP 地址 10.2.2.1、10.2.2.2 和 10.2.2.3 上安装并创建新的 3 实例集群。

  2. 在这些 3 个新实例的每个conf/neo4j.conf中,将其ha.initial_hosts定义为:

    causal_clustering.initial_discovery_members=10.1.1.1:5001,10.1.1.2:5001,10.1.1.3:5001
  3. 启动 10.2.2.1、10.2.2.2 和 10.2.2.3 上的每个实例。这 3 个新实例将随后加入 10.1.1.1、10.1.1.2 和 10.1.1.3 上的初始集群,并复制databases\graph.db。运行dbms.cluster.overview();将返回类似于以下内容的输出:

    +---------------------------------------------------------------------------------------------------------------------------------------------+
    | id                                     | addresses                                                                    | role       | groups |
    +---------------------------------------------------------------------------------------------------------------------------------------------+
    | "ffc16977-4ab8-41b5-a4e2-e0e32e8abd6f" | ["bolt://10.1.1.1:7687", "http://10.1.1.1:7474", "https://10.1.1.1:7473"] | "LEADER"   | []     |
    | "f0a78cd1-7ba3-45f6-aba3-0abb60d785ef" | ["bolt://10.1.1.2:7687", "http://10.1.1.2:7474", "https://10.1.1.2:7473"] | "FOLLOWER" | []     |
    | "2fe26571-6fcc-4d1e-9f42-b81d08579057" | ["bolt://10.1.1.3:7687", "http://10.1.1.3:7474", "https://10.1.1.3:7473"] | "FOLLOWER" | []     |
    | "847b74c2-34a9-4458-b0e2-ea36cf25fdbf" | ["bolt://10.2.2.1:7687", "http://10.2.2.1:7474", "https://10.2.2.1:7473"] | "FOLLOWER" | []     |
    | "39f92686-f581-4454-b288-a2254d38ea5c" | ["bolt://10.2.2.2:7687", "http://10.2.2.2:7474", "https://10.2.2.2:7473"] | "FOLLOWER" | []     |
    | "e4114ad2-dcd1-4d22-8f56-a085524c9ed0" | ["bolt://10.2.2.2:7687", "http://10.2.2.3:7474", "https://10.2.2.3:7473"] | "FOLLOWER" | []     |
    +---------------------------------------------------------------------------------------------------------------------------------------------+
  4. 一旦 3 个新实例完成了从主节点复制 graph.db 的操作,您就可以通过bin/neo4j stop干净地停止 10.1.1.1、10.1.1.2 和 10.1.1.3 上的 3 个初始实例。剩余的 3 个实例将继续运行。

    +---------------------------------------------------------------------------------------------------------------------------------------------+
    | id                                     | addresses                                                                    | role       | groups |
    +---------------------------------------------------------------------------------------------------------------------------------------------+
    | "847b74c2-34a9-4458-b0e2-ea36cf25fdbf" | ["bolt://10.2.2.1:7687", "http://10.2.2.1:7474", "https://10.2.2.1:7473"] | "LEADER"   | []     |
    | "39f92686-f581-4454-b288-a2254d38ea5c" | ["bolt://10.2.2.2:7687", "http://10.2.2.2:7474", "https://10.2.2.2:7473"] | "FOLLOWER" | []     |
    | "e4114ad2-dcd1-4d22-8f56-a085524c9ed0" | ["bolt://10.2.2.2:7687", "http://10.2.2.3:7474", "https://10.2.2.3:7473"] | "FOLLOWER" | []     |
    +---------------------------------------------------------------------------------------------------------------------------------------------+
  5. 如果负载均衡器位于 10.1.1.1、10.1.1.2 和 10.1.1.3 的 3 实例集群之前,则应更新它以指向 10.2.2.1、10.2.2.2 和 10.2.2.3。

  6. 由于初始的 3 个实例已经关闭,为了让新的 3 个实例稍后能够成功重启,请更新新的 3 个实例的 causal_clustering.initial_discovery_members 并将

    causal_clustering.initial_discovery_members=10.1.1.1:5001,10.1.1.2:5001,10.1.1.3:5001

    更改为

    causal_clustering.initial_discovery_members=10.2.2.1:5001,10.2.2.2:5001,10.2.2.3:5001
  7. 如果您当前使用 Bolt 驱动程序连接到集群,则需要更新连接字符串以引用新的 URL,例如将bolt+routing://10.1.1.1:7678更改为bolt+routing://10.2.2.1:7678

© . All rights reserved.