时间:2021-07-01 10:21:17 帮助过:7人阅读
gechongrepl:ARBITER> use admin switched to db admin gechongrepl:ARBITER> db.shutdownServer()
再次关闭S:
S变为了:ggechongrepl:SECONDARY> gechongrepl:SECONDARY> use admin switched to db admin gechongrepl:SECONDARY> db.shutdownServer()
2:关闭顺序PAS : 已经验证,不报错。
3:关闭顺序SAP
S:
gechongrepl:SECONDARY> use admin switched to db admin gechongrepl:SECONDARY> db.shutdownServer()
A:
gechongrepl:ARBITER> use admin switched to db admin gechongrepl:ARBITER> db.shutdownServer()
P:
主变为了:gechongrepl:SECONDARY> gechongrepl:SECONDARY> use admin switched to db admin gechongrepl:SECONDARY> db.shutdownServer()
4:关闭顺序SPA
S:
gechongrepl:SECONDARY> use admin switched to db admin gechongrepl:SECONDARY> db.shutdownServer()
P:
gechongrepl:PRIMARY> use admin switched to db admin gechongrepl:PRIMARY> db.shutdownServer() assert failed : unexpected error: Error: shutdownServer failed: No electable secondaries caught up as of 2015-05-28T23:59:19.685-0700 Error: assert failed : unexpected error: Error: shutdownServer failed: No electable secondaries caught up as of 2015-05-28T23:59:19.685-0700 at Error (<anonymous>) at doassert (src/mongo/shell/assert.js:11:14) at assert (src/mongo/shell/assert.js:20:5) at DB.shutdownServer (src/mongo/shell/db.js:212:9) at (shell):1:4 2015-05-28T23:59:19.702-0700 E QUERY Error: assert failed : unexpected error: Error: shutdownServer failed: No electable secondaries caught up as of 2015-05-28T23:59:19.685-0700 at Error (<anonymous>) at doassert (src/mongo/shell/assert.js:11:14) at assert (src/mongo/shell/assert.js:20:5) at DB.shutdownServer (src/mongo/shell/db.js:212:9) at (shell):1:4 at src/mongo/shell/assert.js:13
A:
gechongrepl:ARBITER> use admin switched to db admin gechongrepl:ARBITER> db.shutdownServer()
再次关闭P:
gechongrepl:PRIMARY> use admin switched to db admin 2015-05-29T00:00:44.938-0700 I NETWORK DBClientCursor::init call() failed 2015-05-29T00:00:44.940-0700 I NETWORK trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed 2015-05-29T00:00:44.941-0700 I NETWORK reconnect 127.0.0.1:27017 (127.0.0.1) ok gechongrepl:SECONDARY> db.shutdownServer()
下面猜测:在关闭最后的Primary节点之前,先关掉仲裁节点即不会报错。(首先关掉Primary节点,还有其他Secondary不属于这种情况)
5:关闭顺序APS : 不会报错 6:关闭顺序ASP : 不会报错
验证猜测:
5:关闭顺序APS
A:
gechongrepl:ARBITER> use admin switched to db admin gechongrepl:ARBITER> db.shutdownServer()
P:
gechongrepl:PRIMARY> use admin switched to db admin gechongrepl:PRIMARY> db.shutdownServer()
S:因为仲裁节点关闭了。所以Primary节点不会再自动切换
gechongrepl:SECONDARY> use admin switched to db admin gechongrepl:SECONDARY> db.shutdownServer()
6:关闭顺序ASP
A:
gechongrepl:ARBITER> use admin switched to db admin gechongrepl:ARBITER> db.shutdownServer()
S:
gechongrepl:SECONDARY> use admin switched to db admin gechongrepl:SECONDARY> db.shutdownServer()
P:
gechongrepl:PRIMARY> 2015-05-29T00:12:23.962-0700 I NETWORK DBClientCursor::init call() failed 2015-05-29T00:12:23.965-0700 I NETWORK trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed 2015-05-29T00:12:23.966-0700 I NETWORK reconnect 127.0.0.1:27017 (127.0.0.1) ok gechongrepl:SECONDARY> gechongrepl:SECONDARY> use admin switched to db admin gechongrepl:SECONDARY> db.shutdownServer()
总结:
1:先关闭从节点、仲裁节点。或者先关闭仲裁节点,最后关闭从节点。则:主节点自动变为从节点
2:先关闭主节点,则从节点自动变为主节点,在仲裁节点关闭之前,新主节点不能关闭
初始化的时候主从节点受priority的影响
priority: 是优先级,默认为1,优先级0为被动节点,不能成为活跃节点。优先级不位0则按照有大到小选出活跃节点。
MongoDB副本集配置系列四:节点的关闭顺序
标签: