0

While trying to clean cleanupOrphaned in my cluster enter image description here

I am getting this error.

SqlWorldWide
13.7k3 gold badges31 silver badges55 bronze badges
asked Nov 27, 2017 at 18:49
3
  • Can you confirm your MongoDB server version with db.version() in the mongo shell? Are you connected to a mongos or a mongod? Commented Nov 28, 2017 at 3:10
  • 1
    I guess that you are using mongodb 2.4 version, what didn't have cleanupOrphaned command, yet. If not, at least you have one error. That panelist_id should be panelist_id.collection, if panelist_id is database. Commented Nov 28, 2017 at 4:01
  • My vesrion is 3.4.3 i have tried with transam_db.panelist (as my database.colection) but i am finding the same error message as (no such cmd: cleanupOrphaned) Commented Nov 29, 2017 at 8:02

1 Answer 1

0

OK..

Step 1. database and collection must be originally created (or sharded) thru mongoS

Step 2. command db.runCommand({cleanupOrphaned: "test.collection"}) must be ran on individual shard node (if replica set, then primary) at admin database. Not on mongoS, if you run that command on mongoS, you get that error message (and of course that error don't tell you that mongos cannot support that command).

#>mlaunch init --sharded 2 --single
launching: mongod on port 27018
launching: mongod on port 27019
launching: config server on port 27020
replica set 'configRepl' initialized.
launching: mongos on port 27017
adding shards.
#>mongo --port 27017
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.6
MongoDB Enterprise mongos> use test
switched to db test
MongoDB Enterprise mongos> db.collection.insert({})
WriteResult({ "nInserted" : 1 })
#> mongo --port 27018 
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:27018/
MongoDB server version: 3.4.6
MongoDB > use admin
switched to db admin
MongoDB > db.runCommand( {cleanupOrphaned: "test.collection"})
{ "ok" : 1 }
answered Nov 29, 2017 at 14:45
7
  • what is the procedure to run it from mongos Commented Dec 20, 2017 at 12:37
  • You cannot run it in the mongos. It must be run at every shard individually. If you try to run, you get error message as you did. Commented Dec 20, 2017 at 22:08
  • ..but you can of course create connection from mongos to individual replica set primary and run command then. Result is same. Commented Dec 20, 2017 at 22:55
  • while runnig the above command in my cluster i am getting rs1:primary>db.runCommand( {cleanupOrphaned: "tans.panelist"}) {"stoppedAtKey" : { "panelist_id : 38112 }, "ok' : 1} rs2:primary>db.runCommand( {cleanupOrphaned: "tans.panelist"}) {"stoppedAtKey" : { "panelist_id : 28741 }, "ok' : 1} is this the correct result Commented Dec 28, 2017 at 11:56
  • Yes, result is OK:1, so command was successful. Commented Dec 28, 2017 at 14:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.