Mongodb 6 does not start service on centOs 7

Good night usingcentos 7 with mongodb 6.
I can’t get it to work at all.
Can you help me?
I’m a beginner so please be patient

systemctl status mongodb.service

● mongodb.service - An object/document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2023-01-17 19:27:24 -03; 4min 18s ago
     Docs: man:mongod(1)
  Process: 2205 ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf (code=exited, status=217/USER)
 Main PID: 2205 (code=exited, status=217/USER)

Jan 17 19:27:24 localhost.localdomain systemd[1]: Started An object/document-oriented database.
Jan 17 19:27:24 localhost.localdomain systemd[2205]: Failed at step USER spawning /usr/bin/mongod: No such process
Jan 17 19:27:24 localhost.localdomain systemd[1]: mongodb.service: main process exited, code=exited, status=217/USER
Jan 17 19:27:24 localhost.localdomain systemd[1]: Unit mongodb.service entered failed state.
Jan 17 19:27:24 localhost.localdomain systemd[1]: mongodb.service failed.
[root@localhost /]# systemctl daemon-reload
[root@localhost /]# systemctl status mongodb.service
● mongodb.service - An object/document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2023-01-17 19:27:24 -03; 5min ago
     Docs: man:mongod(1)
 Main PID: 2205 (code=exited, status=217/USER)

Jan 17 19:27:24 localhost.localdomain systemd[1]: Started An object/document-oriented database.
Jan 17 19:27:24 localhost.localdomain systemd[2205]: Failed at step USER spawning /usr/bin/mongod: No such process
Jan 17 19:27:24 localhost.localdomain systemd[1]: mongodb.service: main process exited, code=exited, status=217/USER
Jan 17 19:27:24 localhost.localdomain systemd[1]: Unit mongodb.service entered failed state.
Jan 17 19:27:24 localhost.localdomain systemd[1]: mongodb.service failed.

mongod

