MongoDB Failing to Start - *** - mongodb

I have configured mongodb with yu on linux.
enabled systemctl enable mongod.service as well, when ever exit do ctrl+c,
systemctl status mongod.service status is failed
mongod --port 27017 says connecting.. but status is still failed.
netstat show port 27017 is listening
any suggestions?
db version 3.2.4, in rc.d/init.d not able to find mondo script, for chkconfig mongod on

Related

Cannot run mongod.service and therefore cannot connect to mongo

I accidentally killed my mongo local server, so every time I want to connect I have to run this command:
mongod --port 27017 --dbpath /var/lib/mongodb --logpath /var/log/mongod.log
How can I run it automatically?
I'm missing for some reason the mongod.service file, so I cannot run systemctl start mongod.
If anyone can please provide a solution (or the missing file) it will be helpful.
If you run this, I think the service will be modified and restored.
sudo systemctl enable mongod
Then run it again.
sudo service mongod restart

MongoDB in Linux Mint 19

I am trying to use mongoDB in Linux mint 19. But I am getting below error.
What is the solution ?
You're starting the mongo shell client, which by default tries to connect to a mongod server running on localhost and listening on port 27017. However, there is no server listening there so the mongo shell notes that and exits.
You'll need to investigate why there was no mongod server listening there:
The MongoDB Server package isn't installed
You're specifying a non-default port in e.g. /etc/mongod.conf
The mongod process/service is not running
...
First verify that the Server package is installed:
sudo dpkg -l | grep -i ".*mongodb.*server"
Then check the status of the mongod service and go from there. That will tell you if it's running, what port it's listening on, what config file is used, etc.
sudo systemctl status mongod
If it's not running then try to start it:
sudo systemctl start mongod
If it's still not running then look at the log messages:
sudo journalctl -u mongod.service

mongodb error. how can I solve the erro in mongoDB?

MongoDB shell version: 3.2.6
connecting to: test
2016-05-08T10:46:12.023+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-05-08T10:46:12.023+0530 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
https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/
Do you have the mongodb service running? Run sudo service mongod status and see what it returns. If it is stopped, run sudo service mongod start to start the mongodb and try connecting to it.
You can also, check whether the mongodb is listening on 27017 or not by running: sudo netstat -lnp | grep 27017.
If sudo service mongod start is giving a error, you may need to check the configuration. We can help you better if you can post the output of the above commands.
Update:
Create the file /etc/systemd/system/mongod.service with the following content:
[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
Just restart the service in terminal, verbose mode helps you to understand the background configuration
$brew services restart mongodb --verbose
and open another terminal (don't use same terminal) and type mongod, you should be able to see process running.
Excuse have the same problem . Just installed Ubuntu 16.04 LTS . The installation process , the same as in the official website of mongo . When I do:
sudo service mongod status; appear
● mongod.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
I guess the error will be in the configuration of "data directory" and the port, but not as configure it properly
Fork your mongodb process as a daemon so that it keeps running in background. E.g
./mongod --port 27017 --dbpath /home/db_directory --logpath /logs/mongod.log --fork

Mongo Shell couldn't connect to the local server

I'm starting MongoDB using the following command:
sumeet#sumeet-acer:~$ sudo service mongod start
I get a reply as:
mongod start/running, process 7209
sumeet#sumeet-acer:~$
But when I try to enter MongoDB shell by typing mongo I get the following error:
sumeet#sumeet-acer:~$ mongo
MongoDB shell version: 2.0.4
connecting to: test
Fri Jun 12 14:01:59 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
By default, mongod and mongos use the 27017 port. Without any option, the client will try to connect to a server running on localhost and listening at that port.
A few general advices here:
check if the mongod server is really running (ps -edf | grep mongod);
check if it uses the default port (look in the config file1, or use nmap localhost -p0-65535 or netstat | grep 27017);
if mongod is not running, check in the log2 for clues about what goes wrong.
1 /etc/mongodb.conf (on Debian-like systems at least)
2 /var/log/mongodb (on Debian-like systems at least)
The default IP and Port for MongoDB is 127.0.0.1 & 27017.
If you are using config file for specifying settings than re-verify IP & Port mentioned in it.
If you are going with default option than mongod should function as expected.
try mongo 127.0.0.1:27017
this worked for me
For MongoDB 2.2.2 running on Ubuntu 12.10, it's in /var/lib/mongodb/mongod.lock
and after that running the repair command
sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/
courtesy: https://stackoverflow.com/a/13700262/4907105

ubuntu sudo service mongod status shows failed but mongo is working

I started a replica set with three servers with default port and used a different data directory. But when i did sudo service mongod stop. it said failed. so i went into mongo shell and did a shutdown and mongo shell stopped working. now when i did sudo service mongod start it said failed but i was able to go to mongo shell and the reolica set was working. I checked sudo service mongod status it said failed.
sudo service mongod status
[FAIL] Checking status of database: mongod apparently not running failed!
i edited mongod.config to have a replica set name , commented out bind_ip, used keyfile for auth