0
votes

After i ran mongorestore the mongo service fail to start automatically, But if i open the terminal and run mongod the service is running perfectlly. if i close the terminal i get. Any suggestions?

Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79

when i'm running the mongod i get:

MongoDB starting : pid=1875 port=27017 dbpath=/data/db/ 64-bit Thu Jul 25 12:16:40 [initandlisten] db version v1.8.2, pdfile version 4.5 Thu Jul 25 12:16:40 [initandlisten] git version: nogitversion Thu Jul 25 12:16:40 [initandlisten] build sys info: Linux allspice 2.6.24-28-server #1 SMP Wed Aug 18 21:17:51 UTC 2010 x86_64 BOOST_LIB_VERSION=1_46_1 Thu Jul 25 12:16:40 [initandlisten] * warning: spider monkey build without utf8 support. consider rebuilding with utf8 support Thu Jul 25 12:16:40 [initandlisten] waiting for connections on port 27017 Thu Jul 25 12:16:40 [websvr] web admin interface listening on port 28017 Thu Jul 25 12:17:05 [initandlisten] connection accepted from 127.0.0.1:38257 #1

3
check the /data/mongodb/mongod.lock file, mongodb cannot start if there is oneVitaly Muminov
already deleted it few times it doesn't solve the issueLiad Livnat
try to execute mongod --config=/path/to/your/config (/etc/mongodb.conf by default) from shell and check the mongodb log after executionVitaly Muminov
log says exception in initAndListen std::exception: Unable to acquire lock for lockfilepath: /data/db/mongod.lock, but i'm deleteing the mongod.lock file and it happens gainLiad Livnat
do you have permissions to delete lock file? check if file still exists after you delete it; also path seems to be not /data/mongodb/mongod.lock but /data/db/mongod.lockVitaly Muminov

3 Answers

3
votes

Well, there's not much information to go on, but the usual check list is:

  • check mongodb's logs, see if it reports anything odd (like a failure to start or a shutdown when there should be none).
  • make sure mongodb is actually scheduled to be started automatically - if it's not, there's nothing surprising about it not running.
  • EDIT: I forgot to mention the MongoDB lock file, but I see you already covered that.

If it's meant to run but doesn't and doesn't log anything, it would suggest that it was shut down sometime after your computer was booted up and you need to restart it.

Calling mongod starts the server, but not in daemon mode - killing the shell in which it runs will kill the process. I'm sure there's a wealth of documentation about starting MongoDB in daemon mode.

1
votes

Well, no one figure out how to do it so the solution was chown -R mongodb /data/db it was an ownership issue thanks all

0
votes

Well,that's probably because you have created the mongod.service file not mongo.service file in systemd/ . Thus it reads that as a command and act as a service launching command. My answer is based on your title of the question