cannot restart mongodb on ubuntu after crash

Viewed 170

so I have recently collected about 5GB of data in a mongodb on my pi. At some point, the pi crashed, because the disk space was used up. As I found, the reason was not the size of the collections themselves, but rather an immensely large mongod.log file (about 100GB). I deleted the log file and wanted to insert the quiet option to the mongod.conf, in order to reduce the logging output. After that, I tried to restart mongod service, but it does not work. Firstly, here is my current conf file:


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

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

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1, localhost, 192.168.1.XXX

# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo´

I removed the quiet option again. (the address in bindIp is replaced by XXX here) Here is the content of my mongod.log file, after trying to start the service:

{"t":{"$date":"2022-05-25T12:51:02.196+02:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-05-25T12:51:02.249+02:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-05-25T12:51:02.249+02:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFa>{"t":{"$date":"2022-05-25T12:51:02.250+02:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":18742,"port":27017,"dbPath":"/var/lib/mongodb","architecture":"64-bit","ho>{"t":{"$date":"2022-05-25T12:51:02.251+02:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.14","gitVersion":"0b0843af97c3ec9d2c0995152d96d2aad725aab7>{"t":{"$date":"2022-05-25T12:51:02.251+02:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"21.10"}}}
{"t":{"$date":"2022-05-25T12:51:02.251+02:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/etc/mongod.conf","net":{"bindIp":"0.0.0.0, loca>{"t":{"$date":"2022-05-25T12:51:02.253+02:00"},"s":"I",  "c":"STORAGE",  "id":22270,   "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/var/lib/mongodb","storageEngine":"wiredTi>{"t":{"$date":"2022-05-25T12:51:02.253+02:00"},"s":"I",  "c":"STORAGE",  "id":22297,   "ctx":"initandlisten","msg":"Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mon>{"t":{"$date":"2022-05-25T12:51:02.253+02:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=3367M,session_max=33000,eviction=(threads_min=4,th>{"t":{"$date":"2022-05-25T12:51:03.976+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475863:976838][18742:0xffff86226030], txn-recover: [WT_VERB_RE>{"t":{"$date":"2022-05-25T12:51:04.330+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475864:330397][18742:0xffff86226030], txn-recover: [WT_VERB_RE>{"t":{"$date":"2022-05-25T12:51:04.883+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475864:883892][18742:0xffff86226030], txn-recover: [WT_VERB_RE>{"t":{"$date":"2022-05-25T12:51:05.548+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475865:548679][18742:0xffff86226030], txn-recover: [WT_VERB_RE>{"t":{"$date":"2022-05-25T12:51:05.906+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475865:906939][18742:0xffff86226030], txn-recover: [WT_VERB_RE>{"t":{"$date":"2022-05-25T12:51:06.240+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475866:240582][18742:0xffff86226030], txn-recover: [WT_VERB_RE>{"t":{"$date":"2022-05-25T12:51:06.240+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475866:240759][18742:0xffff86226030], txn-recover: [WT_VERB_RE>{"t":{"$date":"2022-05-25T12:51:06.251+02:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1653475866:251752][18742:0xffff86226030], WT_SESSION.checkpoint: [>{"t":{"$date":"2022-05-25T12:51:06.282+02:00"},"s":"I",  "c":"STORAGE",  "id":4795906, "ctx":"initandlisten","msg":"WiredTiger opened","attr":{"durationMillis":4029}}
{"t":{"$date":"2022-05-25T12:51:06.282+02:00"},"s":"I",  "c":"RECOVERY", "id":23987,   "ctx":"initandlisten","msg":"WiredTiger recoveryTimestamp","attr":{"recoveryTimestamp":{"$timestamp":{"t":0,"i":0}}}}
{"t":{"$date":"2022-05-25T12:51:06.290+02:00"},"s":"I",  "c":"STORAGE",  "id":4366408, "ctx":"initandlisten","msg":"No table logging settings modifications are required for existing WiredTiger tables","attr":{"loggingEnabl>{"t":{"$date":"2022-05-25T12:51:06.296+02:00"},"s":"I",  "c":"STORAGE",  "id":22262,   "ctx":"initandlisten","msg":"Timestamp monitor starting"}
{"t":{"$date":"2022-05-25T12:51:06.303+02:00"},"s":"W",  "c":"CONTROL",  "id":22120,   "ctx":"initandlisten","msg":"Access control is not enabled for the database. Read and write access to data and configuration is unrestr>{"t":{"$date":"2022-05-25T12:51:06.318+02:00"},"s":"I",  "c":"STORAGE",  "id":20536,   "ctx":"initandlisten","msg":"Flow Control is enabled on this deployment"}
{"t":{"$date":"2022-05-25T12:51:06.326+02:00"},"s":"I",  "c":"FTDC",     "id":20625,   "ctx":"initandlisten","msg":"Initializing full-time diagnostic data capture","attr":{"dataDirectory":"/var/lib/mongodb/diagnostic.data">{"t":{"$date":"2022-05-25T12:51:06.328+02:00"},"s":"I",  "c":"REPL",     "id":6015317, "ctx":"initandlisten","msg":"Setting new configuration state","attr":{"newState":"ConfigReplicationDisabled","oldState":"ConfigPreStart>{"t":{"$date":"2022-05-25T12:51:06.332+02:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"/tmp/mongodb-27017.sock"}}
{"t":{"$date":"2022-05-25T12:51:06.333+02:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"0.0.0.0"}}
{"t":{"$date":"2022-05-25T12:51:06.333+02:00"},"s":"F",  "c":"NETWORK",  "id":31339,   "ctx":"listener","msg":"Error listening for new connections on listen address","attr":{"listenAddrs":"127.0.0.1:27017","error":"Address>{"t":{"$date":"2022-05-25T12:51:06.333+02:00"},"s":"F",  "c":"-",        "id":23089,   "ctx":"listener","msg":"Fatal assertion","attr":{"msgid":31339,"file":"src/mongo/transport/transport_layer_asio.cpp","line":1071}}
{"t":{"$date":"2022-05-25T12:51:06.333+02:00"},"s":"F",  "c":"-",        "id":23090,   "ctx":"listener","msg":"\n\n***aborting after fassert() failure\n\n"}
{"t":{"$date":"2022-05-25T12:51:06.333+02:00"},"s":"F",  "c":"CONTROL",  "id":4757800, "ctx":"listener","msg":"Writing fatal message","attr":{"message":"Got signal: 6 (Aborted).\n"}}
{"t":{"$date":"2022-05-25T12:51:06.367+02:00"},"s":"I",  "c":"CONTROL",  "id":31431,   "ctx":"listener","msg":"BACKTRACE: {bt}","attr":{"bt":{"backtrace":[{"a":"AAAAE878C544","b":"AAAAE5D70000","o":"2A1C544"},{"a":"AAAAE87>{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"AAAAE878C544","b":"AAAAE5D70000","o":"2A1C544"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"AAAAE878E39C","b":"AAAAE5D70000","o":"2A1E39C","s":"_ZN5mongo15printSta>{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"AAAAE878B57C","b":"AAAAE5D70000","o":"2A1B57C"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"FFFF873337DC","b":"FFFF87333000","o":"7DC","s":"__kernel_rt_sigreturn",>{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"FFFF86CEC344","b":"FFFF86C6D000","o":"7F344"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"FFFF86CA71BC","b":"FFFF86C6D000","o":"3A1BC","s":"raise","s+":"1C"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"FFFF86C93F70","b":"FFFF86C6D000","o":"26F70","s":"abort","s+":"E4"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"AAAAE6A1EC48","b":"AAAAE5D70000","o":"CAEC48","s":"_ZN5mongo42fassertFa>{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"AAAAE8187064","b":"AAAAE5D70000","o":"2417064","s":"_ZN5mongo9transport>{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"AAAAE81871AC","b":"AAAAE5D70000","o":"24171AC"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"AAAAE890FD7C","b":"AAAAE5D70000","o":"2B9FD7C"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"FFFF86CEA69C","b":"FFFF86C6D000","o":"7D69C"}}}
{"t":{"$date":"2022-05-25T12:51:06.368+02:00"},"s":"I",  "c":"CONTROL",  "id":31427,   "ctx":"listener","msg":"  Frame: {frame}","attr":{"frame":{"a":"FFFF86D52D1C","b":"FFFF86C6D000","o":"E5D1C"}}}

And I basically have no idea what it means xD.

I followed some other solutions in forums and tried the following:

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo chown -R mongodb:mongodb /etc/mongod.conf

(my user name on the pi is "jc". should I use that instead?) I checked the folder and file permissions using ls -al.

Also, I tried deleting the .sock files. Nothing helped so far when trying to restart the service:

sudo service mongod start
service mongod start

When running the service start without sudo, I am asked to authenticate with my pw, with sudo not. In both cases, the service doesn't run afterwards.

When typing: sudo mongod -f /etc/mongod.conf and launching another terminal, typing:

mongo

launches the shell:

MongoDB shell version v4.4.14
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("b47500ef-d070-4a84-bbdf-4d520b353773") }
MongoDB server version: 4.4.14
---
The server generated these startup warnings when booting:
        2022-05-25T13:23:28.592+02:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
        2022-05-25T13:23:32.743+02:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
        2022-05-25T13:23:32.743+02:00: You are running this process as the root user, which is not recommended
        2022-05-25T13:23:32.744+02:00: Soft rlimits too low
        2022-05-25T13:23:32.744+02:00:         currentValue: 1024
        2022-05-25T13:23:32.744+02:00:         recommendedMinimum: 64000

So, it seems mongodb can run fine, but not as a service. I reckon it is still a user permission issue, cause I heard that a lot in other comments?

If nothing helps, I could also reinstall, but would that be possible without deleting the collections entirely? That would be crucial.

In the worst case, I could also keep open the terminal with the inline mongo launch command and continue using the database, right? I basically never shut down that pc, so it would be ok as a bad solution. But since it has worked nicely as a service before, I am sure this can be solved.

Thanks!

Best, JZ

1 Answers

Okay, I now stumbled across a solution: inside the folder /lib/systemd/system/ there is the file mongod.service. Inside the file, change user and group to root instead of mongodb. Then, reload the daemon processes:

systemctl daemon-reload

Finally: sudo service mongod start does the job.

user@pc:/lib/systemd/system$ sudo systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-05-25 16:59:09 CEST; 20s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 21173 (mongod)
     Memory: 157.4M
        CPU: 4.646s
     CGroup: /system.slice/mongod.service
             └─21173 /usr/bin/mongod --config /etc/mongod.conf

The only issue is that now I am running this as a root user, as indicated by the shell startup warning:

You are running this process as the root user, which is not recommended

So, I guess it is a folder permission issue after all. If someone knows a solution how to adapt this to mongodb as user, please shoot it.

Related