Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongoDB - replica section #195

Open
paf1 opened this issue Nov 23, 2017 · 0 comments
Open

mongoDB - replica section #195

paf1 opened this issue Nov 23, 2017 · 0 comments

Comments

@paf1
Copy link

paf1 commented Nov 23, 2017

Hello,
would you add new section to mongo.pm monitoring ?

add replica section

replica can have these states
PRIMARY / SECONDARY / STARTUP2 / RECOVERY / ......
https://docs.mongodb.com/manual/reference/replica-states/

@ show replica count of nodes ( 2+1 in our case, but can be more )
@ show replica state for current node

_HA0:STARTUP2> rs.status()
{
"set" : "HA0",
"date" : ISODate("2017-11-23T12:41:45.249Z"),
"myState" : 5,
"term" : NumberLong(23),
"syncingTo" : "mongo1:27017",
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"appliedOpTime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"durableOpTime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
}
},
"members" : [
{
"_id" : 1,
"name" : "mongo1:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 5148,
"optime" : {
"ts" : Timestamp(1511440905, 132),
"t" : NumberLong(23)
},
"optimeDurable" : {
"ts" : Timestamp(1511440905, 95),
"t" : NumberLong(23)
},
"optimeDate" : ISODate("2017-11-23T12:41:45Z"),
"optimeDurableDate" : ISODate("2017-11-23T12:41:45Z"),
"lastHeartbeat" : ISODate("2017-11-23T12:41:45.124Z"),
"lastHeartbeatRecv" : ISODate("2017-11-23T12:41:45.125Z"),
"pingMs" : NumberLong(0),
"electionTime" : Timestamp(1511211655, 1),
"electionDate" : ISODate("2017-11-20T21:00:55Z"),
"configVersion" : 565069
},
{
"_id" : 2,
"name" : "mongo3:27017",
"health" : 1,
"state" : 5,
"stateStr" : "STARTUP2",
"uptime" : 5150,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"syncingTo" : "mongo1:27017",
"configVersion" : 565069,
"self" : true
},
{
"id" : 3,
"name" : "mongo2:27017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 5148,
"lastHeartbeat" : ISODate("2017-11-23T12:41:44.121Z"),
"lastHeartbeatRecv" : ISODate("2017-11-23T12:41:41.449Z"),
"pingMs" : NumberLong(0),
"configVersion" : 565069
}
],
"ok" : 1
}

  • when replication is running for the first time we get these outputs, but it's not possible to get db.stat() at this time ( exception is needed ) :

HA0:PRIMARY> db.printReplicationInfo()
configured oplog size: 1024MB
log length start to end:8041secs (2.23hrs)
oplog first event time: Thu Nov 23 2017 11:32:46 GMT+0100 (CET)
oplog last event time: Thu Nov 23 2017 13:46:47 GMT+0100 (CET)
now: Thu Nov 23 2017 13:46:47 GMT+0100 (CET)
HA0:PRIMARY>

HA0:STARTUP2> db.printReplicationInfo()
this is a slave, printing slave replication info.
source: mongo3:27017
syncedTo: Thu Jan 01 1970 01:00:00 GMT+0100 (CET)
1511441113 secs (419844.75 hrs) behind the primary
HA0:STARTUP2>

When finished, then replica STARTUP2 switch to SECONDARY state and the output is the same like PRIMARY ( with different values )

@ show OPLOG size
@ show "log length start to end" value sec / hours -very usefull for maintenance window. If overtimed, then full replica needed, not diff. only.
@ show OPLOG first/last timestamp too

OPLOG - not needed for ARBITER ( no data, just only for cluster voting )

More info for ARBITER node when replication finished ( a few days later )

regs.
Pavel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant