Mongo reflecting different set of DB's before and after mongod shutdown

Hi,

I am seeing different set of DB’s’ after shutting down mongod manually using db.shutdownServer().

Image 1: mongod running as a service
Image 2: mongod being run manually post shutdown using db.shutdownServer() command.

Can anyone suggest the reason behind this.

Regards,
Chetan

Hi Chetan_Prakash_59365,

Can you please share the complete set of commands that you are using to launch the mongod processes in the both the cases?
Meanwhile, please make sure you are running all your mongod commands and vagrant under the “m103-vagrant-env” folder.

Thanks,
Muskan
Curriculum Support Engineer

Below are the commands i am running.

  1. show db’s is resulting in Image 1(mongod is running a service and have only provided mongo as a command to a new cmd window).
    2 using admin DB, ran command db.shutdownServer() and stopped the deamon running as a service.
  2. using a new cmd windows and running mongod,mongo and show db’s respectively, Image 2 DB’s are getting listed.

I am aware that i have created the database existing in Image 2 somewhere during the M201 lesson on my localhost, however it only gets reflected when i run the mongod manually(not by itself as a service).

Also note that i am using Vagrant for labs under this course, however am trying to replicate all processes(whichever applicable) on Windows locally as well.

Just to simplify, mongod as a Service and mongod as a process is listing me different set of DB’s.

Perhaps the mongod started as a service does not use the same configuration file. So the database’s files are not stored at the same place so the databases are different.

Hi,

This discussion can be closed now as the different set of DB’s are being reflected as per below.

  1. When mongod is running as a Windows service it is using below path and the data(db’s,collections, indexes) folder from below location is used.

C:\Program Files\MongoDB\Server\4.0\data
2. When mongod is being ran manually(as a separate process instead of a automatic Windows service) , it is using a different set of data folder which we can define while running mongod. In my case it was using.
C:\data\db

Thanks everyone for their suggestions.

1 Like