4
votes

I was just learning mongodb. I command I entered are :

use admin db.shutdownServer();

This shutdown the database. After that whenever I'm writing mongo to start mongoDB it gives me :

MongoDB shell version: 3.0.12 connecting to: test 2016-10-09T18:24:27.661+0530 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused 2016-10-09T18:24:27.664+0530 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at connect (src/mongo/shell/mongo.js:179:14) at (connect):1:6 at src/mongo/shell/mongo.js:179 exception: connect failed

When I run this : sudo service mongodb start

I get :

Redirecting to /bin/systemctl start mongodb.service Failed to start mongodb.service: Unit mongodb.service failed to load: No such file or directory.

I tried other different commands (even I've re installed it again) but none of them restarted mongodb.

How to start mongodb?

2
Are you sure you are running MongoDB as service?Saleem
@Saleem yes ...Ayushi bhardwaj

2 Answers

2
votes

shut down the node

:SECONDARY> db.shutdownServer()

up

:~$ mongod --config /db/mongod-repl-2.conf
:SECONDARY> rs.slaveOk()
:SECONDARY> show dbs
admin         0.000GB
config        0.000GB
local         0.000GB
testDatabase  0.000GB
0
votes

You need to fork your service again, Try

mongod --dbpath /var/lib/mongo/ --fork --logpath /var/log/mongodb/mongod.log