mongodb not starting after reboot for my rails3 app - mongodb

Due to power outage my computer crahsed while working on rails3 app. My mongodb is not restarting ever since.
MongoDB shell version: 2.4.10
connecting to: test
Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
Noticed after reboot /data/db is missing. Went ahead and created it, but for some reason it is still not starting. Appreciate inputs here

I think the issue is due to mongodb lock.
Try this:
sudo rm -rf /var/lib/mongodb/mongod.lock
and restart your service.

Related

brew services. Cant start service. get "Bootstrap failed: 5: Input/output error"

running brew services start mongodb-community which yields:
Bootstrap failed: 5: Input/output error
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/<myUserName>/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist` exited with 5.
when I run launchctl load -w /Users/<myUserName>/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
yields
Load failed: 5: Input/output error
I recently upgraded macOs to BigSur 11.5.2.
Ive uninstall and reinstalled homebrew and xcode.
try this
brew services restart <mongodb-community#4.4>
I am able to run mongodb through homebrew. I believe this solved my issue:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
followed by
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
I saw this issue with MySQL and the solution was my current profile was not the owner of my homebrew folder.
I had to change it because I have a second profile set up for another work space, but they share the same homebrew path.
I would suggest anyone who sees this error try running
sudo chown -R $(whoami) $(brew --prefix)/*
And then seeing if that will resolve it. Again I didn't have this issue with MongoDB, but I saw this exact error with MySQL when my profile didn't own the brew folder.
Try this if you tried to restart your service, but it still doesn't work
stop your service
brew services stop mongodb-community
restart your macOS
start your service again
brew services start mongodb-community
To see the real errors, you need to run the service without brew
I had a similar problem, but instead of mongodb, I could not start apache(httpd).
$ brew services start httpd
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501
/Users/john/Library/LaunchAgents/homebrew.mxcl.httpd.plist` exited with
5.
FAIL: 1
Unfortunately brew doesn't show the user what causes this error. At first I tried to use the tips from the answers in this thread, but neither reinstalling apache nor unload -w/load -w helped.
I also found nothing in the brew logs. I decided to investigate apache itself. To do this I ran apache without brew:
$ /opt/homebrew/Cellar/httpd/2.4.51/bin/apachectl start
httpd: Syntax error on line 66 of /opt/homebrew/etc/httpd/httpd.conf: Cannot load /opt/homebrew/Cellar/php#5.6/5.6.40_3/lib/httpd/modules/libphp5.so into server: dlopen(/opt/homebrew/Cellar/php#5.6/5.6.40_3/lib/httpd/modules/libphp5.so, 0x000A): tried: '/opt/homebrew/Cellar/php#5.6/5.6.40_3/lib/httpd/modules/libphp5.so' (no such file), '/usr/local/lib/libphp5.so' (no such file), '/usr/lib/libphp5.so' (no such file)
FAIL: 1
Then it was finally clear what was the reason why httpd service was not starting. It turned out that after the php upgrade, the php version had changed and I forgot to write the new php version in the apache configuration file.
I quickly fixed this and apache started up.
It seems that the mongodb-community is already started. So do restart it instead of starting, by the following command:
brew services restart mongodb-community
I faced a similar problem with postgresql 11 and restarting the service did not help. The issue arose when my MacBook restarted abruptly.
After checking the ports and trying out all the possible solutions, I decided to look into the logs.
tail -n 100 /usr/local/var/log/postgresql#11.log
This gave me the last 100 lines of the log where I found this:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 479) running in data directory "/usr/local/var/postgresql#11"?
Clearly, the issue was with postmaster.pid so I deleted it:
rm /usr/local/var/postgresql#11/postmaster.pid
Started the postgres service again:
brew services start postgresql#11
and voila! It worked.
I had similar error in regard to postgres.
$ brew services start postgresql
Bootstrap failed: 5: Input/output error
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/yrk/Library/LaunchAgents/homebrew.mxcl.postgresql.plist` exited with 5.
I've tried restart and it looked promising:
$ brew services restart postgres
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
But there still was a problem when trying to connect:
$ psql -d postgres -U apiuser
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Checking postgres log as mentioned by #mansoor.khan helped, in my case it was:
tail /usr/local/var/log/postgres.log.
And the issue was clear:
$ tail /usr/local/var/log/postgres.log
2022-05-19 14:18:46.029 CEST [32374] FATAL: database files are incompatible with server
2022-05-19 14:18:46.029 CEST [32374] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:18:56.071 CEST [32676] FATAL: database files are incompatible with server
2022-05-19 14:18:56.071 CEST [32676] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:19:06.111 CEST [32885] FATAL: database files are incompatible with server
2022-05-19 14:19:06.111 CEST [32885] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:19:16.128 CEST [33102] FATAL: database files are incompatible with server
2022-05-19 14:19:16.128 CEST [33102] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:19:26.166 CEST [33434] FATAL: database files are incompatible with server
2022-05-19 14:19:26.166 CEST [33434] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
Now the problem is: how to revert to previous version or upgrade old data to new version of postgres DB, but this is for another topic.
run something like launchctl remove homebrew.mxcl.mongodb-community before the load command solved my problem
I had this when upgrading from 4.4 to 5.0 and I suspect it’s similar for you. Lets assume you were upgrading 5.x to 6.x then the resolution would be ...
check your mongo log, e.g.
vi /usr/local/var/log/mongodb/mongo.log
Look for any errors relating to file/directory permissions and fix those, e.g. though I’m not quite sure whether ‘wheel’ or ‘admin’ is right.
sudo chown yourloginname:wheel thedirectory/*
Roll back to your previous working version of mongo (e.g. 5.x)
Start Mongo 5
Start a Mongo Shell and type
db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )
Check the logs to verify the database has detected 5.0
Uninstall 5.x
Re-install 6.x
Restart / start 6.x
It should now work?
In my case, another httpd process was running on the Mac. Killed with monitor tool allowed me to start httpd.
I had a similar problem on mysql.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/gerd/Library/LaunchAgents/homebrew.mxcl.mysql.plist` exited with 5.
In my case the mysqld miss the osx network connection permission. After restart OSX it appear the network permissions dialog. I granted the permission to msqld and the problem was fixed!
Happened with redis. Realized there was a bind setting in the config, binding the server to an incorrect ip address.
I faced the same problem. This commands helped me
brew uninstall rabbitmq
brew uninstall erlang
brew install rabbitmq
brew services restart rabbitmq
You may run into this if the service is already running, but as another user.
For example, you may have run sudo brew services start example and are now running brew services info example. It tells you it's not running and you think "hm, it should be running" and enter brew services start example.
Potentially example is already bound to, say, port 7777 and now you ask for another program to be bound to the same port, leading to a failing service start.
In short: If you are binding to a port, check if the same service is already running as another user and bound to the same port.

