接上一篇博客: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则按照有大到小选出活跃节点。

 

MongoDB副本集配置系列四:节点的关闭顺序的更多相关文章

  1. MongoDB副本集配置系列五:副本集的在线迁移

    MongoDB副本集的在线迁移 查看当前集群的状态: { "setName" : "gechongrepl", "setVersion" : ...

  2. MongoDB副本集配置系列三:副本集的认证方式

    1:副本集配置参考这篇博客: http://www.cnblogs.com/xiaoit/p/4478951.html 2:副本集的认证 假设有两台机器已经配置好了副本集(副本集罪一般最少3台机器,这 ...

  3. MongoDB副本集配置系列二:配置MongoDB副本集

    接上一篇博客: http://www.cnblogs.com/xiaoit/p/4479066.html 1:首先创建3台虚拟机作为配置环境 IP1:192.168.91.128 IP2:192.16 ...

  4. MongoDB副本集配置系列十一:MongoDB 数据同步原理和自动故障转移的原理

    1:数据同步的原理: 当Primary节点完成数据操作后,Secondary会做出一系列的动作保证数据的同步: 1:检查自己local库的oplog.rs集合找出最近的时间戳. 2:检查Primary ...

  5. MongoDB副本集配置系列十:MongoDB local库详解和数据同步原理

    1:local库是MongoDB的系统库,记录着时间戳和索引和复制集等信息 gechongrepl:PRIMARY> use local switched to db local gechong ...

  6. MongoDB副本集配置系列七:MongoDB oplog详解

    1:oplog简介 oplog是local库下的一个固定集合,Secondary就是通过查看Primary 的oplog这个集合来进行复制的.每个节点都有oplog,记录这从主节点复制过来的信息,这样 ...

  7. MongoDB副本集配置系列九:MongoDB 常见问题

    What is a namespace in MongoDB? If you remove a document, does MongoDB remove it from disk? When doe ...

  8. MongoDB副本集配置系列八:MongoDB监控

    1:Mongostat MongoDB2.6版本 MongoDB3.0版本 2:db.setProfilingLevel(2):打开profiler 类似于MySQL的slow log Profile ...

  9. MongoDB副本集配置系列六:定位MongoDB慢的原因

    1:想知道哪些操作拖慢了MongoDB的速度,首先需要检查当前正在执行哪些操作. gechongrepl:PRIMARY> db.currentOp() "opid" : 7 ...

随机推荐

  1. Linux网络之设备接口层:发送数据包流程dev_queue_xmit

    转自:http://blog.csdn.net/wdscq1234/article/details/51926808 写在前面 本文主要是分析kernel-3.8的源代码,主要集中在Network的n ...

  2. 将应用升级到了 Spring 4.1.0+quartz-2.2.1 还是很给力一样的兼容

    应用采用了集群3个tomcat,一个weblogic12c 后台数据应用

  3. @NotBlank注解使用不生效的解决办法

    @NotBlank注解使用时必须在入参处(controller)加@Valid. 如: public Class User{ @NotBlank(message = "用户名不能为空&quo ...

  4. 指定文件兼容性模式 < meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />的意义

    X-UA-Compatible是神马? X-UA-Compatible是IE8的一个专有<meta>属性,它告诉IE8采用何种IE版本去渲染网页,在html的<head>标签中 ...

  5. [总结]Jquery api 快速参考

    选择符 匹配 * 所有元素 #id 带有给定ID的元素 element 给定类型的所有元素,比如说html标签 .class 带有给定类的所有元素 a,b 匹配a或者匹配b的元素 a b 作为a后代的 ...

  6. 条件随机场(CRF)原理和实现

    版权声明:作者:金良山庄,欲联系请评论博客或私信,个人主页:http://www.jinliangxu.com/,CSDN博客: http://blog.csdn.net/u012176591   目 ...

  7. java 从网络Url中下载文件 (转)

    http://blog.csdn.net/xb12369/article/details/40543649/ /**       * 从网络Url中下载文件       * @param urlStr ...

  8. [Algorithm] Circular buffer

    You run an e-commerce website and want to record the last N order ids in a log. Implement a data str ...

  9. 数据结构 - 2-路插入排序 具体解释 及 代码(C++)

    2-路插入排序 具体解释 及 代码 本文地址: http://blog.csdn.net/caroline_wendy/article/details/24267679 2-路插入排序的思想非常有意思 ...

  10. Python爬虫学习系列教程

    最近想学一下Python爬虫与检索相关的知识,在网上看到这个教程,觉得挺不错的,分享给大家. 来源:http://cuiqingcai.com/1052.html 一.Python入门 1. Pyth ...