How can I start a member as a read-only member?
Hi @greensky00 , Thank you for your great job! I found that all members start as a leader. I have 4 members (s0, s1, s2, s3), and I want only s0, s1 and s2 to participate in voting. How can I avoid s3 becoming a leader?
Hi @ZTJiu
In srv_config, there is a boolean flag indicating whether it is a learner:
https://github.com/eBay/NuRaft/blob/498cc30fb1e15fa4d1901821e9231a0727bfedfb/include/libnuraft/srv_config.hxx#L108-L112
You can make the flag true, and use it for initializing s2
https://github.com/eBay/NuRaft/blob/498cc30fb1e15fa4d1901821e9231a0727bfedfb/examples/in_memory_state_mgr.hxx#L34
then s2 will not be a leader at the beginning.
After that, you can use the same srv_config for adding s2 to the leader.
https://github.com/eBay/NuRaft/blob/498cc30fb1e15fa4d1901821e9231a0727bfedfb/include/libnuraft/raft_server.hxx#L114-L125
Once adding a learner is successfully done, you can see a log like this:
2020-06-02T10:46:15.276_630-07:00 [8d67] [INFO] new configuration: log idx 4, prev log idx 3
peer 1, DC ID 1, tcp://127.0.0.1:11111, voting member, 50
peer 2, DC ID 1, tcp://127.0.0.1:11112, voting member, 50
peer 3, DC ID 1, tcp://127.0.0.1:11113, voting member, 50
peer 4, DC ID 1, tcp://127.0.0.1:11114, learner, 50
my id: 1, leader: 1, term: 1 [handle_commit.cxx:693, reconfigure()]
Hi @greensky00 It works. Thanks a lot!