Mongo: Force move Secondary to Primary

Автор | 24.05.2024

If happen that your cluster is degraded, for example, two nodes dead in PSS configuration, and the last node is in status Secondary. Then we can force move this node to Primary

cfg = rs.conf()
printjson(cfg)

Remove old nodes

cfg.members = [cfg.members[0] , cfg.members[4] , cfg.members[7]]

maybe change the priority on some members

cfg.members[3].priority = 0
cfg.members[3].vote = 0

And force apply changes on Secondary

rs.reconfig(cfg, {force : true})

Залишити відповідь