Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo service start or restart always fail

I've installed mongodb then I've created a mongo 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

But When I launch the service and then I check the status, I get always this error:

● 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 Mon 2017-04-24 13:08:55 UTC; 6min ago
  Process: 1094 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=48)
 Main PID: 1094 (code=exited, status=48)

Apr 24 13:08:54 ip-172-31-37-163 systemd[1]: Started High-performance, schema-free document-oriented database.
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Main process exited, code=exited, status=48/n/a
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Unit entered failed state.
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Failed with result 'exit-code'.
like image 550
Chlebta Avatar asked Apr 24 '17 13:04

Chlebta


People also ask

Why MongoDB server is not starting?

We found that the reason for this error was the dbpath variable in /etc/mongodb. conf. Previously, the default value for dbpath was /data/db. The upstart job mongodb(which comes with mongodb-10gen package) invokes the mongod with –config /etc/mongodb.


2 Answers

The problem was in config file and changing

bindIp: 127.0.0.1, X.X.X.X

to

bindIp: [127.0.0.1, X.X.X.X]

Solved my issue

like image 76
Chlebta Avatar answered Oct 24 '22 07:10

Chlebta


Try changing the owner permissions

chown -R mongodb:mongodb /var/lib/mongodb

chown mongodb:mongodb /tmp/mongodb-27017.sock

like image 4
savio rajan k Avatar answered Oct 24 '22 05:10

savio rajan k