Database Administrators Asked by jack jack on February 12, 2021
I have Mongo installed on Ubuntu 16.04 machine, on VMWare. I start it using “mongo” command, last week there was no problem. But recently, it gives this error:
MongoDB shell version: 3.2.15
connecting to: test
2017-08-09T09:31:33.634+0300 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-08-09T09:31:33.712+0300 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6
exception: connect failed
I know how to solve it, it is here: https://stackoverflow.com/questions/12831939/couldnt-connect-to-server-127-0-0-127017/34835813#34835813
But everytime I reboot Ubuntu machine, the problem repeats. Why, and how can I prevent this happen everytime?
Thanks.
Edit: Problem solved. You can see the solution below, in my comments to JJussi’s answer.
As MongoDB BOL Here The MongoDB instance stores its data files in /var/lib/mongodb
and its log files
in /var/log/mongodb
by default, and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf
.
If you change the user that runs the MongoDB
process, you must modify the access control rights to the /var/lib/mongodb
and /var/log/mongodb
directories to give this user access to these directories.
Issue the following command to start mongod:
sudo service mongod start
For your further ref Configuration File Options
Answered by Md Haidar Ali Khan on February 12, 2021
mongod
is actual mongodb daemon what "is" the database. mongo
is just client program what connects to mongod process (in this case; with sharded cluster it connects to mongos -process).
So, mongod
process must be running before mongo
can connect it.
You wrote that sudo systemctl enable mongod.service
don't work anymore? Check if that service has (some how) changed its name. Just give command sudo systemctl|grep -i mongo
and you can see if it is there and it is enabled. IF still your mongod process don't start automatically after reboot, check /var/log/mongodb/mongodb.log (you can check that lock file name with sudo grep path /etc/mongod.conf
-command) says. What is the error? Fix that error (maybe chown of directory and files?) and try again with sudo systemctl restart mongod.service
(or what ever is services name)
Answered by JJussi on February 12, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP