Mongodb副本集容灾
实验环境
操作系统:CentOS Linux release 7.3.1611 (Core)
数据库系统: Mongodb 3.4.9-1.el7
mongo1 IP: 192.168.58.129
mongo2 IP: 192.168.58.130
mongo3 IP: 192.168.58.131
查看副本集状态
在mongo1上查看mongodb集群状态
sbc:PRIMARY> rs.status()
{
"set" : "sbc",
"date" : ISODate("2017-11-27T03:11:08.053Z"),
"myState" : 1,
"term" : NumberLong(6),
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1511752259, 1),
"t" : NumberLong(6)
},
"appliedOpTime" : {
"ts" : Timestamp(1511752259, 1),
"t" : NumberLong(6)
},
"durableOpTime" : {
"ts" : Timestamp(1511752259, 1),
"t" : NumberLong(6)
}
},
"members" : [
{
"_id" : 0,
"name" : "192.168.58.129:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 2396,
"optime" : {
"ts" : Timestamp(1511752259, 1),
"t" : NumberLong(6)
},
"optimeDate" : ISODate("2017-11-27T03:10:59Z"),
"electionTime" : Timestamp(1511749886, 1),
"electionDate" : ISODate("2017-11-27T02:31:26Z"),
"configVersion" : 3,
"self" : true
},
{
"_id" : 1,
"name" : "192.168.58.130:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 2387,
"optime" : {
"ts" : Timestamp(1511752259, 1),
"t" : NumberLong(6)
},
"optimeDurable" : {
"ts" : Timestamp(1511752259, 1),
"t" : NumberLong(6)
},
"optimeDate" : ISODate("2017-11-27T03:10:59Z"),
"optimeDurableDate" : ISODate("2017-11-27T03:10:59Z"),
"lastHeartbeat" : ISODate("2017-11-27T03:11:06.514Z"),
"lastHeartbeatRecv" : ISODate("2017-11-27T03:11:07.703Z"),
"pingMs" : NumberLong(0),
"syncingTo"