场景: 在已经配置了mongodb并启动cmdb服务后,本机ip地址发生变化
注意:使用stop.sh
停止cmdb后,用ps -ef
确保cmdb所有服务真的停了,有时可能停不掉,需要手动kill
例如: 新的服务地址为192.168.5.199
bindIp
字段修改为192.168.5.199
在mongo client中输入两条命令
cfg={ _id:"rs0", members:[ {_id:1,host:'192.168.5.199:27017',priority:1}]}
强制应用
rs.reconfig(cfg,{"force":true})
然后rs.status()
确认状态正常,以及节点ip是否已经更改为192.168.3.100
例:
rs0:PRIMARY> rs.status()
{
"set" : "rs0",
"date" : ISODate("2021-05-11T03:11:20.097Z"),
"myState" : 1,
"term" : NumberLong(32),
"syncingTo" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 1,
"writeMajorityCount" : 1,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1620702671, 1),
"t" : NumberLong(32)
},
"lastCommittedWallTime" : ISODate("2021-05-11T03:11:11.885Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1620702671, 1),
"t" : NumberLong(32)
},
"readConcernMajorityWallTime" : ISODate("2021-05-11T03:11:11.885Z"),
"appliedOpTime" : {
"ts" : Timestamp(1620702671, 1),
"t" : NumberLong(32)
},
"durableOpTime" : {
"ts" : Timestamp(1620702671, 1),
"t" : NumberLong(32)
},
"lastAppliedWallTime" : ISODate("2021-05-11T03:11:11.885Z"),
"lastDurableWallTime" : ISODate("2021-05-11T03:11:11.885Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1620702651, 1),
"lastStableCheckpointTimestamp" : Timestamp(1620702651, 1),
"electionCandidateMetrics" : {
"lastElectionReason" : "electionTimeout",
"lastElectionDate" : ISODate("2021-05-11T03:08:00.972Z"),
"electionTerm" : NumberLong(32),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1620702473, 1),
"t" : NumberLong(31)
},
"numVotesNeeded" : 1,
"priorityAtElection" : 5,
"electionTimeoutMillis" : NumberLong(10000),
"newTermStartDate" : ISODate("2021-05-11T03:08:00.979Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2021-05-11T03:08:01.087Z")
},
"members" : [
{
"_id" : 0,
"name" : "192.168.5.199:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 201,
"optime" : {
"ts" : Timestamp(1620702671, 1),
"t" : NumberLong(32)
},
"optimeDate" : ISODate("2021-05-11T03:11:11Z"),
"syncingTo" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1620702480, 1),
"electionDate" : ISODate("2021-05-11T03:08:00Z"),
"configVersion" : 67365,
"self" : true,
"lastHeartbeatMessage" : ""
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1620702671, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1620702671, 1)
}