From 80c94e176ba540cabd46c2f5030cdf67f833778c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=82=8E=E6=B3=BC?= Date: Tue, 12 Dec 2023 18:56:25 +0800 Subject: [PATCH] Doc: faq: how to initalize a cluster --- openraft/src/docs/faq/faq.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openraft/src/docs/faq/faq.md b/openraft/src/docs/faq/faq.md index eff370d9e..1e38e828b 100644 --- a/openraft/src/docs/faq/faq.md +++ b/openraft/src/docs/faq/faq.md @@ -17,11 +17,14 @@ This way in every term there could be more than one leaders elected, and the las See: [`leader-id`](`crate::docs::data::leader_id`) for details. -### If I start a node and set it as leader, will there be any problems if the node keeps running? +### How to initialize a cluster? -No problem at all. +There are two ways to initialize a raft cluster, assuming there are three nodes, `n1, n2, n3`: -It's quite typical to initiate a cluster with a single node for testing purposes. +1. Single-step method: Call `Raft::initialize()` on any one of the nodes with the configuration of all 3 nodes, e.g. `n2.initialize(btreeset! {1,2,3})`. +2. Incremental method: First, call `Raft::initialize()` on `n1` with configuraion containing `n1` itself, e.g., `n0.initialize(btreeset! {1})`. Subsequently use `Raft::change_membership()` on `n1` to add `n2` and `n3` into the cluster. + +Employing the second method provides the flexibility to start with a single-node cluster for testing purposes and subsequently expand it to a three-node cluster for deployment in a production environment. ### Are there any issues with running a single node service?