知识库

将因果集群复制到新硬件上的方法,最小化停机时间

如果出现需要将现有 因果集群 复制到新硬件设置的情况,可以使用以下方法来最小化停机时间。

首先让我们从一个具有以下特征的现有 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