MongoDB won't connect on Ubuntu 14.04

I am trying to install MongoDB on Ubuntu 14.04 LTS. I am following the article at the link below:
https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/
Everything is fine, and my log file shows the following line:
2016-12-18T20:47:19.476+0000 I NETWORK [thread1] waiting for connections on port 27017
I also get the following status when i run the following command:
bitnami#ip-172-31-58-13:service mongod status
bitnami#ip-172-31-58-13:mongod start/running, process 15587
however, as soon as i try to connect to mongo, I run into an error, which I simply cannot seem to resolve.
Command:
bitnami#ip-172-31-58-13:/var/log/mongodb$ mongo
Output:
MongoDB shell version: 3.0.7
connecting to: /opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017/test
2016-12-19T00:08:48.809+0000 W NETWORK Failed to connect to /opt/bitnami/mongodb/tmp/mongodb-27017.sock:0, reason: errno:2 No such file or directory
2016-12-19T00:08:48.810+0000 E QUERY Error: couldn't connect to server /opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017 (/opt/bitnami/mongodb/tmp/mongodb-27017.sock), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
bitnami#ip-172-31-58-13:/var/log/mongodb$
I have tried everything on the internet (gone through about 50+ articles) but nothing seems to work - changing the .lock file, updating the permissions, even uninstalled and re-installed mongodb 2 times and so on.
I noticed that the mongodb-27017.sock is placed under /tmp rather than /opt/bitnami/mongodb/tmp/ but I am not sure if that is a problem?
Please help me in resolving this issue.
Thank you

Mongo: network error while attempting to run command 'whatsmyuri' on host

