How is mongod run in the one-click app?

June 1, 2017 521 views
MongoDB One-Click Install Apps Ubuntu

Hi

I have created a one-click droplet with MongoDB. Now I want to set up authentication. I already created users and roles. But I must enable authentication when the process is started and restart the process.

But how exactly is the mongod process started in this one-click app (I don't want authentication to be disabled if the process needs to be restarted later on)?

I already tried changing the /etc/mongod.conf and rebooting the server (sudo reboot). But it is still possible to login to mongo without specifying a user.

I coud not find anything in the /etc/init.d or in the /etc/systemd/system directories.

This is my mongod.conf:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


#processManagement:

security:
  authorization: enabled

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:
2 Answers
hansen June 1, 2017
Accepted Answer

Hi @sanderdeclerck

According to the manual, the parameter authorization needs to be a string:
https://docs.mongodb.com/manual/reference/configuration-options/#security.authorization

So change the config:

security:
  authorization: "enabled"

And then restart MongoDB:

sudo systemctl restart mongod

You can see more in this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-mongodb-on-ubuntu-16-04

MongoDB is a document-oriented database that is free and open-source. It is classified as a NoSQL database because it does not rely on a traditional table-based relational database structure ... In Part One of this tutorial we'll use the MongoDB Repository to install the latest version of MongoDB. In Part Two, we'll enable authentication to secure it on the local system. Finally, in Part Three, we'll show how to more securely allow remote connections if they're needed.
  • Thanks for the info, as a side note - the systemctl file was located under /lib/systemd/system/mongod.service

@sanderdeclerck

You may want to take a look at this post for details on how to setup authentication with a user.

https://medium.com/@raj_adroit/mongodb-enable-authentication-enable-access-control-e8a75a26d332

As far as starting, stopping and restarting the service, it'll be done either via:

service mongod restart

or

systemctl restart mongod

In most cases, especially on newer distros, systemd is used, so the systemctl command would be what you'd use.

Have another answer? Share your knowledge.