@Ridah_97796, I concur with what @Ramachandra_37567 says. Initially there was a problem with the content of your config file, but once you’d fixed that, you couldn’t start mongod because there was already a mongod instance running and using the same data folder as the one that the mongod that you’re trying to start is trying to use.
This is a really easy mistake to make, starting up mongod instances in the background, forgetting to stop them once you’ve finished with them, and then trying to start another mongod instance when you’ve already got one running with the same config file (and therefore the same data directory). I should know, I’ve done it enough times during this course
The answer is buried in the lecture notes for the chapter 1 lab “Launching Mongod”
ps -ef | grep mongod
To people like me who aren’t familiar with the Linux command line, that command means next to nothing and is difficult to recall when it’s needed, but basically it lists any running processes which might be mongod. You might want to write it on a post-it note and stick it to your monitor
If I run it on my vagrant m103 VM, it tells me this:
vagrant@m103:~$ ps -ef | grep mongod
vagrant 2379 1 1 06:11 ? 00:08:57 mongod -f node1.conf
vagrant 2582 1 1 06:33 ? 00:07:59 mongod -f node2.conf
vagrant 2623 1 1 06:34 ? 00:08:07 mongod -f node3.conf
vagrant 4200 1 1 09:38 ? 00:05:41 mongod -f mongod-repl-1.conf
vagrant 4291 1 1 09:43 ? 00:05:41 mongod -f mongod-repl-2.conf
vagrant 4321 1 1 09:43 ? 00:06:04 mongod -f mongod-repl-3.conf
vagrant 7556 1 1 15:50 ? 00:00:32 mongod -f node4.conf
vagrant 8438 2919 0 16:41 pts/0 00:00:00 grep --color=auto mongod
What this tells me is that I’ve been very bad at stopping my mongod instances once I’m done with them, because I’m still running the mongod instances that I started for both the lesson on setting up a replica set, and for the lab on the same subject. I want to keep the mongod instances I started during the lesson, but I think I’ve finished with the mongod instances that I started for the lab, so I can stop them thus:
vagrant@m103:~$ kill 4200
vagrant@m103:~$ kill 4291
vagrant@m103:~$ kill 4321
vagrant@m103:~$ ps -ef | grep mongod
vagrant 2379 1 1 06:11 ? 00:09:18 mongod -f node1.conf
vagrant 2582 1 1 06:33 ? 00:08:21 mongod -f node2.conf
vagrant 2623 1 1 06:34 ? 00:08:29 mongod -f node3.conf
vagrant 7556 1 1 15:50 ? 00:00:53 mongod -f node4.conf
vagrant 8706 2919 0 17:06 pts/0 00:00:00 grep --color=auto mongod
So now the mongod instances I started for the lectures are still running, but I’ve killed the instances that I started for the lab and forgot to stop, so I can now start other mongod instances using their data directories if I want to.
Disclaimer: you probably don’t want to go killing mongod instances like this in a production environment. This approach is appropriate in the contrived scenario where you’re running all the nodes in a replica set on a single developer box (which doesn’t actually provide the resilience which replica sets are intended for), where your data is probably less important than your ability to learn about how replica sets work.
I get the feeling that I’m not the only one who’s come here to learn about administering MongoDB dabases but has had to sidetrack to learn Linux commands. Any chance of some kind of crib sheet with information about the Linux commands used in this course, for the benefit of Windows junkies like me?
Not that I’m moaning of course, the quality of the training available here (for free!) continues to be excellent, other than considerations such as having an audience who aren’t necessarily already familiar with Linux. Keep up the good work