删除进入分片集群的 mongodb 副本集

删除进入分片集群的 mongodb 副本集

我有这样的配置:

mongos> db.adminCommand('getShardMap')
{
"map" : {
    "RS13" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS13/mongo09-02:27003,mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS26" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS26/mongo09-04.de.prod:27008,mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS45" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS45/mongo09-02:27004,mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS67" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "config" : "mongo09-01:27011,mongo09-02:27012,mongo09-03:27013",
    "mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "mongo09-02:27003" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-02:27004" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-03.de.prod:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-03:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-04.de.prod:27007" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-04.de.prod:27008" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002"
},
"ok" : 1
}

实际上 mongo09-03 似乎是重复的:

    "mongo09-03.de.prod:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-03:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",

并且请考虑副本集 RS67 也是分片集群的一部分。

当 Mongodb 副本集进入分片集群时,我可以将其删除吗?如果可以,该怎么做?

我可以使用 rs.remove(hostname) 吗?

答案1

这不是一个简单的运行命令类型的事情。请参阅文档站点上的以下内容

http://docs.mongodb.org/manual/tutorial/remove-shards-from-cluster/

删除副本集成员

 rs.remove("mongo09-03.de.prod:27006")

答案2

我们已成功配置副本集,执行以下命令:

db.shards.update({_id: "RS67"} , {$set: {"host" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007"}})

现在分片图已正确配置并且额外的 mongo09-03 已消失。

mongos> db.adminCommand('getShardMap') 
{
"map" : {
    "RS13" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS13/mongo09-02:27003,mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS26" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS26/mongo09-04.de.prod:27008,mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS45" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS45/mongo09-02:27004,mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS67" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "config" : "mongo09-01:27011,mongo09-02:27012,mongo09-03:27013",
    "mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "mongo09-02:27003" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-02:27004" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-03.de.prod:27006" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-04.de.prod:27007" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-04.de.prod:27008" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002"
},
"ok" : 1
}

还请考虑:

集合中的主机列表仅在 mongos 首次启动时用作种子列表。一旦进程启动,它们就会自动发现其余成员(就像副本集模式下的任何其他客户端/驱动程序一样)并跟踪副本集中的每个成员。

相关内容