I successfully created a replica set of three instances on mongodb. Each member of the replica set is instantiated using a config file. When I tested it, everything went well, and executed successfully without any errors.
The next step, which is generating the error in the title is to Enable Internal Authentication. In order to do that, I followed the mongo documentation found in this page:
[a] https://docs.mongodb.com/v3.0/tutorial/enable-internal-authentication/
First, I generated a keyfile using the two lines of code below
openssl rand -base64 755 > <path-to-keyfile>
chmod 400 <path-to-keyfile>
I couldn't exeucte the lines without being root so I did it using root.
then I added the keyfile inside the instance's config file.
# Where and how to store data.
storage:
dbPath: /mon/data1/
journal:
enabled: true
#engine:
#mmapv1:
#wiredTiger:
#where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod1.log
#network interfaces
net:
port: 27018
bindIp: 127.0.0.1
processManagement:
fork: true
security:
keyFile: /etc/keyFiles
replication:
replSetName: "myRepl"
Now in order to start mongo again, I wrote the following command, which I use everytime
sudo mongod --config /etc/mongod1.config
and I got the error above. I made sure that everything was owned by root. the dbpath, the config file, and the keyfile.
Then, I switched everything to be owned by a regular user and I tried to start mongod as a regular user (without sudo). I received the same error.
What do you think is the solution?