While trying to clean cleanupOrphaned
in my cluster enter image description here
I am getting this error.
1 Answer 1
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 }
-
what is the procedure to run it from mongosashk– ashk2017年12月20日 12:37:20 +00:00Commented 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.JJussi– JJussi2017年12月20日 22:08:37 +00:00Commented 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.JJussi– JJussi2017年12月20日 22:55:14 +00:00Commented 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 resultashk– ashk2017年12月28日 11:56:01 +00:00Commented Dec 28, 2017 at 11:56
-
Yes, result is OK:1, so command was successful.JJussi– JJussi2017年12月28日 14:14:58 +00:00Commented Dec 28, 2017 at 14:14
db.version()
in themongo
shell? Are you connected to amongos
or amongod
?cleanupOrphaned
command, yet. If not, at least you have one error. Thatpanelist_id
should bepanelist_id.collection
, if panelist_id is database.