MongoDB 删除,添加副本集,并修改副本集IP等信息
添加副本,在登录到主节点下输入
rs.add("ip:port");
删除副本
rs.remove("ip:port");
新增仲裁节点
rs.addArb("ip:port");
修改副本host:
shard1:PRIMARY> cfg = rs.conf()
{
"_id" : "shard1",
"version" : ,
"protocolVersion" : NumberLong(),
"members" : [
{
"_id" : ,
"host" : "127.0.0.1:2777",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : ,
"tags" : { },
"slaveDelay" : NumberLong(),
"votes" :
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : ,
"heartbeatTimeoutSecs" : ,
"electionTimeoutMillis" : ,
"getLastErrorModes" : { },
"getLastErrorDefaults" : {
"w" : ,
"wtimeout" :
},
"replicaSetId" : ObjectId("5d9c7a7e76695600e03e231f")
}
} shard1:PRIMARY> cfg.members[].host = "10.13.10.2:2777"
10.130.10.72:
shard1:PRIMARY> rs.reconfig(cfg)
{ "ok" : }
shard1:PRIMARY> rs.status()
{
"set" : "shard1",
"date" : ISODate("2019-10-09T02:59:26.916Z"),
"myState" : ,
"term" : NumberLong(),
"heartbeatIntervalMillis" : NumberLong(),
"members" : [
{
"_id" : ,
"name" : "10.130.10.72:2777",
"health" : ,
"state" : ,
"stateStr" : "PRIMARY",
"uptime" : ,
"optime" : {
"ts" : Timestamp(, ),
"t" : NumberLong()
},
"optimeDate" : ISODate("2019-10-09T02:59:21Z"),
"electionTime" : Timestamp(, ),
"electionDate" : ISODate("2019-10-08T12:01:02Z"),
"configVersion" : ,
"self" : true
}
],
"ok" :
}