1

After a complete reinstall of mongo, it has still remembered the replica set configuration from before; where has it stored this?

I installed mongo on a linux server, using our project's user account, into a directory owned by that user. I set up replication and had it working fine. Then, to test out some finer install points, I removed the whole mongo directory and did a reinstall. Entering into mongo, I found that the replication was already set up as before; so it would appear that mongo is storing the information somewhere.

I have checked several areas which might have been holding the replica set config:

  1. First, in the mongo directory, but that was deleted.
  2. In some traditional linux structure probably owned by root, but the project user does not have root access and mongo, run by the same, should not either.
  3. The project user's home directory. Now this does have a .dbshell file containing the command line history, but only that. I did not see any other files there that related.
  4. Some location specified in the mongo configuration. But I only have two paths mentioned in there, one for the system log (systemLog.path) and the other for storage (storage.dbPath), and the both point to the mongo directory, which was deleted.

Does anyone know where mongo is storing this configuration information?

Scott Law
  • 708
  • 1
  • 6
  • 16
  • A good starting point would be rs.help() and rs.status() in your Mongo Shell. rs.conf() shows your current replication config. – dyouberg Sep 07 '16 at 14:49
  • Actually, rs.status() is how I know that it came up with all the original information. Unfortunately, it provides no information on what physical location on the machine that the information is stored. Thanks though. – Scott Law Sep 07 '16 at 14:54

1 Answers1

6

The replication data is stored in the local database in each node (as of MongoDB 3.2.9). This database contains information about the replica set, and also contains the oplog (the oplog.rs collection). The replica set information is stored in the system.replset collection in this local database.

The physical files for this database (and also for other databases) are stored in the dbPath directory, which can be configured using:

  • The --dbpath parameter when starting mongod
  • The storage.dbPath setting in the configuration file

The default dbpath value is /data/db

Your replica set setting will not be retained if you emptied the dbpath directory. If you find that the replication settings are being retained, it is possible that the dbpath setting is incorrect.

Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56
kevinadi
  • 13,365
  • 3
  • 33
  • 49
  • I wasn't clear above, but I am setting the `dbPath` which is in the mongo directory that I am deleting. BUT I just went through the whole process again and the rs config information was gone. Which is what I would have expected in the first place. Possibly I got one of the steps backwards earlier. I am going to go ahead and check this as the right answer, since it should be, and mark this down to user error. – Scott Law Sep 08 '16 at 14:35