Can not start mutiple mongo instances on the same machine

hi all,

i tried to build a replicaset for 3 nodes on the same VM machine. when i started one instance with the mongod command, the mongod program permission changed from 777 to 666 immediately, hence another mongod command to start a new instance failed with the permission denied error. and the permission of mongod can not change during the process is running…

LOG: since instance is not up, no system log generated.

Permission: -rw-rw-rw- 1 vagrant vagrant 60327384 Nov 13 02:48 mongod

Error message:
vagrant@m312:/shared/mongodb/bin$ ./mongod -f /home/vagrant/config_file/secondary_node2.conf
-bash: ./mongod: Permission denied

may it know what’s the solution for this? Thanks a lot.

Hi @stewie_song

That shouldn’t be an issue since the file is not an executable. You’ll need to include the log at the very least.

Also, see if you can start a standalone with config file first.

hi Santiago,

Thanks for your reply. i am able to start a standalone instance with each of the config files. but i can not have more than 1 instance started with the mongod command… when the first instance is running, then try to start another one with mongod command always fail with the permission denied…

the instance is not up at all, no mongodb logs…below is the error.fyi, thanks…
vagrant@m312:/shared/mongodb/bin$ ./mongod -f /home/vagrant/config_file/secondary_node2.conf
-bash: ./mongod: Permission denied

I see. I supposed the permissions for the db storage were changed. Sorry.
Indeed it seems a problem with the binary’s permission…

I’m not much into vagrant so you may wait someone else’s answer.

thank you all the same. :+1:

Share you 3 configuration files.

Have doubts about the above being the complete story. May be the configuration files will shed some lights.

Are you taking M103 or M312? Your post is in M103, yet your prompt indicates that you are running on the M312 virtual machine. It is important to know exactly what course and what lab you are trying to accomplish.

Also provide the output of the following commands:

  1. whoami
  2. ls -al /home/vagrant/config_file/
  3. ls -al /shared/mongodb/bin/

hi Steevej,

Thanks for you reply.
I am working on the M312, and tried to build a 3 nodes replicaset, but i failed to start multiple instances on the localhost. and i refer to the M103 for the replica setup. that’s why i posted my issue here…

please refer to below for those commands output:
vagrant@m312:/shared/mongodb/bin$ whoami
vagrant
vagrant@m312:/shared/mongodb/bin$ ls -al /home/vagrant/config_file/
total 20
drwxrwxr-x 2 vagrant vagrant 4096 Dec 22 09:45 .
drwxr-xr-x 11 vagrant vagrant 4096 Dec 22 09:45 …
-rw-rw-r-- 1 vagrant vagrant 308 Dec 21 02:07 primary_node.conf
-rw-rw-r-- 1 vagrant vagrant 313 Dec 22 09:45 secondary_node1.conf
-rw-rw-r-- 1 vagrant vagrant 310 Dec 21 14:53 secondary_node2.conf
vagrant@m312:/shared/mongodb/bin$ ls -al /shared/mongodb/bin/
total 312784
drwxrwxrwx 1 vagrant vagrant 4096 Dec 14 01:04 .
drwxrwxrwx 1 vagrant vagrant 4096 Dec 14 01:04 …
-rwxrwxrwx 1 vagrant vagrant 13586800 Nov 13 02:35 bsondump
-rwxrwxrwx 1 vagrant vagrant 7722 Nov 13 02:48 install_compass
-rw-rw-rw- 1 vagrant vagrant 34241536 Nov 13 02:48 mongo
-rw-rw-rw- 1 vagrant vagrant 60327384 Nov 13 02:48 mongod
-rwxrwxrwx 1 vagrant vagrant 14452000 Nov 13 02:36 mongodump
-rwxrwxrwx 1 vagrant vagrant 14008616 Nov 13 02:35 mongoexport
-rwxrwxrwx 1 vagrant vagrant 13884952 Nov 13 02:35 mongofiles
-rwxrwxrwx 1 vagrant vagrant 14153672 Nov 13 02:36 mongoimport
-rwxrwxrwx 1 vagrant vagrant 59821992 Nov 13 02:48 mongoperf
-rwxrwxrwx 1 vagrant vagrant 18723880 Nov 13 02:36 mongoreplay
-rwxrwxrwx 1 vagrant vagrant 14487560 Nov 13 02:36 mongorestore
-rwxrwxrwx 1 vagrant vagrant 34622360 Nov 13 02:48 mongos
-rwxrwxrwx 1 vagrant vagrant 14154544 Nov 13 02:35 mongostat
-rwxrwxrwx 1 vagrant vagrant 13780576 Nov 13 02:36 mongotop
vagrant@m312:/shared/mongodb/bin$ ps -elf|grep mongod
1 S vagrant 19339 1 1 80 0 - 251345 futex_ 04:55 ? 00:05:53 ./mongod -f /home/vagrant/config_file/secondary_node1.conf
0 S vagrant 22177 11383 0 80 0 - 2618 pipe_w 14:33 pts/0 00:00:00 grep --color=auto mongod
vagrant@m312:/shared/mongodb/bin$

I started with:

As for mongo and mongod having the wrong permission you could try

chmod +x /shared/mongodb/bin/mongo*

You should also start a new thread in the forum for M312 that indicates clearly which lab you are doing. M103 forum is not appropriate for M312. People taking M103 might be confused with the discussion. Once the new thread is started mark this one as solved.

hi Steejev,
i already had one instance up and running , and the chmod command did not work during the instance is up, besides the permission is 777 while there is no instance running. but it will auto remove the execution permission when the instance started…so strange…

I repeat again.

And will not answer anymore until a thread in the appropriate forum is created.

Hello,
It’s difficult to run tree services in mongod.
You have to create 3 services and 3 config files. Then you create bash script to run in tree services in 1 machine. The basic config mongod couldn’t run 3 services in one machine.

Yes, coding is hard. System admin is also hard. Sometimes a little search can lead to solutions. See

It could if it would make sense to run 3 instances on one machine. A replica set is real replication if and only if the instances run on different machines. You would not want to lose access to your database with a single hardware failure. The fact that we run 3 instances on the same machine, is solely for learning and testing purposes. You must not run your instances on one machine in production, not even on 3 different virtual machines in a single host. I think it is a good thing that the configuration file makes it hard to run something that is not recommended.

Anyway it is quite easy, even without mlaunch, to have a single configuration file that gives the common options and use --dbpath and --port as parameter.

1 Like