Recently I successfully downloaded and installed MongoDB on my Mac. I am a Windows developer dwelling in the world of
Linux programming, so I wanted to blog about my experience
as it may be helpful to other fellow devs who are new to Linux as well.
Most of the steps below are refinement / explanation of http://www.mongodb.org/display/DOCS/Building+for+OS+X.
- Step 1 - Download MongoDB server - From mongodb.org website download MongoDB server and untar the files in some folder (MongoDB_Server).
- Step 2 - Create a folder /data/db in your root. MongoDB server uses this path to store the database(s).
- Step 3- Download MongoDB client - From mongodb.org, download a compatible client (same version as the server) and untar the files in client folder (MongoDB_Client)
- Step 4 - If you haven't done so far, you must download package manager on OSX called homebrew. A package manager on linux is an application that makes it dead simple to download other applications and install them on your system. To download homebrew open a shell window and type:
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
- Step 5 - Download boost C++ library - Execute: brew install boost
- Step 6 - Download scons (Makefile executor) - Execute: brew install scons
- Step 7 - Download pcre++ (Perl regular expression lib) - Execute: brew install pcre++
- Step 8 - Build client - Navigate to the client folder and simply type: scons
- Step 9 - Start server - Open a new shell window and navigate to server folder's bin subfolder and type: mangod. This should start the server !
- Step 10 - Test client - Navigate to client folder and execute: ./clientTest (this should run a simple client test)
- Step 11 - Write your own test: In the client folder's client/example subfolder, create a test program with code
from http://www.mongodb.org/pages/viewpage.action?pageId=133415 and name it test.cpp
- Step 12 - Now navigate to root client folder and execute: g++ -o test client/examples/test.cpp -I mongo -L. -lmongoclient -lpthread -lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt
- Step 13: Last step should compile your code and output test binary. Simply execute this binary to verify client code ! Ensure that your server is running all this time...
Software Developer (Senior)
MixModes Inc. | Research In Motion
Ashish worked for Microsoft for a number of years in Microsoft Visual Studio (Architect edition) and Windows Live division as a developer. Before that he was a developer consultant mainly involved in distributed service development / architecture. His main interests are distributed software architecture, patterns and practices and mobile device development.
Currently Ashish serves as a Technical Lead at RIM leading next generation BlackBerry media experience and also runs his own company MixModes Inc. specializing in .NET / WPF / Silverlight technologies. You can visit MixModes at http://mixmodes.com or follow it on Twitter @MixModes
In his free time he is an avid painter, hockey player and enjoys travelling. His blog is at: http://ashishkaila.serveblog.net