I have VPS with Ubuntu 18.04 LTS
with Mongodb
and my script was working until 3 days ago fine, but suddenly my hosting server was rebooted (I purchased it from a hosting company) and when my server was boot again, I saw my website was not working and did not connect to database. The result of systemctl status mongod
is:
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-10-29 22:47:35 +0330; 17h ago
Docs: https://docs.mongodb.org/manual
Process: 2800 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
Main PID: 2800 (code=exited, status=14)
Oct 29 22:47:35 MYHOSTNAME systemd[1]: Started MongoDB Database Server.
Oct 29 22:47:35 MYHOSTNAME systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Oct 29 22:47:35 MYHOSTNAME systemd[1]: mongod.service: Failed with result 'exit-code'.
When I restart the service, nothing happens. I checked /var/log/mongodb/mongod.log
and this is the log:
2020-10-30T15:53:39.251+0330 I REPL [signalProcessingThread] Stepping down the ReplicationCoordinator for shutdown, waitTime: 10000ms
2020-10-30T15:53:39.458+0330 I CONTROL [signalProcessingThread] Shutting down the LogicalSessionCache
2020-10-30T15:53:39.460+0330 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2020-10-30T15:53:39.460+0330 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2020-10-30T15:53:39.461+0330 I NETWORK [signalProcessingThread] Shutting down the global connection pool
2020-10-30T15:53:39.461+0330 I STORAGE [signalProcessingThread] Shutting down the PeriodicThreadToAbortExpiredTransactions
2020-10-30T15:53:39.462+0330 I REPL [signalProcessingThread] Shutting down the ReplicationCoordinator
2020-10-30T15:53:39.462+0330 I SHARDING [signalProcessingThread] Shutting down the ShardingInitializationMongoD
2020-10-30T15:53:39.463+0330 I COMMAND [signalProcessingThread] Killing all open transactions
2020-10-30T15:53:39.463+0330 I - [signalProcessingThread] Killing all operations for shutdown
2020-10-30T15:53:39.463+0330 I NETWORK [signalProcessingThread] Shutting down the ReplicaSetMonitor
2020-10-30T15:53:39.463+0330 I CONTROL [signalProcessingThread] Shutting down free monitoring
2020-10-30T15:53:39.464+0330 I CONTROL [signalProcessingThread] Shutting down free monitoring
2020-10-30T15:53:39.466+0330 I FTDC [signalProcessingThread] Shutting down full-time data capture
2020-10-30T15:53:39.466+0330 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2020-10-30T15:53:39.470+0330 I STORAGE [signalProcessingThread] Shutting down the HealthLog
2020-10-30T15:53:39.471+0330 I STORAGE [signalProcessingThread] Shutting down the storage engine
2020-10-30T15:53:39.472+0330 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2020-10-30T15:53:39.472+0330 I STORAGE [signalProcessingThread] Shutting down session sweeper thread
2020-10-30T15:53:39.472+0330 I STORAGE [signalProcessingThread] Finished shutting down session sweeper thread
2020-10-30T15:53:39.648+0330 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2020-10-30T15:53:39.648+0330 I - [signalProcessingThread] Dropping the scope cache for shutdown
2020-10-30T15:53:39.648+0330 I CONTROL [signalProcessingThread] now exiting
2020-10-30T15:53:39.648+0330 I CONTROL [signalProcessingThread] shutting down with code:0
I did telnet localhost 27017
and it works fine and connects (it's closed for remote connections).
I removed /tmp/mongodb-27017.sock
manually, checked ownership of /var/log/mongodb
and /var/lib/mongodb
and everything is correct. I also did chown -R mongodb:mongodb
on both folders to correct them if any incorrect ownership has happened during sudden reboot, but nothing worked.
By the way, when I run /usr/bin/mongod --config /etc/mongod.conf
command, my website runs, I can login to my user account and etc. I am currently doing this in a screen
to run my website currently, but I do not know how to find the problem and fix it.
Would you help me to check what's wrong with MongoDB and how to fix it? Also like nginx -t
that tests config file, is there any similar command? I read man mongod
but found nothing.
edited to add /etc/mongodb.conf
contents:
# 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:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Try this, it worked for me:
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With