接上一篇博客:http://www.cnblogs.com/xiaoit/p/4522218.html

Primary Secondary Arbiter
1:关闭顺序PSA :会报错
2:关闭顺序PAS :可以
3:关闭顺序SAP :主节点会变为从节点
4:关闭顺序SPA :会报错
5:关闭顺序APS
6:关闭顺序ASP :主节点会变为从节点

  

1:关闭顺序PSA
gechongrepl:PRIMARY> rs.isMaster()
{
"setName" : "gechongrepl",
"setVersion" : 13,
"ismaster" : true,
"secondary" : false,
"hosts" : [
"192.168.91.133:27017",
"192.168.91.132:27017",
"192.168.91.132:27018"
],
"arbiters" : [
"192.168.91.135:27017"
],
"primary" : "192.168.91.133:27017",
"me" : "192.168.91.133:27017",
"electionId" : ObjectId("5568098a6de3d53a2ea91c64"),
"maxBsonObjectSize" : 16777216,
"maxMessageSizeBytes" : 48000000,
"maxWriteBatchSize" : 1000,
"localTime" : ISODate("2015-05-29T06:39:36.548Z"),
"maxWireVersion" : 3,
"minWireVersion" : 0,
"ok" : 1
}

  

P:

gechongrepl:PRIMARY> use admin
switched to db admin
gechongrepl:PRIMARY> db.shutdownServer()

S:

从变为了:gechongrepl:PRIMARY>

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:48:06.022-0700
Error: assert failed : unexpected error: Error: shutdownServer failed: No electable secondaries caught up as of 2015-05-28T23:48:06.022-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:48:06.023-0700 E QUERY Error: assert failed : unexpected error: Error: shutdownServer failed: No electable secondaries caught up as of 2015-05-28T23:48:06.022-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()

  

  

再次关闭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则按照有大到小选出活跃节点。

 

最新文章

  1. Android入门(九)文件存储与SharedPreferences存储
  2. neo4j安装与示例
  3. 11.python之线程,协程,进程,
  4. Windows 10 访问网络共享 总是提示用户名或密码不正确的解决方法
  5. ActiveMQ消息的可靠性机制(转)
  6. 【mysql】之MySQL导入sql脚本错误:2006 - MySQL server has gone away
  7. How to control PrincipalObjectAccess table growth in Microsoft Dynamics CRM 2011
  8. java对cookie的操作_01
  9. linux安装mongodb并启动
  10. 云计算与虚拟化以及IaaS, PaaS和SaaS
  11. MVC 向页面传值方式总结
  12. Unity5系列资源管理AssetBundle——加载
  13. 关于SQL调优(Distinct 和 Exits)
  14. Go语言学习笔记(三)数组 &amp; 切片 &amp; map
  15. ASP.NET Core 开源论坛项目 NETCoreBBS
  16. MyBatis学习(01)之解决mapper绑定异常
  17. 2018年省赛蓝桥杯JavaB组
  18. Influxdb简介与安装
  19. android 解决studio生成aar包并在其他工程引用aar包的坑,不需要任何gradle配置
  20. 借助LVS+Keepalived实现负载均衡

热门文章

  1. BaseControl按钮合集
  2. springboot redis多数据源设置
  3. 每天一个linux命令:df 命令
  4. windows快速删除大量文件
  5. 内存数据库-H2简介与实践
  6. Windows Server 2008 R2 小技巧 (转)
  7. 实战体验几种MySQL Cluster方案(转)
  8. 十个 Laravel 5 程序优化技巧
  9. 【Scala】Scala-循环与遍历
  10. [Algorithm] Delete a node from Binary Search Tree