mongodb on AWS ec2 redhat linux - linux

I am trying to install mongodb on my production instance, following this tutorial.
Everything seems to be fine, im seeing mongo on info.php and the sample connection is working.
But, when i run mongod or service mongod start from command line
i get mongod: unrecognized
service
Also when i run sudo find / -type f -name *mongo* this is what i get.
/home/userName/.npm/mongodb/1.1.3/package/lib/mongodb/responses/mongo_reply.js
/home/userName/.npm/mongodb/1.1.3/package/lib/mongodb/connection/mongos.js
/usr/lib64/php/modules/mongo.so
/usr/share/pear/.registry/.channel.pecl.php.net/mongo.reg
/usr/share/vim/vim72/keymap/mongolian_utf-8.vim
question what am i missing?
Up until now i have been testing locally on a windows machine.

You need to install the database package itself (you have so far installed all the libraries to connect to it, but not the database). Follow the instructions here:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-redhat-centos-or-fedora-linux/
And you will have the appropriate service as needed.

Related

Error: Could not connect to Redis at 127.0.0.1:6379:connection refused

The detailed installation guide to install Redis on Mac
Hello Everyone,
I recently stumbled upon a YT video on Redis Crash Course by "BRAD" in Traversy Media Channel(https://www.youtube.com/channel/UC29ju8bIPH5as8OGnQzwJyA). Below are the following that I got stuck in while Installing Redis.
I was unable to download Redis through CLI i.e. wget
https://download.redis.io/releases/redis-6.2.6.tar.gz and note, I
used curl as wget was not functional.
I was unable to start the Redis-Cli and it tortured me with an Error:
Could not connect to Redis at 127.0.0.1:6379:connection refused not
connected> Below are the steps that I followed to install and run
successfully.
[Solution]Problem statement 1:
Instead of downloading through CLI, I tried downloading the "tar.gz" file directly. Downloaded the stable version 6.2.6 and then followed the below CLI commands.
$ tar xzf redis-6.2.6.tar.gz $ cd redis-6.2.6 $ make
This made the job easy to make a binary. Post which, I followed the Redis documentation to run the redis-server. And, it worked fine.
[Solution]Problem statement 2:
As I said, I was unable to run the redis-cli even though, I was able to successfully run the redis-server. I tried several websites and StackOverflow to understand the concept behind the error. That's when I realized the redis-server and redis-client are two separate executable files/process so to make the redis-client work, you should keep in mind that the redis-server should run either in background or in other terminal.
Note, if you're executing the redis-server in the same terminal, then make sure to run the server in the background using the below command.
redis-server --daemonize yes
This should solve the problem, now try using the redis-cli. It will work perfectly.
Now, you can see port 6379 with the localhost IP, make a test PING and confirm it is connected.

net start MongoDB - system error

I am new to MEAN development which means I am new to MongoDB.
I have picked up Packt's book "MEAN Web Development" by Amos Haviv and I am running into issues right off the bat.
I have installed MongoDB no problems. I can run it just fine with "mongod" or by running the bin\mongod.exe command.
The problem is that the book has been telling me to do the following (and apparently the book is great so I doubt it would have gotten much acclaim if everyone got stumped like me so early on).
echo logpath = C:\mongodb\log\mongo.log > C:\mongodb\mongod.cfg
Cool, good, done. Config file is written and all is well.
Then it tells me to run this command
sc.exe create MongoDB binPath= "\"C:\mongodb\bin\mongod.exe\" --service --config= \"C:\mongodb\mongod.cfg\"" DisplayName= "MongoDB 2.6" start= "auto"
Again, runs fine. It gives me this message
[SC] CreateService Success
Then the author goes on to tell me that I should be able to run the following command.
net start MongoDB
Of which, mind you, I still do not really know what it's supposed to do. Is it the same as running
C:\>mongod
and
C:\mongodb\bin>mongod.exe
??
So, I try to run the command it suggests and I get the following:
System error 2 has occurred.
The system cannot find the file specified.
I have tried this solution already
MongoDB 3.0 Windows Service Start : System Error 2 has occured
But it doesn't seem to apply to me.
Please help. My knowledge of this stuff is quite limited (I am moving from mainly a PHP/JQuery background into this stuff and the initial setup is driving me crazy.
Any and all help is appreciate. Thanks all
B
EDIT - SOLUTION
Cannot start MongoDB as a service
This solution allowed me to fix my problem. I first had to uninstall the service that was supposedly successfully installed and then reinstall it using the command from this solution
mongod --logpath c:\mongodb\logs\mongo.log --dbpath c:\mongodb\data\db --directoryperdb --install
SOLUTION
Cannot start MongoDB as a service
This solution allowed me to fix my problem. I first had to uninstall the service that was supposedly successfully installed and then reinstall it using the command from this solution mongod --logpath c:\mongodb\logs\mongo.log --dbpath c:\mongodb\data\db --directoryperdb --install
Try running cmd as administrator it worked for me

Why is my mongo db not starting? (Bitnami MEAN Stack)

I installed the stack on my laptop and it was working fine. Then I restarted my computer and tried to start mongo and it would not start.
the error message I get in the manager is
meanstack-3.0.6-1/mongodb/scripts/ctl.sh : mongodb could not be
started Stderr: child process exited abnormally
And when I try to start manually from a terminal I get an error saying data/db directory not found even though there is one.
I have already tried these steps with no luck:
1) Remove .lock file
sudo rm /var/lib/mongodb/mongod.lock
2) repair the mongodb
mongod –repair
3) start the mongodb
sudo service mongodb start
4) start the mongo client
just a tip: check your available free disc space, sometimes this kind of problems occurs because mongDb don't have enough space on the disc to run the server. if this is not working then manually check the log file Mongodb.log at 'yourPath\bitnami\meanstack-3.x.x-x\mongodb\log' hear you will sure find some proper clue.
Rename below file to anything
meanstack-3.0.6-1/mongodb/data/db/mongod.lock
restart mongodb from bitnami
note:-- mongodb installed in your system is different then installed through bitnami, they are using different ports, i.e. currently you have two instance of mongodb installed in your system.
I needed to install an old version of Mongo so I replaced all the files in the /bin folder with the old version and then I was getting the error "mongodb could not be started". I then deleted all the files under data/db and restarted using "./ctlscript.sh start mongodb" which worked.

