- 1台Primary,1台Secondary,1台Arbiter
- 当Arbiter挂了
- Primary和Secondary的主从不会切换
- 外部应用服务不受影响
- 在Primary上重新配置拓扑,去掉原有Aribter引入新的Arbiter, 命令如下。这个操作对Primary,Secondary以及外部应用都没有影响。
|
- Primary和Arbiter同时挂了
- Secondary一直保持Secondary状态,不会自动切换为Primary。重启之后,仍然保持Secondary状态。
- 外部应用服务不能读写,且应用服务不能正常重启
- 重启Primary,则经过几秒钟之后,Primary恢复成Primary状态,则外部应用能正常重启,外部应用读写正常,如果外部应用没有重启,则仍然能恢复正常读写;Primary与Secondary之间数据同步恢复正常。
- 如果因为硬件等原因Primary不能重启,则需要在Secondary的上强制修改拓扑配置,将其余节点去掉,并将原来的Secondary指定为新的Primary,然后修改应用服务的mongo URL指向新的Primary再重启应用服务。修改命令如下:
|
等原有Primary恢复以后,再将其作为Secondary加入到拓扑当中,需要在新的Primary上修改配置,命令如下
|
- 1台Primary,2台Secondary,1台Arbiter
- Primary和Arbiter同时挂了,达到总节点数的一半
- 2台Secondary无法自动选出一个Primary,日志中会报“Not starting an election, since we are not electable due to: Not standing for election because I cannot see a majority (mask 0x1)”
- 1台Primary,3台Secondary,1台Arbiter
- Primary和Arbiter同时挂了
- 3台Secondary会自动选出一个Primary,先选priority值最大的,priority值相同的情况则随机选择。
- Primary和其中一个Secondary同时挂了
- 2台Secondary中会自动选出一个Primary,先选priority值最大的,priority值相同的情况则随机选择。
- Primary,其中一个Secondary和Arbiter同时挂了
- 2台Secondary无法自动选出一个Primary,日志中会报“Not starting an election, since we are not electable due to: Not standing for election because I cannot see a majority (mask 0x1)”
- 1台Primary,4台Secondary,1台Arbiter
- Primary和Arbiter同时挂了
- 4台Secondary会自动选出一个Primary,暂时没有发现有平局的情况
- Primary,Arbiter和一个Secondary同时挂,达到总节点数的一半
- 3台Secondary无法自动选出一个Primary,日志中会报“Not starting an election, since we are not electable due to: Not standing for election because I cannot see a majority (mask 0x1)”
- Primary和2个Secondary同时挂,达到总节点数的一半
- 2台Secondary无法自动选出一个Primary,日志中会报“Not starting an election, since we are not electable due to: Not standing for election because I cannot see a majority (mask 0x1)”
多个Secondary节点并不是全部都从主节点同步,也可以从其它从节点同步。Secondaries may automatically change their sync from source as needed based on changes in the ping time and state of other members’ replication.
应用服务里所配的多个Mongo IP只要有一个还处于存活状态,则读写正常,应用服务重启也正常。