I'm using meteor and I need to use mongoimport to add some JSON-data to the DB. But when I try to start meteor import, I got the error command not found. This is surprising for me as mongoimport is part of mongoDB, so I expected this working.
So I guess I have to install MongoDB separately from meteor (using OS X). But what is the correct way to do that?
Of course I can do brew install mongodb. Or would it be better to download the mongodb-file manually, extract the archive and take the mongoimport-file?
I'm just worried to install mongodb, although I already have meteor installed and it works. I don't want to get two different mongoDB instances.
If you don't already have the mongoimport binary somewhere, just download MongoDB for OSX from their site, extract the archive somewhere, and use the mongoimport file that will be in its bin folder.
You won't get another daemon running unless you run another mongod and you are probably safest to avoid using brew so that it doesn't do something unintended.
Related
I run a MongoDB replica set in a containerization environment orchestrated by Rancher.
After rolling out the latest update, MongoDB as been upgraded from 3.6.x to 4.0.x (latest).
No upgrade path has been followed and, as a result, when trying to bind the volume holding the database storage, the service fails to start, exiting with the following exception:
STORAGE [initandlisten] exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: admin.system.version, terminating
I get the same outcome even attempting to launch mongod with the --repair option.
I have also tried to rollback the container to MongoDB 3.6.16, but the journal version is now incompatible.
We don't have snapshots of the volume, hence restoring the data is not an option (this is not a production environment). The only solution I've found online is not applicable, since it suggests to leverage mongodump and mongorestore, requiring a running database with the data storage attached.
I'm running out of ideas, any advice about how to fix this?
A bug report on this issue recommended following the full upgrade path and that worked for me. I was able to go back to my old version when I ran into this error, and then upgrade properly.
Specifically: upgrade just one major version at a time and check the prerequisites and upgrade steps carefully. The most important part of this is checking your compatibility with db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) and make sure it matches the current version before upgrading to the next version. Update it with command like db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
Read the full docs at pages like https://docs.mongodb.com/manual/release-notes/3.6/#upgrade-procedures https://docs.mongodb.com/manual/release-notes/4.0/#upgrade-procedures etc
I was updating MongoDB from 3.6 to 4.2 with Homebrew on Mac OS, and ran into this similar situation.
Since formula mongodb was removed from homebrew-core, the team of mongodb maintained a custom Homebrew tap.
Following steps is my solution for upgrading MongoDB from 3.6 to 4.2 with Homebrew:
Uninstall old version mongodb from Homebrew
# If you run mongodb in background service, stop it first.
brew services stop mongodb
# If you have multiple version of mongodb, you might need to add `--force` option for deleting all of them at once.
brew uninstall mongodb
Install new mongodb from custom Homebrew tap
brew tap mongodb/brew
brew install mongodb-community#3.6
Add mongodb-community#3.6 to your PATH
echo 'export PATH="/usr/local/opt/mongodb-community#3.6/bin:$PATH"' >> ~/.bash_profile
Restart your terminal, and run mongod
Open another tab or terminal windows to run mongodump
Terminate mongod
Uninstall mongodb-community#3.6 and reinstall mongodb-community
brew uninstall mongodb-community#3.6
brew install mongodb-community
Delete old data with old mongo data structure
rm -rf /data/db/*
Run mongod
Open another tab or terminal windows to run mongorestore dump/
Once mongorestore completed, mongod will be terminated.
And you can run mongodb as a background service or just run mongod again. Open MongoDB with mongo or Robo 3T(formerly Robomongo), you will see your data is good as usual.
Hope it helps.
Alright after about 3hours of trying to fix exactly what you are describing, here are the steps I took. Here I will show how to retain the data while downgrading to 3.6 and also how to update it 4.0 with the retained data.
The reason this happens for mac users is because there was an update for people using brew can no longer download Mongodb directly from brew. Then people tend to download the newer community edition instead from brew which then gets in conflict the old version of 3.6 db folder still present in the directory. Instead you would need to download it from the actual mongodb website:
https://www.mongodb.com/download-center/community
Here what you would want to do, is download everything manually. Follow these instructions here, but do this with the 3.6 version:
https://medium.com/#saurabhkumar_4718/install-mongodb-without-homebrew-on-mac-os-2a98b68ab09c
NOTE: when you copy .bash_profile please make sure export commands are not
Once you have successfully installed 3.6 manually you can mongodump to be safe, and or export all your mongo data into json with mongoexport for any data that you must really really save.
After that you can fresh install 4.0 manually again by following exactly the same steps as previously done for 3.6
This worked for me without having to do any 'mongorestore' as the 'db' folder was left alone and all my data was there, but maybe extra steps might be needed to restore the data. Worst comes to worst you have .jsons that needs to be rewritten. 'mongo --version' also showed the right version :) Hope it helps
Backing-up all the databases (using mongodump)
Removing every file in /data/db, due to their incompatibility with the newer version: rm -rf /data/db/*
Restarting the MongoDB service by mongod
Restoring all the databases (using mongorestore)
https://dba.stackexchange.com/a/252393
For Docker:
I had this issue when I was upgrading a project that used Docker from 3.6 to 4.2 (and 4.4).
The way the project is set up means I don't have a physical /data/db directory to purge.
However, there is a volume defined that acts as the /data/db directory.
In this case all you need to do is backup any data you need and remove the associated volume.
If using vs code with the docker extension, you can simply open your docker tab in the sidebar, expand the volumes section, locate the volume in question (for me it was called mongo-4-2-upgrade-test_mongo-data which depends on how your various containers are named for your project), right-click and remove.
Ensure that the containers that use this volume have been properly shut down or you'll get a 409 conflict error. I did the same as above but found my mongo container (in the containers section of the docker tab) instead. then when I restarted my docker-compose file the new version of mongo was installed and ran as expected.
I installed MongoDB manually on the MongoDB website. https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
I followed the instructions under "Install MongoDB Community Edition Manually".
How do I uninstall MongoDB completely? I have searched around and only found how to uninstall using Homebrew. I did not install MongoDB using Homebrew.
Any help is greatly appreciated.
Just follow the manual install steps in reverse order:
shutdown mongod
remove your data directory (if you no longer want this)
remove the directory with the MongoDB binaries
remove the directory with the MongoDB binaries from your shell PATH
Other files that might have been created depending on how you ran MongoDB:
there may be old log files to remove if you specified a --logpath outside your data directory
there may be a launchctl script and configuration file to remove if you configured mongod to run as a service
I am new to Unit testing and trying to use Phactory with Mongo, but when I run the test I keep getting the following error.
PHP Fatal error: Class 'Mongo' not found in /vagrant/Test/user/LoginTest.php on line 19
I know Mongo is installed because when I pull up the site it works, but for some reason PHPUnit isn't recognizing it.
I feel I am missing a step. Do I need to install the Mongo extension locally, or do I need to include the location in a config file somewhere?
Are you sure Mongo is installed as a module in the command line version of PHP?
Do a quick run of php -i and have a look at the output (which is phpinfo() without fancy formatting) or php -m for a list of modules. If the Mongo extension does not show up, you have to install it.
Also note that the Mongo class has been deprecated. You'd probably update to using MongoClient.
Does anyone know a step by step guide to deploy the own meteor app from windows to a webspace (not xxx.meteor.com).
I've found some tools like meteor.sh, but I'm a beginner and it's difficult without a guidance and without linux (needed to execute sh-files for example)
Make your project locally
Build your project locally, you could test it using meteor run or even meteor deploy xxx.meteor.com to see if its working
Bundle your app
Use meteor bundle deploy.tar.gz to make a file called deploy.tar.gz in your meteor directory containing your project
Upload your file to your server
This depends more on how your server is/what your platform is but you can use a tool to upload it for you (e.g Transmit on mac)
Install node.js & fibers on your platform if you don't have it already
This depends alot on your server platform. Have a look at http://nodejs.org/ for more detailed instructions
Extract your bundle
If on a *nix platform you could do the below in the directory where you uploaded your bundle (explanation):
tar -xzvf bundle.tar.gz
Enter the directory and install fibers
Fibers is needed for any meteor project, it helps use synchronous style code on server side javascript:
cd bundle/programs/server/node_modules
rm -r fibers
npm install fibers#1.0.1
The first line enters the directory in your bundle where fibers is installed, the second removes it, and the third reinstalls it.
Get MongoDB on another server or use a third party service like mongohq
Meteor production deployments need another mongodb. You can either install it on another server or use a third party server. It's not recommended to install it on the same server you install meteor on.
Finally check if your project is runnable
cd ../../../
node MONGO_URL=mongodb://dbuser:dbpassword#dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js
The first line gets you back to the bundle directory and the second runs node.js on your project with the parameters that let you connect to your mongodb database.
Install something to let it run in the background
It depends on which one you want to use, foreverjs is quite easy to use
npm install forever -g
If you get an error problem try using sudo before the npm (which lets you run as a super user).
Then you can run forever:
forever start MONGO_URL=mongodb://dbuser:dbpassword#dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js
And its done!
Extra notes
While its not that easy to get started from scratch this should help you get started. You still need to secure your mongodb server up if you've used your own servers.
The meteor.sh script does pretty much the same as above but very quickly if you learn to use that instead it might be faster to deploy updates
You might not have wget or a couple of commands that you might need that come up and give you Unknown command errors. Have a go at running yum or apt-get and see which one of the two you might have. You can then install the required package using one of these installer tools, i.e with yum install wget
I hope this helps you, its not that easy to deploy to a server on the first shot as a couple of things might be missing (files/packages/dependencies), you might run into other problems with permissions & stuff, but you could always ask on serverfault or here on stackoverflow on what you run into.
I recommend Meteoric.
Note, that you need to run meteoric from your development machine.
Script is self explanatory and works perfect for me.
I'm playing with MongoDB while reading O'Reilly MongoDB - The Definitive Guide.
In appendix A, the authors teach how to install MongoDB, downloading the latest version, creating a /data/db directory and so on.
The question is: what's the best approach to install MongoDB?
In my computer, first I extracted the archive and then, inside /mongodb-linux-i686-2.0.1 directory, I created that structure, /data/db. Did I take the right decision?
I'm just playing but, what if I decide to start a real project using MongoDB? How to setup properly my server, in order to update MongoDB for next releases without data loss (as my /data directory is inside /mongodb-linux-i686-2.0.1 directory)?
Ordinarily MongoDB will use /data/db -- that is, that folder in the root of your filesystem tree -- as the data path. You can override this with the --dbpath command-line argument, or in a config file (and with --config). It is up to you whether to use the default data path or a custom one, and to use a startup script that sets the options you want.
If you are using an RPM-based distribution, see http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages for information about using officially-provided 10gen RPMs; if you are using Debian or Ubuntu, see http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages instead. These packages come with startup scripts for you and defaults for --dbpath which match expectations of the respective operating systems.