Running mongodb in production

I am currently building a web app using express.js and mongodb. My problem is I do not know how to run mongodb itself in production. Because in the development, I used mongod command, but it need the terminal to be open so mongodb will run. How can I do this in the real server? In my express app, I just use pm2 to run it.
Since you are not an expert on managing this, I would suggest you to use some mongodb-as-a-service, so that they manage that for you and you just simply access it. for example: https://mongolab.com/
Or you can use https://www.mongodb.com/cloud so that you can just lunch a few commands in your server and mongodb+backup will be installed in your server and you can update, or make clusters simply using their interface.
Or if you want to install it in your server, guessing you are using linux, and probably an ubuntu based distro you can run mongod like #aiobe suggested: sudo service mongod start

Error with Mongo starting Meteor

I am using a fresh Linux install. I am trying to install Meteor. Using Ubuntu 12.04, Centos and Ubuntu 13.04. I installed Node.js, Meteor and Meteorite.
Error:
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start mongod
MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.
I've tried:
Deleting .meteor/local/db/mongod.lock
Also I tried to change the permissions for the whole project with chmod.
Do you recommend any Ubuntu distribution?
Thanks in advance.
I have run in this problem before (after meteor update or abnormal meteor termination) and these solutions worked for me before.
Restart your machine.
Delete the file .meteor/local/db/mongod.lock and run meteor again.
Execute meteor reset and start again, but this command will erase your database.
Hope it helps.
It some time depends on your locale settings.
Meteor reset and delete mongod.lock didn't help in my case.
I've fixed it by running
export LC_ALL=C
you can add this line to
sudo vim /usr/local/bin/meteor
All I had to do was run "killall mongod" in the terminal. After that it worked again. I believe it may have cleared parts of the database though.
For me a combination of the suggestions worked out. The answer that has gotten 2 down votes! and this one from another page.
sudo vim /usr/local/bin/meteor
export LC_ALL="en_US.UTF-8"
then make sure which port your mongodb is running at by issuing the following:
meteor mongo
You will get a response like this:
connecting to: 127.0.0.1:3001/meteor
now that you know the port on which the mongo is configured, add the following to the same file we have been editing:
export MONGO_URL=mongodb://127.0.0.1:3001/meteor
Now you are good to go. Of course "meteor reset" works but if you dont want to loose your data, stick with those two export lines.
I have found that setting MONGO_URL helps avoid issue
export MONGO_URL=mongodb://localhost:27017/your_db
If you're having this issue running Ubuntu inside Vagrant/VirtualBox, then the problem come from working in the synced vagrant folder.
The workaround is to initialize the .meteor directory in the home directory and to mount it in the synced folder. Assuming your meteor app is called MyApp and the /vagrant is the synced folder, here's how to do it:
cd ~
meteor create MyApp
cd MyApp
meteor
cd /vagrant/MyApp
sudo mount --bind ~/MyApp/.meteor/ .meteor
meteor
I had a similar issue. It was due to the fact that my project directory was part of my Dropbox and there was some conflicted files in the .meteor/local/db directory. Removing these solved the problem.
I encounter the same issue when my disk space ran low.
Freeing up some space in the disk fixed the problem for me.
I encountered this problem when I ran meteor in VMWare, ubuntu 14.04 guest on a Windows 7 host. The problem was that I was running meteor/mongo in a shared directory. When I used a non-shared directory (~/meteor/project) the problem disappeared.
Following the steps that #Oscar mentions further up should sort you out.
However in my case meteor reset wouldn't work, telling me this:
reset: Meteor is running.
This command does not work while Meteor is running your application. Exit the running Meteor development server.
For which I tracked the process down, like this:
$ ps aux | grep meteor --color=auto
which gave me this info:
$ myUser 71981 0.5 0.0 2849208 3644 ?? S Mon02pm 4:25.27 /Users/myUser/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --port 2001 --dbpath /Users/jgt/Documents/Projects/todos/.meteor/local/db --oplogSize 8 --replSet meteor
As you can see I'm on Mac, but this works fine on any Unix based OS.
So then you only need to kill the process by it's id, like this:
$ kill -9 71981
And finally run again meteor reset
That's it, got it working now. Hope it helps.
One option is to wait until you have your app on a staging or production server, and then test it on an Android emulator provided by Android Studio or BlueStacks.
I am having this issue on WSL for Ubuntu on Windows. The only solution that worked for me was creating a remote mongodb with mLabs and ran the following
export MONGO_URL=mongodb://username:password#randomurl.mlab.com:port#/project
Recently I got the same case, which I run meteor on WSL for Ubuntu on windows 10. I resolved this case by updating WSL to version 2.
Note :
Make sure your Windows build is higher than the minimum WSL 2 requirements. And don't forget to set version 2 as WSL default version after updating.
wsl --set-version [linux_dist] 2
For windows 10, I moved all my Meteor projects in drive C. So far working.

Resources