问题描述
我正在尝试在mongoDB中创建一个具有3个节点(主节点和2个辅助节点)的基本副本集。 它为我工作了一次,但突然我在rs.status()中看到主节点现在是辅助节点,而其他两个节点则无法访问。我试图重新配置,启动但没有任何效果。我所要做的就是删除2个节点并保留1个主节点,但是每当我尝试添加2个节点时,都会出现错误,提示该节点正在重新配置。
rs1:SECONDARY> rs.status()
{
"set" : "rs1","date" : ISODate("2020-09-22T07:11:47.370Z"),"myState" : 2,"term" : NumberLong(3),"syncSourceHost" : "","syncSourceId" : -1,"heartbeatIntervalMillis" : NumberLong(2000),"majorityVoteCount" : 2,"writeMajorityCount" : 2,"votingMembersCount" : 3,"writableVotingMembersCount" : 3,"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1600758614,1),"t" : NumberLong(3)
},"lastCommittedWallTime" : ISODate("2020-09-22T07:10:14.325Z"),"appliedOpTime" : {
"ts" : Timestamp(1600758624,"durableOpTime" : {
"ts" : Timestamp(1600758624,"lastAppliedWallTime" : ISODate("2020-09-22T07:10:24.326Z"),"lastDurableWallTime" : ISODate("2020-09-22T07:10:24.326Z")
},"lastStableRecoveryTimestamp" : Timestamp(1600758614,"members" : [
{
"_id" : 0,"name" : "127.0.0.1:27011","health" : 1,"state" : 2,"stateStr" : "SECONDARY","uptime" : 3007,"optime" : {
"ts" : Timestamp(1600758624,"t" : NumberLong(3)
},"optimeDate" : ISODate("2020-09-22T07:10:24Z"),"infoMessage" : "","configVersion" : 382587,"configTerm" : -1,"self" : true,"lastHeartbeatMessage" : ""
},{
"_id" : 1,"name" : "127.0.0.1:27012","health" : 0,"state" : 8,"stateStr" : "(not reachable/healthy)","uptime" : 0,"optime" : {
"ts" : Timestamp(0,0),"t" : NumberLong(-1)
},"optimeDurable" : {
"ts" : Timestamp(0,"optimeDate" : ISODate("1970-01-01T00:00:00Z"),"optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"),"lastHeartbeat" : ISODate("2020-09-22T07:11:42.692Z"),"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),"pingMs" : NumberLong(0),"lastHeartbeatMessage" : "Couldn't get a connection within the time limit of 500ms","configVersion" : -1,"configTerm" : -1
},{
"_id" : 2,"name" : "127.0.0.1:27013","configTerm" : -1
}
],"ok" : 1,"$clusterTime" : {
"clusterTime" : Timestamp(1600758624,"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),"keyId" : NumberLong(0)
}
},"operationTime" : Timestamp(1600758624,1)
}
此外,当我尝试使用3个节点成员创建配置文件,然后再使用rs.initiate()时,我收到错误消息“ errmsg”:“已初始化”。
解决方法
如果要设置副本集,则应将其初始化一次,然后再不修改其配置。
如果您有意重新配置RS,则可以更改其配置,但这不是您当前情况下要做的。
在3节点的RS中,至少要有2个节点才能成为主节点。
第一次遇到问题时,您应该做的是打开两个故障节点之一,然后RS应该会自动修复。
假设您实际上尚未成功更改任何设置,您可能仍可以调出下行节点,并且可以修复所有问题。