以最小停机时间将因果集群复制到新硬件的方法
如果出现需要将现有的Causal Cluster复制到新硬件环境的情况,以下方法可用于实现最小停机时间。
让我们首先从一个已有的包含 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" | [] |
+---------------------------------------------------------------------------------------------------------------------------------------------+
每个实例都在其 conf/neo4j.conf 中定义了 /docs/operations-manual/current/reference/configuration-settings/#config_causal_clustering.expected_core_cluster_size 和 causal_clustering.initial_discovery_members,具体如下
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,执行以下步骤
-
在 IP 地址 10.2.2.1、10.2.2.2 和 10.2.2.3 上安装并创建新的 3 实例集群。
-
在这 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 -
启动位于 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" | [] | +---------------------------------------------------------------------------------------------------------------------------------------------+
-
一旦这 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" | [] | +---------------------------------------------------------------------------------------------------------------------------------------------+
-
如果在 3 实例集群(10.1.1.1、10.1.1.2 和 10.1.1.3)前面有负载均衡器,则需要将其更新为指向 10.2.2.1、10.2.2.2 和 10.2.2.3。
-
由于原始的 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 -
如果您当前使用 Bolt 驱动程序连接到集群,则需要将连接字符串更新为指向新的 URL,例如将
bolt+routing://10.1.1.1:7678改为bolt+routing://10.2.2.1:7678。
此页面有帮助吗?