Failure with start mongod.service on Ubuntu - mongodb

I try to start service with mongo and get an error:
* mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2019-04-12 12:55:29 MSK; 9s ago
Docs: https://docs.mongodb.org/manual
Process: 15162 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 15162 (code=exited, status=1/FAILURE)
Apr 12 12:55:29 mx systemd[1]: Started MongoDB Database Server.
Apr 12 12:55:29 mx systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
Apr 12 12:55:29 mx systemd[1]: mongod.service: Failed with result 'exit-code'.
If I start mongod by manual, all works good.
mongod.service:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
mongod.config:
# 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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
I've set permissions for /var/lib/mongodb and /var/log/mongodb/mongod.log
chown mongodb:mongodb /var/lib/mongodb -R
chown mongodb:mongodb /var/log/mongodb/mongod.log -R
What's wrong? What should I do? Any ideas?

I've solved my porblem. The solution is very simple, but I had a lot of headace.
Free disk space. I have no anought free disk space in my server. Thats it!
I hope this will be helpfull for anybody...

Related

Mongod Active: Failed (code=exited, status=217/USER)

I am using ubuntu16.04 on VPS.
It has been migrated to another company's VPS and is in use.
nginix works fine and my node application works fine.
When the mongodb service is run as systemlctl stat
The following error code was shown and it became Active:Failed.
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-03-18 08:57:04 UTC; 3s ago
Docs: https://docs.mongodb.org/manual
Process: 3558 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=217/USER)
Main PID: 3558 (code=exited, status=217/USER)
Mar 18 08:57:04 user systemd[1]: Started MongoDB Database Server.
Mar 18 08:57:04 user systemd[1]: mongod.service: Main process exited, code=exited, status=217/USER
Mar 18 08:57:04 user systemd[1]: mongod.service: Unit entered failed state.
Mar 18 08:57:04 user systemd[1]: mongod.service: Failed with result 'exit-code'.
Below is my mongod.conf setting.
# 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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
In my system
mongod.conf Path
/etc/mongod.conf
mongodb DB path
/var/lib/mongodb
I'd appreciate it if you could let me know what I need to check.
The problem is probably with the account mongo is trying to launch with in your systemd mongod.service file. Check the user and group defined in the [Service] block are valid.

Error when configuring TLS/SSL for Mongodb

I have an existing MongoDB Instance on my server. I wanted to enable SSH for it. I edited the /etc/mongod.conf as follows and added the TLS Options
# 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:
# 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
tls:
mode: requireTLS
certificateKeyFile: /path/to/privatekey.pem
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Whenever I try to restart MongoDB by running sudo service mongod restart I face the following error:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2021-12-24 04:32:58 IST; 2s ago
Docs: https://docs.mongodb.org/manual
Process: 72902 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE) Main PID: 72902 (code=exited,
status=1/FAILURE)
Dec 24 04:32:58 tcp-server-1 systemd[1]: Started MongoDB Database
Server. Dec 24 04:32:58 tcp-server-1 systemd[1]: mongod.service: Main
process exited, code=exited, status=1/FAILURE Dec 24 04:32:58
tcp-server-1 systemd[1]: mongod.service: Failed with result
'exit-code'.
But if I comment out the TLS Options, then its working fine. What am I doing wrong?

Service mongod does not start on Centos8

