4/14/2023 0 Comments Mongodb for mac os xYou’ll have to set this to something other than the default 27017 or mongo will complain. Port sets the port where the mongod instance should run. my_data instead of the default /data/dbĭbpath tells mongo where you data should be stored, in this case, the data directory we created earlier. Create a new nf in this directory and include the following code: # Store data in. In order to tell MongoDB your settings when you start a mongod process, you will need to setup a config file. ‘cd’ back into the directory where you setup MongoDB. We just need to set the configurations for our new MongoDB instance and then we should be good to go. The next time you start up again, MongoDB will not start by default. Open up this file in your favorite file editing software and change the following line: First, cd into the LaunchAgent directory cd ~/Library/LaunchAgents To turn this off, you need to edit a LaunchAgent file that Homebrew sets up by default. The homebrew version of MongoDB is still setup to start automatically on startup. However, if you plan to use this setup more than once, I would recommend one more change. You should get an error: Error: couldn't connect to server Ok, now if you try to connect to MongoDB again using the mongo command. You could try to just kill the mongod process in the terminal, but there are no guarantees about how that might affect your current MongoDB setup and database. You can cancel a mongod process by running the mongo shell with the “mongo” command then issuing the following commands in the shell: use admin For http diagnostic access, add 1000 to the port number To triple-check this, MongoDB runs off port 27017 by default, you can go to localhost:27017 and you should see a message like this: You are trying to access MongoDB on the native driver port. usr/local/bin/mongod run -config /usr/local/etc/nf If mongo is running, you should see mongod in your list. To double-check this run: ps -ef | grep mongo This means that your other version of MongoDB is still running and you need to stop it before you can start up the new version. It might give you a message like MongoDB shell version: 2.0.x If an instance of mongod process is running, then it should have no problem connecting. You can check if this just by running the mongo shell with the “mongo” command: If you installed MongoDB via Homebrew, then more than likely, MongoDB is running on startup. But first, before we fire that up, there are a couple of things to check first. Ok, now you should be all setup for a new instance of MongoDB. We’ll create a “data” directory in the current directory which should be something like: ~/mongo2_2/mongodb-osx-x86_64-2.2.2 However, if you have installed MongoDB via Homebrew, then mongo is configured to write to /usr/local/var/mongodbįor the ease of use, we’re just going to use the directory we are currently in. By default, mongod writes data to the /data/db/ directory. Ok, you have mongo setup, but now you need a place to store the data. Some of these you may recognize, like the actual MongoDB process – mongod and the mongo shell, mongo. ‘cd’ into that directory and you will see that it has created a “bin” folder with all the MongoDB commands and executables. This should create a new directory mongodb-osx-x86_64-2.2.2. Then you need to untar the download into that directory. I call it mongo2_2 here but you can call it whatever you would like: mkdir mongo2_2 Then create an empty directory wherever you would like MongoDB to live. In addition, I will be using the 64-bit OSX version from their site. In this case, we’ll use the latest production release which is 2.2.2 at the time of this post. Again, I had already installed MongoDB via Homebrew using brew install mongodb, so I’ll show you how to install your own version outside of homebrew.įirst, you’ll need to download a version of MongoDB from their website. So, here are the steps I used for setting up a separate instance of MongoDB. Searching the web, I found very little information about how to setup multiple versions of MongoDB on the same local environment. However, I already had a local version of MongoDB v2.0 installed on my mac via Homebrew which I was using to test and development a production database that we were running. I was working on a problem that required MongoDB’s new aggregation framework that comes standard with MongoDB ~> 2.2. I ran into an interesting problem the other day. For more up-to-date information, I would check the MongoDB site or Google. I am posting this just as a reference for those curious as to how I did this originally back in 2013. Some of this information may no longer work. This post was originally published in February 2013 on my old blog.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |