【问题标题】:Adding a node to a running replicaset on an existing shard将节点添加到现有分片上正在运行的副本集
【发布时间】:2014-02-05 22:58:57
【问题描述】:

MongoDB 分片需要知道副本集的成员。成员列表发现是动态的吗?我的意思是,如果我们将一个节点添加到已在配置服务器上配置为分片的现有副本集,分片会自动更新,还是我们手动更新分片配置并添加任何新成员到副本?

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    在旧版本的 Mongo 中,在 2.0.3 之前,添加分片时需要指定所有副本集成员。因此,似乎可以得出这样的结论:当一个分片被添加并且它只需要知道副本集的一个成员时,副本集成员之间的所有活动都被委托给副本集。

    确定的最佳方法可能是在您自己的机器上启动测试场景。但是没有任何迹象表明应该需要任何额外的分片配置。

    作为一个更新,因为我在吃午饭时无事可做 :) 我只是启动了列出的教程中列出的大量实例:

    http://docs.mongodb.org/manual/tutorial/add-shards-to-shard-cluster/

    一些不同之处在于仅在添加的副本集的第一个成员中使用sh.addShard,而不是文档中显示的所有成员语法。

    一旦碎片上升。我刚刚向firstset 添加了两个副本集节点。

    http://docs.mongodb.org/manual/tutorial/expand-replica-set/

    没有别的,让我们看看来自 mongos 的状态

    mongos> db.printShardingStatus()
    --- Sharding Status ---
    sharding version: {
        "_id" : 1,
        "version" : 4,
        "minCompatibleVersion" : 4,
        "currentVersion" : 5,
        "clusterId" : ObjectId("52f2f77a538f784f4413e6b9")
    }
    shards:
      {  "_id" : "firstset",
          "host" :"firstset/localhost:10001,localhost:10002,localhost:10003,localhost:10004,localhost:10005" }
        {  "_id" : "secondset",  "host" : "secondset/localhost:20001,localhost:20002,localhost:20003" }
    databases:
        {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
        {  "_id" : "test",  "partitioned" : true,  "primary" : "firstset" }
                test.test_collection
                        shard key: { "number" : 1 }
                        chunks:
                                secondset       23
                                firstset        191
    

    所以分片仍在移动块,新节点在我输入时刚刚完成初始化。

    这就是向分片上的副本集添加额外节点的全部内容。其中大部分是在插入 100 万个文档期间完成的。

    【讨论】:

    • 谢谢您的麻烦!
    猜你喜欢
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 2012-10-08
    • 1970-01-01
    • 2020-09-13
    • 1970-01-01
    • 2018-11-23
    • 1970-01-01
    相关资源
    最近更新 更多