{"t":{"$date":"2023-01-17T19:46:09.304-03:00"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"-","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2023-01-17T19:46:09.305-03:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"-","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2023-01-17T19:46:09.306-03:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2023-01-17T19:46:09.308-03:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}}
{"t":{"$date":"2023-01-17T19:46:09.308-03:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2023-01-17T19:46:09.308-03:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2023-01-17T19:46:09.309-03:00"},"s":"I",  "c":"CONTROL",  "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
{"t":{"$date":"2023-01-17T19:46:09.309-03:00"},"s":"I",  "c":"CONTROL",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":2248,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"localhost.localdomain"}}
{"t":{"$date":"2023-01-17T19:46:09.309-03:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"6.0.3","gitVersion":"f803681c3ae19817d31958965850193de067c516","openSSLVersion":"OpenSSL 1.0.1e-fips 11 Feb 2013","modules":[],"allocator":"tcmalloc","environment":{"distmod":"rhel70","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2023-01-17T19:46:09.309-03:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"CentOS Linux release 7.9.2009 (Core)","version":"Kernel 3.10.0-1160.81.1.el7.x86_64"}}}
{"t":{"$date":"2023-01-17T19:46:09.309-03:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2023-01-17T19:46:09.310-03:00"},"s":"E",  "c":"NETWORK",  "id":23024,   "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}}
{"t":{"$date":"2023-01-17T19:46:09.310-03:00"},"s":"F",  "c":"ASSERT",   "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":1125}}
{"t":{"$date":"2023-01-17T19:46:09.310-03:00"},"s":"F",  "c":"ASSERT",   "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

mongo

-bash: mongo: command not found 

You have to use mongosh with latest versions of mongodb
Just issue mongosh and see if you can connect(assuming you already have a mongod up & running)
Regarding errors while starting mongod it appears to be permissions issues
Also your prompt indicates you tried to start it as root
Do not start mongod as root.Bring it up as normal user and use sudo privileges wherever you need root privs like to start service,create dir etc
Also check ownership/permissions on that TMP sock file

How do I check ownership/permissions of that TMP sock file?

Now it’s like this

mongosh
Current Mongosh Log ID: 63c8617aa251ba8aa3ee901a
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.2
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017

sudo service mongod start
Redirecting to /bin/systemctl start mongod.service
Job for mongod.service failed because the control process exited with error code. See “systemctl status mongod.service” and “journalctl -xe” for details.

I’m trying to access via ssh
mongodb on centOs server 7
me on pc fedora 37 with vscode

On your Centos machine check this
ls -lrt /tmp/mongodb-27017.sock

1 Like

ls -lrt /tmp/mongodb-27017.sock
srwx------. 1 william william 0 Jan 18 19:07 /tmp/mongodb-27017.sock

/var/lib/mongo ls -l
drwxr-xr-x. 2 mongod mongod 6 Nov 14 16:44 mongo

sudo tail /var/log/mongodb/mongod.log
{“t”:{"$date":“2023-01-19T09:07:50.054-03:00”},“s”:“I”, “c”:“REPL”, “id”:5123008, “ctx”:“main”,“msg”:“Successfully registered PrimaryOnlyService”,“attr”:{“service”:“TenantMigrationRecipientService”,“namespace”:“config.tenantMigrationRecipients”}}
{“t”:{"$date":“2023-01-19T09:07:50.054-03:00”},“s”:“I”, “c”:“REPL”, “id”:5123008, “ctx”:“main”,“msg”:“Successfully registered PrimaryOnlyService”,“attr”:{“service”:“ShardSplitDonorService”,“namespace”:“config.tenantSplitDonors”}}
{“t”:{"$date":“2023-01-19T09:07:50.054-03:00”},“s”:“I”, “c”:“CONTROL”, “id”:5945603, “ctx”:“main”,“msg”:“Multi threading initialized”}
{“t”:{"$date":“2023-01-19T09:07:50.054-03:00”},“s”:“I”, “c”:“CONTROL”, “id”:4615611, “ctx”:“initandlisten”,“msg”:“MongoDB starting”,“attr”:{“pid”:2124,“port”:27017,“dbPath”:"/var/lib/mongo",“architecture”:“64-bit”,“host”:“localhost.localdomain”}}
{“t”:{"$date":“2023-01-19T09:07:50.054-03:00”},“s”:“I”, “c”:“CONTROL”, “id”:23403, “ctx”:“initandlisten”,“msg”:“Build Info”,“attr”:{“buildInfo”:{“version”:“6.0.3”,“gitVersion”:“f803681c3ae19817d31958965850193de067c516”,“openSSLVersion”:“OpenSSL 1.0.1e-fips 11 Feb 2013”,“modules”:,“allocator”:“tcmalloc”,“environment”:{“distmod”:“rhel70”,“distarch”:“x86_64”,“target_arch”:“x86_64”}}}}
{“t”:{"$date":“2023-01-19T09:07:50.054-03:00”},“s”:“I”, “c”:“CONTROL”, “id”:51765, “ctx”:“initandlisten”,“msg”:“Operating System”,“attr”:{“os”:{“name”:“CentOS Linux release 7.9.2009 (Core)”,“version”:“Kernel 3.10.0-1160.81.1.el7.x86_64”}}}
{“t”:{"$date":“2023-01-19T09:07:50.054-03:00”},“s”:“I”, “c”:“CONTROL”, “id”:21951, “ctx”:“initandlisten”,“msg”:“Options set by command line”,“attr”:{“options”:{“config”:"/etc/mongod.conf",“net”:{“bindIp”:“127.0.0.1”,“port”:27017},“processManagement”:{“fork”:true,“pidFilePath”:"/var/run/mongodb/mongod.pid",“timeZoneInfo”:"/usr/share/zoneinfo"},“storage”:{“dbPath”:"/var/lib/mongo",“journal”:{“enabled”:true}},“systemLog”:{“destination”:“file”,“logAppend”:true,“path”:"/var/log/mongodb/mongod.log"}}}}
{“t”:{"$date":“2023-01-19T09:07:50.055-03:00”},“s”:“E”, “c”:“NETWORK”, “id”:23024, “ctx”:“initandlisten”,“msg”:“Failed to unlink socket file”,“attr”:{“path”:"/tmp/mongodb-27017.sock",“error”:“Operation not permitted”}}
{“t”:{"$date":“2023-01-19T09:07:50.055-03:00”},“s”:“F”, “c”:“ASSERT”, “id”:23091, “ctx”:“initandlisten”,“msg”:“Fatal assertion”,“attr”:{“msgid”:40486,“file”:“src/mongo/transport/transport_layer_asio.cpp”,“line”:1125}}
{“t”:{"$date":“2023-01-19T09:07:50.055-03:00”},“s”:“F”, “c”:“ASSERT”, “id”:23092, “ctx”:“initandlisten”,“msg”:"\n\n***aborting after fassert() failure\n\n"}

Remove TMP file and try to start mongod again
sudo systemctl start mongod
Check mongodb documentation for Centos