M103 configDB: Database collection not found

MongoDB Enterprise mongos> show dbs
admin            0.000GB
applicationData  0.030GB
config           0.001GB
MongoDB Enterprise mongos> use config
switched to db config
MongoDB Enterprise mongos> show collections
changelog
chunks
collections
lockpings
locks
migrations
mongos
shards
tags
transactions
version
  1. why don’t I find the database,actionlog collection in config DB
MongoDB Enterprise mongos> show dbs
admin            0.000GB
applicationData  0.030GB
config           0.001GB
MongoDB Enterprise mongos> use applicationData
switched to db applicationData
MongoDB Enterprise mongos> show collections
MongoDB Enterprise mongos> use admin
switched to db admin
MongoDB Enterprise mongos> show collections
system.keys
system.users
system.version
MongoDB Enterprise mongos> use config
switched to db config
MongoDB Enterprise mongos> show collections
changelog
chunks
collections
lockpings
locks
migrations
mongos
shards
tags
transactions
version
  1. I cannot view the collection of applicationData from mongos process but I am able to view it on m103-repl set

@Rakshith_79674 please put your code inside backticks:
image
It’s not a single quote character (’), it’s a backtick character(`).

Potentially there’s something wrong with your setup. Check sh.status() and see if you can find anything there.

1 Like

Hi @Rakshith_79674,

The config.databases collection stores a document for each database in the cluster, i.e., the databases for which we have enabled sharding.

MongoDB Enterprise mongos> db.databases.find().pretty()
{ “_id” : “m103”, “primary” : “m103-repl-2”, “partitioned” : true }

The actionlog contains the details of operations occurring related to that same database.

MongoDB Enterprise mongos> db.actionlog.find().pretty()
{
“_id” : “m103-2019-09-25T10:56:22.065+0000-5d8b47d619f570dae0633167”,
“server” : “m103”,
“clientAddr” : “”,
“time” : ISODate(“2019-09-25T10:56:22.065Z”),
“what” : “balancer.round”,
“ns” : “”,
“details” : {
“executionTimeMillis” : 22787,
“errorOccured” : false,
“candidateChunks” : 1,
“chunksMoved” : 1
}
}

The reason that you are unable to see config.databases collection here in your config db might be that sharding hasn’t been enabled on applicationData.

As a reference, to see the details of databases and actionlog collection, you may look for these when you enable sharding on m103 in Lab: Shard a collection.

Let me know if this helps, happy learning! :slight_smile:

Thanks,
Muskan

1 Like

Should I enable this with the below command?

sh.enableSharding()

How do I do it?
Is it like authenticating into applicationData db and using the above cmd?

1 Like

Absolutely right, @Rakshith_79674! This is the command that you use to enable sharding and I hope you might have used it earlier in previous labs like Chapter 3: Sharding Lab - Shard a Collection

sh.enablesharding() enables sharding on the specified database, i.e., it allows you to shard the collections present in that database. This does not automatically shard any collections but makes it possible to begin sharding collections using sh.shardCollection().

Thanks,
Muskan

2 Likes

In my view, I don’t think sh.enableSharding() is necessary.

The databases collection in the config db will show all databases (sharded or not) that were created through mongos. All sharded and non-sharded datbases are accessible through mongos hence the reason why I say that the enableSharding command is not necessary. As per the image below, this shows the sharded status:

In @Rakshith_79674’s scenario, the applicationData db was not created through mongos. It was created on the replica set hence the reason why it hasn’t yet been synced to the config database. So there should be a command to resync this db to the config db so that it becomes available in mongos.

Or maybe @Muskan_47318 is saying that if you didn’t create the db using mongos, you have to explicitly enableSharding on that db for it to be configured in the config db? If that’s the case, then I agree. And in such a case, applicationData will be setup in the config server and an entry will be made in the databases collection.

This documentation needs a better explanation:
https://docs.mongodb.com/manual/reference/method/sh.enableSharding/

Hi @007_jb,

Yes, that’s exactly what I was trying to put out that config.databases will show the dbs created in the sharded cluster.
Sorry if the explanation was confusing.

Thanks for your inputs! :slight_smile:

Regards,
Muskan

1 Like