1
votes

After install mongodb on CentOS, I'm typingthe command systemctl status mongod, but the following problem appears (also see picture):

systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) 02-28 20:17:01 CST; Process: 3558 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2) Process: 3556 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 3554 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 3547 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Thank you so much for reading my problem. If you can help me solve the problem, I will appreciate it very much. Figure

1
systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) 02-28 20:17:01 CST; Process: 3558 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2) Process: 3556 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 3554 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 3547 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)vegazhang

1 Answers

1
votes

This happends often when you started the service as a different user. Follow this: - try first stoping the service.

sudo systemctl stop mongod

  • then remove this file:

sudo rm /tmp/mongodb-27017.sock

  • restart mongodb service

    sudo systemctl start mongod


if that doesnt do it, i would suggest to remove mongodb and follow this guide: (it worked for me perfectly on CentOS 7)

try installing mongodb like this:

  • Create a /etc/yum.repos.d/mongodb-org-4.2.repo file so that you can install MongoDB directly using yum:
sudo vi /etc/yum.repos.d/mongodb-org.repo
  • Paste this inside the mongodb-org.repo
 [mongodb-org-4.2]
     name=MongoDB Repository
     baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
     gpgcheck=1
     enabled=1
     gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
  • verify that the MongoDB repository exists
yum repolist
  • Installing mongodb
sudo yum install mongodb-org
  • Start the mongodb service:
sudo systemctl start mongod
  • The reload command requests that the mongod process reads the configuration file, /etc/mongod.conf, and applies any changes without requiring a restart
sudo systemctl reload mongod
  • try access the database server with the MongoDB Shell:

mongo


this helped me allot on centos7, let me know if you need anything else. cheers, Radi