C100DBA MongoDB 讲解-information can be extracted from rs.status() output?

C100DBA MongoDB 讲解-information can be extracted from rs.status() output?

what useful information can be extracted from rs.status() output?

 

  1. Data about the node against which rs.status() is run from the perspective of the nodes in the replica set
  2. Data about which server each secondary is syncing from(askmaclean.com)
  3. Data about the state of other nodes in the replica set from the perspective of the node against which rs.status() is run

中文为:

从rs.status()返回的信息中可以获取以下哪些信息?

  1. Replica Set中运行rs.status()的节点的相关数据
  2. 每一个secondary服务器在基于那个服务器做同步
  3. Replica Set中运行rs.status()的节点意外服务器的信息

 

官方文档对rs.status()的解释是:

This output reflects the current status of the replica set, using data derived from the heartbeat packets sent by the other members of the replica set.

This method provides a wrapper around the replSetGetStatus command. See the documentation of the command for a complete description of the output.

http://docs.mongodb.org/manual/reference/method/rs.status/

官方的解释说明了数据是通过心跳包在replica set复制集的节点间传递的,其反应了replica set的当前状态,所以其不仅仅包括了replica set中本节点的信息(askmaclean.com),

 

实际rs.status()的样例, “syncingTo” : “rep0.dbdao.com:35001”,反应了secondary服务器在基于谁做同步:

rsdbao:PRIMARY> rs.status()
{
        "set" : "rsdbao",
        "date" : ISODate("2015-05-14T03:07:00.883Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "rep0.dbdao.com:35001",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 345,
                        "optime" : Timestamp(1431572809, 1),
                        "optimeDate" : ISODate("2015-05-14T03:06:49Z"),
                        "electionTime" : Timestamp(1431572753, 2),
                        "electionDate" : ISODate("2015-05-14T03:05:53Z"),
                        "configVersion" : 3,
                        "self" : true
                },
                {
                        "_id" : 1,
                        "name" : "rep1.dbdao.com:35001",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 22,
                        "optime" : Timestamp(1431572809, 1),
                        "optimeDate" : ISODate("2015-05-14T03:06:49Z"),
                        "lastHeartbeat" : ISODate("2015-05-14T03:07:00.011Z"),
                        "lastHeartbeatRecv" : ISODate("2015-05-14T03:07:00.650Z"),
                        "pingMs" : 1,
                        "syncingTo" : "rep0.dbdao.com:35001",
                        "configVersion" : 3
                },
                {
                        "_id" : 2,
                        "name" : "rep2.dbdao.com:35001",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 10,
                        "optime" : Timestamp(1431572809, 1),
                        "optimeDate" : ISODate("2015-05-14T03:06:49Z"),
                        "lastHeartbeat" : ISODate("2015-05-14T03:07:00.078Z"),
                        "lastHeartbeatRecv" : ISODate("2015-05-14T03:07:00.228Z"),
                        "pingMs" : 23,
                        "configVersion" : 3
                }
        ],
        "ok" : 1
}



 

同时早期版本存在rs.status()显示syncingTo信息不正确的问题。

This is a known issue. There is an open ticket about rs.status() showing the primary as syncingTo when run from a secondary if the current primary was a secondary in the past ( SERVER-9989 ). Fix verion is 2.5.1

Comment

*

沪ICP备14014813号

沪公网安备 31010802001379号