I have been trying to access my mongo instance from another machine, but I get this error. I could not find many references to this whatsmyuri error. This is what I get from the external machine:
$ mongo <IP_ADDRESS>:27017/youtube_advertising -u user -p password
MongoDB shell version: 3.2.0
connecting to: <IP_ADDRESS>:27017/youtube_advertising
2016-02-19T17:10:02.923+0100 E QUERY [thread1] Error: network error while attempting to run command 'whatsmyuri' on host '<IP_ADDRESS>:27017' :
connect#src/mongo/shell/mongo.js:226:14
#(connect):1:6
exception: connect failed
I have already changed the /etc/mongod.conf file, opened connections through port 27017 (with iptables) and restarted mongo. I am able to connect via ssh to that machine.
Searching about this whatsmyuri, I ran this command on mongo:
> db.runCommand( { whatsmyuri: 1 } )
{ "you" : "127.0.0.1:36990", "ok" : 1 }
I do not know if that 36990 port is right or wrong. Just in case I opened connections from there too, but still nothing.
Any ideas?
UPDATE
Checking the /var/log/mongodb/mongod.log, this is what I get when I try to connect from remote:
2016-02-19T10:41:07.292-0600 I NETWORK [initandlisten] connection accepted from <EXT_IP_ADDRESS>:51800 #2 (1 connection now open)
2016-02-19T10:41:07.310-0600 I QUERY [conn2] operation isn't supported: 2010
2016-02-19T10:41:07.310-0600 I - [conn2] Assertion: 16141:cannot translate opcode 2010
Check your versions. That may help.
I was having the same problem. In my case, the server was version 3.2.0-rc2, while mongo shell version was 3.2.1.
Upgrading the server to 3.2.1 fixed the problem.
This issue bit me when I was running two versions (3.4 and 4.2) of MongoDB on the same Windows 10 machine. I ran v3.4 mongod with no problems mentioned in the console output, but then running the v3.4 mongo shell produced the above error. Checking the Task Manager, it turned out there was a MongoDB process (I'm not sure, but I think it was for v4.2) running. After ending that process through the Task Manager, the v3.4 mongo shell ran fine with no error.
Using mongodb-community-shell
In MacOs brew install mongodb/brew/mongodb-community-shell
It will ask you to overwrite link with mongo command.
brew link --overwrite mongodb-community-shell
The issue arises when the mongo client's and server's version mismatch.
Uninstall MongoDB from the client and for installation follow the detailed instruction provided over here.
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
The key step which needs to be done with the attention is
sudo apt-get install -y mongodb-org=4.2.7 mongodb-org-server=4.2.7 mongodb-org-shell=4.2.7 mongodb-org-mongos=4.2.7
mongodb-org-tools=4.2.7
Note: In my case, the mongo version of server was 4.2.7
Another thing that one can do is uninstall MongoDB from both the systems taking necessary backups and install it again.

error connecting to mongodb service on windows

I recently started the mongodb service on my windows machine, and it is running succesfully. Or at least I think it is, though I am not 100% sure and I don't know what port it is running on because all attempts to check the status have failed. When I try to run mongo.exe, I get the following error:
paul#PAUL_LAPTOP /c/program files/mongodb 2.6 standard/bin
$ mongo
MongoDB shell version: 2.6.3
connecting to: test
2014-08-11T03:36:15.802-0400 warning: Failed to connect to 127.0.0.1:27017, reas
on: errno:10061 No connection could be made because the target machine actively
refused it.
2014-08-11T03:36:15.808-0400 Error: couldn't connect to server 127.0.0.1:27017 (
127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
Any ideas how I could check why this is happeing? One good first step would be checking the status of my mongo service, which I am not sure how to do.
Any help is greatly appreciated.
Thanks,
Paul
Have you gonbe through all the steps here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/?
You need to run the mongod command to start mongodb, and you also have to define the path where mongodb shall store your database:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
When you typed in the mongod command, did you also give it a path? This is the step beforehand and this is usually the issue.
mongod --dbpath="put your path to where you want it to save the working area for your database here!! without these silly quotations marks I may also add!"
example: mongod --dbpath=C:/Users/Kyle-3/Desktop/DEV/dangerzonearea/test/mongodb
That is my path and don't forget if on windows to flip the slashes forward if you copied it or it won't work!

Brew MongoDB autoload mongod on login - run mongo as a service

I am confused.
brew services list is showing me that mongod is being loaded at login
mongodb started - /Users/myuser/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
but, when I do mongo I get Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
How do I make mongod to start as a service? The content of the .plist file can be viewed here: http://pastebin.com/itxUtZ8M
Any suggestions much appreciated. P.S. I am running on OS X Maverick (OS X 10.9.2)
Starting mongod manually with the command /usr/local/opt/mongodb/bin/mongod --config /usr/local/etc/mongod.conf showed that something was wrong with the log file:
FileNotOpen Failed to open "/usr/local/var/log/mongodb/mongo.log"
As it turned out, the owner of the file was wrong. Changing it to myuser solved the problem. See comments below the question for details.