I tried to install mongoDB on Centos8, but when I run the command
systemctl status mongod.service
I get this error:
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2020-08-01 14:26:53 CEST; 11min ago
Docs: https://docs.mongodb.org/manual
Process: 1875 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
Process: 1873 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 1871 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 1869 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Aug 01 14:26:53 db.localhost systemd[1]: Starting MongoDB Database Server...
Aug 01 14:26:53 db.localhost mongod[1875]: about to fork child process, waiting until server is ready for>
Aug 01 14:26:53 db.localhost mongod[1875]: forked process: 1877
Aug 01 14:26:53 db.localhost mongod[1875]: ERROR: child process failed, exited with 14
Aug 01 14:26:53 db.localhost mongod[1875]: To see additional information in this output, start without th>
Aug 01 14:26:53 db.localhost systemd[1]: mongod.service: Control process exited, code=exited status=14
Aug 01 14:26:53 db.localhost systemd[1]: mongod.service: Failed with result 'exit-code'.
Aug 01 14:26:53 db.localhost systemd[1]: Failed to start MongoDB Database Server.
I tried to check privileges for the folders: /var/lib/mongo and /var/log/mongodb
#/var/lib/
drwxr-xr-x. 4 mongod mongod 4096 Aug 1 14:44 mongo
#/var/log/
drwxr-xr-x. 2 mongod mongod 50 Aug 1 14:14 mongodb
In some other posts, people told to try this command:
sudo chown -R mongodb:mongodb /var/lib/mongodb/
but in don't have the user mongodb and I get the error: invalid user: 'mongodb:mongodb'!
In my /etc/passwd file the only user for mongo is this:
mongod:x:994:992:mongod:/var/lib/mongo:/bin/false
What's the problem?
Why I cannot run mongod.service?
Thanks for your support.
Added more informations:
systemctl cat mongod
[root#db tmp]# systemctl cat mongod
# /usr/lib/systemd/system/mongod.service
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target
[Service]
User=mongod
Group=mongod
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking
# 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 mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
[Install]
WantedBy=multi-user.target
mongod.conf
[root#db tmp]# cat /etc/mongod.conf
# ..
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
# engine:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
/usr/bin/mongod -f /etc/mongod.conf
[root#db mongodb]# /usr/bin/mongod -f /etc/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 1959
child process started successfully, parent exiting
For some kind of reason, mongod want the folder /data/db and ignore the file mongod.conf
After I created these folders, if I run mongod command (with sudo), programme start "correctly".
But if I reboot the system, the service fails on boot and continue to have problems.

Mongod Service exit code 2

My Problem
Hi there! When I tried to start and see status I've got an error.
skozurak#danny:~$ service mongod start
skozurak#danny:~$ 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 Tue 2020-07-14 17:54:33 CEST; 3s ago
Docs: https://docs.mongodb.org/manual
Process: 77503 ExecStart=/usr/bin/mongod --auth --config /etc/mongod.conf (code=exited, status=2)
Main PID: 77503 (code=exited, status=2)
Jul 14 17:54:33 danny systemd[1]: Started MongoDB Database Server.
Jul 14 17:54:33 danny mongod[77503]: Error parsing YAML config file: yaml-cpp: error at line 32, col>
Jul 14 17:54:33 danny mongod[77503]: try '/usr/bin/mongod --help' for more information
Jul 14 17:54:33 danny systemd[1]: mongod.service: Main process exited, code=exited, status=2/INVALID>
Jul 14 17:54:33 danny systemd[1]: mongod.service: Failed with result 'exit-code'.
lines 1-12/12 (END)
What I did
Tried to reinstall
Tried to install different versions
Then I added the service to be able to run on server startup.
skozurak#danny:~$ systemctl enable mongod.service
I think that problem is in the config file. But I do not know how to fix it there.
skozurak#danny:~$ sudo nano /etc/mongod.conf
# mongod.conf
# 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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
I just changed one line of config as I saw here
skozurak#danny:~$ sudo nano /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 --auth --config /etc/mongod.conf #i changed this line
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 mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
[Install]
WantedBy=multi-user.target
Your error lies here:
security:
authorization: enabled
You can't use any other indentation than exactly 2 spaces.

Mongodb not starting as normal user

My MongoDB server is not starting on command mongod
Typing sudo service mongodb status yeilds
mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2017-11-28 20:08:25 IST; 2s ago
Process: ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 29675 (code=exited, status=1/FAILURE)
System service:
#/etc/systemd/system/mongodb.service
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
mongod conf:
#/etc/mongod.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
However if i am running sudo -u mongodb mongod --config /etc/mongod.conf it runs.
Also if I run sudo mongod the server tries to start but the storage path is /data/db/ which I haven't created.
mongod --config /etc/mongod.conf gives the below error
[main] Failed global initialization: FileNotOpen: Failed to open "/var/log/mongodb/mongod.log"
I had run chown -R mongodb:mongodb /var/lib/mongodb
Permissions:
-rw-r--r-- 1 mongodb mongodb 4096 Nov 28 20:19 /var/log/mongodb/mongod.log
drwxr-xr-x 4 mongodb mongodb 20480 Nov 28 21:32 /var/lib/mongodb
Now whenever I need MongoDB server I have to run it with sudo mongod --dbpath /var/lib/mongodb/
It seems like a permission issue for me. But I cannot figure how to fix this out?