I've ran into this super annoying issue today.
Basically, I have setup a MongoDB database using the GCP Marketplace offering. It sets up a primary node, secondary, and an arbiter. Which is super cool. What it doesn't do is security. Like, at all. So only natural I had to set it up myself. Well, now 20 hours later and a few good punches to my own face I am still struggling to get it running.
Basically, this is my partial config:
security:
authorization: enabled
keyFile: '/etc/mongodKey'
If I comment out the keyFile
the instance runs. But it cannot connect to any other nodes, because of the security being enabled. And no, I cannot disable it, are you mad?
The thing about the keyFile though... As I understand, mongod
cannot open it, so it won't start. I suppose /etc
is not a good place to put it in? I tried other folders, but to no avail. Nothing works.
And I need to have that security measure, since the database needs to be connected to by my colleagues using Robo 3T. So dropping the external IP address is out of the question.
What me do wrong? Please help as I'm pulling my own hair out.
This is the output of sudo service mongod status
:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-08-21 15:28:08 UTC; 4min 29s ago
Docs: https://docs.mongodb.org/manual
Process: 1024 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 1024 (code=exited, status=1/FAILURE)
Aug 21 15:28:08 m-vm-0 systemd[1]: Started MongoDB Database Server.
Aug 21 15:28:08 m-vm-0 systemd[1]: mongod.service: Main process exited, code=exited, status=1/F
Aug 21 15:28:08 m-vm-0 systemd[1]: mongod.service: Unit entered failed state.
Aug 21 15:28:08 m-0 systemd[1]: mongod.service: Failed with result 'exit-code'.
Edit:
I checked the mongod.log
. Yes it is a permission issue. And I cannot solve it.
I tried doing sudo chmod 400 /etc/mongodKey
but it doesn't do anything.
Please, someone, where do I put the key file so it is readable by mongodb? This is very important!
sudo chmod 600 /etc
and now I can't access that folder anymore. So the whole deployment is fucked and can't be fixed. Well, getting fired is not bad. I'll finally move onto doing something else. Fuck devops and fuck programming.