Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2086

Prevent creating collections on the 'admin' database and sharding them

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 1.9.0
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • ALL

      1.I'm running shard server

      ./mongod --shardsvr --dbpath /data/r1/ --port 10000

      2.Configuration server

      ./mongod --configsvr --dbpath /data/db/config/ --port 20000

      3.mongos server
      ./mongos --configdb localhost:20000 --port 30000

      4.client

      ./mongo localhost:30000/admin

      Here I'm creating collection table and insert with 1 key called
      "name"
      db.table1.find();

      { "_id" : ObjectId("4cd7ed644ab7a52e8ac54309"), "name" : "1" } { "_id" : ObjectId("4cd7ed7f4ab7a52e8ac5430a"), "name" : "3" } { "_id" : ObjectId("4cd7ed864ab7a52e8ac5430b"), "name" : "4" } { "_id" : ObjectId("4cd7ed8c4ab7a52e8ac5430c"), "name" : "5" } { "_id" : ObjectId("4cd7ed914ab7a52e8ac5430d"), "name" : "6" } { "_id" : ObjectId("4cd7ed964ab7a52e8ac5430e"), "name" : "7" } { "_id" : ObjectId("4cd7ed9f4ab7a52e8ac5430f"), "name" : "8" } { "_id" : ObjectId("4cd7eda54ab7a52e8ac54310"), "name" : "9" } { "_id" : ObjectId("4cd7edaa4ab7a52e8ac54311"), "name" : "20" }

      and then i performing these steps to add and enable sharding

      > db.runCommand(

      { addshard : "localhost:10000" }

      );

      { "shardAdded" : "shard0000", "ok" : 1 }

      > db.runCommand(

      { enablesharding : "admin" }

      )

      { "ok" : 1 }

      >db.table1.ensureIndex(

      { name: 1 }

      );

      > db.runCommand( { shardcollection : "admin.table1",key :

      {name : 1}

      ,unique:true });

      { "collectionsharded" : "admin.table1", "ok" : 1 }

      >db.printShardingStatus()

      — Sharding Status —
      sharding version:

      { "_id" : 1, "version" : 3 }

      shards:

      { "_id" : "shard0000", "host" : "localhost:10000" }

      databases:

      { "_id" : "admin", "partitioned" : true, "primary" : "config" }

      admin.table1 chunks:
      { "name" :

      { $minKey : 1 }

      } -->> { "name" :

      { $maxKey : 1 }

      } on :
      config

      { "t" : 1000, "i" : 0 }

      when i want to see the collection items it's showing like this

      > db.table1.find();
      error:

      { "$err" : "can't find shard for: localhost:20000", "code" : 13129 }

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            alerner Alberto Lerner
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: