The `cleanupOrphaned` doesn't exist in MongoDB 3.0.2? - mongodb

I deploy a sharded cluster with the MongoDB version of 3.0.2.
I check the MongoDB 3.0 manual and find the command cleanupOrphaned.
http://docs.mongodb.org/manual/reference/command/cleanupOrphaned/#log-files
When I type this command from a mongos' admin database with the follow format:
db.runCommand({cleanupOrphaned:"mydb.mycol"})
it returns:
{ "ok" : 0, "errmsg" : "no such cmd: cleanupOrphaned", "code" : 59 }
Does anybody know why this happens???

Run cleanupOrphaned in the admin database directly on the mongod instance that is the primary replica set member of the shard. Do not run cleanupOrphaned on a mongos instance. It is given in the same link.

Related

Does DocumentDB support mongo shell?

I am using AWS document db v4.0.0. It works fine with my application using MongoDB driver to connect. But when I try to use mongo shell it gives me some errors on basic query:
db.myCollection.find({})
Error: error: {
"ok" : 0,
"code" : 303,
"errmsg" : "Feature not supported: 'causal consistency'",
"operationTime" : Timestamp(1645150705, 1)
}
Does this mean DocumentDB is not compatible with mongo shell?
Your code is missing the actual connection part, but make sure you have the TLS keys placed on the machine.
Your connection string should be something like this:
mongo --ssl host docdb-2020-02-08-14-15-11. cluster.region.docdb.amazonaws.com:27107 --sslCAFile rds-combined-ca-bundle.pem --username demoUser --password
There is actually a really good example/explanation in the official AWS Documentation
Casual consistency isn't supported in DocumentDB. From your mongo shell you can run "db.getMongo().setCausalConsistency(false)" then re-run your find operation.
https://docs.mongodb.com/manual/reference/method/Mongo.setCausalConsistency/

Error in configuration of Mongodb sharded cluster

I have Error in configuration of Mongodb sharded cluster.
I tried all the possibilities of rs.add("127.0.0.1:27002"), rs.add("loclahost:27002") and rs.add("hostname:27002") for sharding
But I am getting error:
{
"ok" : 0,
"errmsg" : "Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2",
"code" : 103
}
I assume that you try to connect to your primary and trying to add the secondary nodes. To start a Mongo instance by typing
mongo localhost:30001
I suppose this is primary, in the mongod shell for this primary. Type in this command
rs.status()
You'll get to know the name of your primary. Same will be the name of your secondary with just the difference of the port number.
Once you get the name, just do rs.add("name:port_number") and you'll be able to add.
rs.add() is used to make ReplicaSet not Sharded cluster.
If you what to add a shard to a sharded cluster, you may use sh.addShard("host:port").

Mongo DB: Unable to create a sharding cluster in Ubuntu

I have installed MongoDB using http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ in my Ubuntu machine and the mongo instance is working fine.
I am able to do CRUD operations in the instance. I also installed the MonjaDB eclipse plugin and am able to see all databases/collections/documents in it.
Now, I want to create a sharded cluster in my machine. I am trying to create this way:
cluster = new ShardingTest({"shards" : 3, "chunksize" : 1})
It is giving the following error:
Resetting db path '/data/db/test0'
Wed Feb 12 15:46:43 Error: boost::filesystem::create_directory: Permission denied: "/data/db/test0" (anon):1
Also, I tried to create shards for existing collection. For this, first I tried to enable sharding in my database ("test")
sh.enableSharding("test")
Wed Feb 12 15:48:14 uncaught exception: not connected to a mongos
Can someone please let me know, what might went wrong.
Thanks in advance,
Raghu
I can suggest that you follow the documentation from the MongoDB site to deploy your sharded cluster for the first time:
http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/
If you then wish to work through another product to aid in this then you can be more aware of what actually needs to be done and what is not happening.
Try starting mongo shell with root user:
$ sudo mongo --nodb
and then in mongo shell:
> cluster = new ShardingTest({"shards" : 3, "chunksize" : 1})
If your problem persists check permissions and ownership for the directory "/data/db/". See mongodb Mongod complains that there is no /data/db folder answer.

Mongo Replica Sets

I just set up a replica set according to the instructions online.
I have config like this:
{
"_id" : "rs0",
"members" : [
{
"_id" : 0,
"host" : "10.0.8.10:27017"
}
]
}
I ran the rs.initiate() command. No issues.
Ok, so I went to set up the second node I did the same thing (with a different IP of course).
Again I ran the rs.initiate() command without issues.
I ran the rs.add command, providing the IP/port of my first instance. No problem.
Finally from the other node I ran the rs.add command with the reference to the former node.
Now I got this:
rs0:PRIMARY> rs.add("10.0.0.10:27017");
{
"errmsg" : "exception: member 10.0.0.10:27017 has a config version >= to the new cfg version; cannot change config",
"code" : 13341,
"ok" : 0
}
What does that mean? And how do I fix it? Both nodes were created from identical Mongo releases.
The rs.initiate() command should only be used once for any given replicaset. You have the option of specifying all members of the set as options to the command like so:
rs.initiate({_id:'rs0', members:[{_id:0, host:'10.0.8.10:27017'},{_id:1, host:'10.0.0.10:27017'}]})
Once the replicaset is configured, you can add new members using rs.add(). If you choose this method, you would initialize the set with a single member, then execute rs.add() from the PRIMARY.
rs.initiate({_id:'rs0', members:[{_id:0, host:'10.0.8.10:27017'}]})
rs.add('10.0.8.10:27017')
You don't need to run rs.initiate() on the other node. Once the node is added to the config, running rs.initiate() on the first node will initiate the entire replica set.
The error is caused because the replica set has already been initiated with the config version you set up when you run rs.initiate() a second time.

Configure an Openshift MongoDB Replica Set

Tried to configure an openshift MongoDB Replica Set, so I configured the main openshift application instance, but when trying to add a new replica set member:
rsMeetPays:PRIMARY> rs.add('aaa.bbb.ccc:27017')
{
"errmsg" : "exception: can't use localhost in repl set member names except when using it for all members",
"code" : 13393,
"ok" : 0
}
I made a ping from openshit to the server aaa.bbb.ccc, so it exists an it is alive. When trying to resolve the server's name:
[app-gear.rhcloud.com user]\> nslookup aaa.bbb.ccc
nslookup: isc_socket_bind: permission denied
So, can I assume MongoDB can not resolve names, and thus there is no way to set up a MongoDB replica set on Openshift?
OpenShift currently doesn't support MongoDB Replica Sets. Please vote on the feature here:
https://www.openshift.com/content/support-replica-sets-for-mongodb