Change the Default DB Path

Hello Fellows,
I am running mongod configurations on windows 7 and so far everything worked fine, until I got to change default DB path, using /var/mongodb/db.
The default storage data/db worked correctly.
My question is, how do I create and change owner of the above directory in windows 7 (cmd)?
Since sudo is not windows command, how do I go about it?
Validate_lab_configuration_file tells me the following message:
2019-05-19T18:13:26.320+0000 I STORAGE [initandlisten] exception in initAndListen: NonExi
stentPath: Data directory /var/mongodb/db not found., terminating
Any ideas to help me move on?

Thanks
Wilson

You must follow Windows instructions when running Windows. Path like /var/… are for unix like system.

My system is Windows 10 but Vagrant works as an Ubuntu emulator, right?

I’m asking this because if it’s possible to configure Vagrant as a Windows system I’d prefer it by far, I have no idea about Linux (neither about Windows CMD, but at least it’s Windows).

Using what you know about the configuration file and Linux user groups...

I don’t even know what Linux user groups are.

OK, after getting some help from a keen-on-Linux-friend:

Entering /var:
vagrant@m103:~$ cd /var

Creating /mongodb:
vagrant@m103:/var$ sudo mkdir mongodb

Entering /mongodb to create /db and change the owner:
vagrant@m103:/var$ cd mongodb
vagrant@m103:/var/mongodb$ sudo mkdir db
vagrant@m103:/var/mongodb$ cd db
vagrant@m103:/var/mongodb/db$ sudo chown vagrant:vagrant /var/mongodb/db

Checking that it worked:
vagrant@m103:/var/mongodb/db$ cd ..
vagrant@m103:/var/mongodb$ ls -la

total 12
drwxr-xr-x 3 root root 4096 Jun 25 08:40 .
drwxr-xr-x 16 root root 4096 Jun 25 08:23 …
drwxr-xr-x 2 vagrant vagrant 4096 Jun 25 08:40 db

Is this OK?

=====

Now I’m at this point:

Once your mongod is safely stopped, you can launch it again with your new config file.

So:
mongod --config mongod.conf

But I get an error:
Error reading config file: No such file or directory

The file is where I left it for the last lab…

Run pwd to tell us where you are and run ls to show us the files you have.

@steevej-1495 my set up is exactly the same

vagrant@m103:/data/db$ mongod --config mongod.conf
2019-06-25T12:39:24.971+0000 I CONTROL  [main] log file "/data/mongod.log" exists; moved to "/data/mongod.log.2019-06-25T12-39-24".

heres how my config file looks:

storage:
  dbPath: "/var/mongodb/db"
net:
  bindIp: "192.168.103.100,127.0.0.1"
  port: 27000
systemLog:
  destination: file
  path: "/data/mongod.log"
security:
  authorization: enabled

=====================

2019-06-25T12:42:32.974+0000 I STORAGE  [conn1] WiredTigerKVEngine shutting down
2019-06-25T12:42:33.069`0000 I STORAGE  [conn1] shutdown: removing fs lock...
2019-06-25T12:42:33.069+0000 I CONTROL  [conn1] now exiting
2019-06-25T12:42:33.069+0000 I CONTROL  [conn1] shutting down with code:0
vagrant@m103:/data/db$ mongod --config mongod.conf
2019-06-25T12:44:45.623+0000 I CONTROL  [main] log file "/data/mongod.log" exists; moved to "/data/mongod.log.2019-06-25T12-44-45"
agrant@m103:/var/mongodb$ mongo admin --port 27000

MongoDB shell version v3.6.12

connecting to: mongodb://127.0.0.1:27000/admin?gssapiServiceName=mongodb

2019-06-25T12:51:18.234+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused

2019-06-25T12:51:18.235+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27000, connection attempt failed :

connect@src/mongo/shell/mongo.js:263:13

@(connect):1:6

exception: connect failed`

Please share mongod.log.

vagrant@m103:~$ pwd
/home/vagrant
vagrant@m103:~$ ls
mongod
vagrant@m103:~$ ls -a
.  ..  .bash_history  .bash_logout  .bashrc  .cache  .dbshell  .mongorc.js  .profile  .ssh  mongod

@Sonali_Mamgain agrant@m103:/data/db$ validate_lab_different_logpath

You need to set logAppend to true.

storage:
  dbPath: "/var/mongodb/db"
net:
  bindIp: "192.168.103.100,127.0.0.1"
  port: 27000
processManagement:
  fork: true
systemLog:
  destination: file
  path: "/data/mongod.log"
  logAppend: true
security:
  authorization: enabled

any reason why im still getting error?

@Sonali_Mamgain now lol

vagrant@m103:/data/db$ validate_lab_different_logpath

You need to specify the millisecond threshold for slow operations.

vagrant@m103:/data/db$

Hi @James_68753,

Please correct the validation script. If you are doing the Lab - Change the Default DB Path, then use the following script:

Thanks,
Sonali

SUCCESS!!! thank you!

@JavierBlanco, where is your config file?

Please share your log file.