Home Work 1.2: ...log file exists; moved to

When I restart the replication set with the keyfile, I get the following message and can’t connect to the database, but without the keyfile, I can connect to the database.

2019-12-23T22:42:17.168+0000 I CONTROL [main] log file “/home/vagrant/M310-HW-1.2/r0/mongodb.log” exists; moved to “/home/vagrant/M310-HW-1.2/r0/mongodb.log.2019-12-23T22-42-17”.

Why can’t I start the first/primary node of the replica set with the keyfile?

Hi @Masud_20882,

It’s against forum guidelines to post potential answers to homework/labs. Suggest you edit and remove the mongod line.

The Informational (I) message is simply telling you that your log file has been rotated.

As this is an advanced course, have you taken the M103 Basic Cluster Administration as a prerequisite?

Sorry, for this. I have made the correction as your suggested. Please note that I have completed all the previous requirements for the DBA path.

I still look for the answer ‘why can’t I restart the primary node with the keyfile’

Thank you for making me aware of your guidelines.

As a tip, have a look in the log file for more. And as a side note, check out the logAppend option.

MONGOD log file content:
…I ACCESS [main] permissions on /mongodb-keyfile are too open…

I made sure that the owners of the MONGOD process and the KEYFILE are the same.

I tried CHMOD for both 400 and 600 for the KEYFILE. But I still cannot restart the MONGOD instance with the KEYFILE

I need your help for further pointers. Please note that I am very rusty on UNIX/LINUX

Here are some suggested steps:

  1. Delete all the log files
  2. Add the logAppend option to your mongod string. Refer to the mongod documentation.
  3. Run mongod again
  4. View the full contents of the file:
    cat /home/vagrant/M310-HW-1.2/r0/mongodb.log
    You can show us the full contents too.

I have deleted all log files. Adding --logappend I tried the mongod and recieved the first line. Second and third lines are after recreating the keyfile:

2019-12-24T05:55:33.953+0000 I ACCESS [main] permissions on /home/vagrant/shared/mongodb-keyfile are too open
2019-12-24T06:01:39.806+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2019-12-24T06:01:39.817+0000 I ACCESS [main] permissions on /home/vagrant/shared/mongodb-keyfile are too open

There are no other lines in the log file?

Just had a think and I can see why the error (which at first wasn’t obvious).
The keyfile should not be created on the shared drive that’s located on your local machine. It needs to be created on a folder on the VM. You can’t run a Linux chmod to a file on a (I’m guessing) Windows OS.


You are right about not creating the keyfile in the shared folder on a Windows host. I created the keyfile on Linux and used 400 to change its mode. Everything is fine and I have completed the homework 1.2.

Thank you, very much. You helped me learn more than what required for the homework.

:slightly_smiling_face: :+1: