I've tried to install MongoDB 5.0 Community edition on Ubuntu 18.04 from the Official doc: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Everything went fine until I tried to run mongod service:
$ systemctl start mongod
Failed to start mongod.service: Unit mongod.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status mongod.service' for details.
I tried to gather infos:
$ systemctl status mongod.service
● mongod.service
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
$ sudo systemd-analyze verify mongod.service
mongod.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
mongod.service: Failed to create mongod.service/start: Unit mongod.service is not loaded properly: Argument invalide.
Attempted to remove disk file system, and we can't allow that.
If I try to enable the service instead, I have the following message:
$ systemctl enable mongod.service
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
instance name specified.
Indeed, if I read the output from systemctl list-unit-files
, the mongod service is flagged as static
.
Here's my /lib/systemd/system/mongod.service
contents (automatically written by installing mongodb):
GNU nano 2.9.3 /lib/systemd/system/mongod.service
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target
[Service]
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
PIDFile=/var/run/mongodb/mongod.pid
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
[Install]
WantedBy=multi-user.target
The /var/log/mongodb/
folder is empty though.
Note that I had a previous versions of MongoDB installed, so I ran through the steps on this post:Apt-get fails on 16.04 or 18.04 installing mongodb
And I tried to installed MongoDB 4.2 after that. And the issue persists.
It is indeed installed though, as I can see its version:
db version v4.2.18
git version: f65ce5e25c0b26a00d091a4d24eec1a8b3a4c016
OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1804
distarch: x86_64
target_arch: x86_64
What do these systemctl errors mean? What should I try to do?
Thank you for reading.
EDIT: Note that I need to run the mongod
command through sudo
to have it working from the terminal.
So I tested to modify the mongod.service
file in two waYS:
- First with
User=root
, Group=root
- Then by adding
mongodb
to my sudo group and using:
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
ExecStart=sudo /usr/bin/mongod --config /etc/mongod.conf
Both resulted in the same error: Invalid argument