Skip to content

Commit

Permalink
Doc: faq: how to initalize a cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Dec 12, 2023
1 parent 79cedd4 commit 80c94e1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions openraft/src/docs/faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 80c94e1

Please sign in to comment.