1

When I enable the directoryperdb option in the mongo.conf file, mongodb server service doesn't start.

It says directotyperdb value can't be true.

These are the mongo logs:-

2020-03-16T15:37:55.300+0530 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'

2020-03-16T15:37:55.671+0530 I  CONTROL  [main] Trying to start Windows service 'MongoDB'

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten] MongoDB starting : pid=8776 port=27017 dbpath=C:\Program Files\MongoDB\Server\4.2\data 64-bit host=GGNUVBRESSCHINL

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten] db version v4.2.0

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten] allocator: tcmalloc

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten] modules: none

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten] build environment:

2020-03-16T15:37:55.672+0530 I  CONTROL  [initandlisten]     distmod: 2012plus

2020-03-16T15:37:55.673+0530 I  CONTROL  [initandlisten]     distarch: x86_64

2020-03-16T15:37:55.673+0530 I  CONTROL  [initandlisten]     target_arch: x86_64

2020-03-16T15:37:55.673+0530 I  CONTROL  [initandlisten] options: { config: "C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg", net: { bindIp: "127.0.0.1", port: 27017 }, service: true, storage: { dbPath: "C:\Program Files\MongoDB\Server\4.2\data", directoryPerDB: true, journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "C:\Program Files\MongoDB\Server\4.2\log\mongod.log" } }

2020-03-16T15:37:55.674+0530 I  STORAGE  [initandlisten] Detected data files in C:\Program Files\MongoDB\Server\4.2\data created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.

2020-03-16T15:37:55.674+0530 I  STORAGE  [initandlisten] exception in initAndListen: InvalidOptions: Requested option conflicts with current storage engine option for directoryPerDB; you requested true but the current server storage is already set to false and cannot be changed, terminating

2020-03-16T15:37:55.675+0530 I  NETWORK  [serviceStopWorker] shutdown: going to close listening sockets...

2020-03-16T15:37:55.675+0530 I  -        [serviceStopWorker] Stopping further Flow Control ticket acquisitions.

2020-03-16T15:37:55.675+0530 I  CONTROL  [serviceStopWorker] now exiting
Tedinoz
  • 5,911
  • 3
  • 25
  • 35

1 Answers1

2

If the server has already started before without this parameter you won't be able to change it afterwards, this is because the metadata files are already there, if you are ok deleting the data you delete the data folder contents and try it again, it will work.

As per documentation if you want to do it for an existing server you will need to do the following:

To change the storage.directoryPerDB option for existing deployments:

For standalone instances:
Use mongodump on the existing mongod instance to generate a backup.
Stop the mongod instance.
Add the storage.directoryPerDB value and configure a new data directory
Restart the mongod instance.
Use mongorestore to populate the new data directory.
For replica sets:
Stop a secondary member.
Add the storage.directoryPerDB value and configure a new data directory to that secondary member.
Restart that secondary.
Use initial sync to populate the new data directory.
Update remaining secondaries in the same fashion.
Step down the primary, and update the stepped-down member in the same fashion.

This is explained here: https://docs.mongodb.com/manual/reference/configuration-options/#storage.directoryPerDB

Cross
  • 1,436
  • 12
  • 20