Chapter 1: Mongod - Lab: Configuration File

I’ve getting the following error while doing the Lab:
Failed global initialization: FileNotOpen: Failed to open “/Users/AlphaLy/Desktop/Coding/EloquentMongoDB/mongod.log”

I understand that the SytemLog path is not required. However, how can solve the Lab while maintaining my log file?

image

Why do you want to keep the log file?

The directory must exist for mongod to be able to write the file.

It will be simpler if you stricly follow lab instructions unless you absolutely know what youcare doing.

@steevej-1495
Ok I was able to run the configuration file without the log file. However, I’m getting another error when I try to add the user as directed by the instructions.
The error is as follow:
Error: couldn’t add user: not master :_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1491:15
@(shell eval):2:1

What am I doing wrong?

I’d recommend you to stick with the exercise requirements, at least if you want to pass the exercise.


Now for playing purposes, you could follow this:

Say we log in Donald Trump’s computer. It doesn’t know anything like “Alpha_Ly” user or data. The IDE is much like DT’s computer, just cleaner.

“/Users/AlphaLy/Desktop/Coding/EloquentMongoDB/mongod.log”

this has not meaning in DT’s computer.

You create the directory, and subdir mkdir -p /home/alphaLy/plays and direct the system log there.

Something like this

systemLog:
   destination: file
   path: "/home/alphaLy/plays"
   logAppend: true

@Santiago_Miranda
I’ve skipped that part for now. I was just trying it for learning purpose.
I guess I’ll do it later when I pass the Lab.
Now my problem is adding the user as directed. When I tried to add the user, I got the following error: Error: couldn’t add user: not master :_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1491:15
@(shell eval):2:1

What am I doing wrong?

Alright. What command are you issuing? (A screenshot could be better than code)

This is the command in the instructions:

mongo admin --host localhost:27000 --eval ’
db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

I’d recommend the following, because it difficult to know like that:

  • Reset workspace, and if you see anything strange refresh the page

Then, use the configuration file, as they request:

# mongod -f mongod.conf
net:
 port: 27000
security:
  authorization: enabled

After that, you should see the terminal full of logs, but that’s ok. Once it is running, try to finish up yourself, or come back and ask.

Please, check that the code is valid YAML. before using it.

As mentioned above, the problem is not my configuration file.
It runs correctly. As of now, my problem is creating the user with the command I mentioned above.
Anyway, thanks for trying.

You may be right, but it sounds as if you had started a replica set and are connecting to a secondary node.

Hence it would be helpful to see the configuration file, and that’s why I asked for a screenshot both of the config file and the terminal where you issue the command.

The lab you linked is for a standalone server, and this may be why we are confused.
If you’re solving Chapter 2: Replication, then the solution is different.

1 Like

@Santiago_Miranda
I’m not comprehending anything you’re saying; replica set (I know the definition), secondary node.
Remember that I’m only on chapter 1.
Haven’t done Chapter 2: Replication
So I’m getting more confused.
The screenshots are on my original post above.
Thanks

That is why configuration items like replication, keyFile and systemLog should not be in your configuration file.

@steevej-1495
They were mentioned on Chapter 1
Lecture: Configuration File
So I supposed we had to have a configuration file as that one.
Thanks