Friday, May 27, 2011

Running MongoDB on a mac

In a previous blogpost I stated that I found out about MongoDB, a database type I never heard of before. I have downloaded it and "installed" it on my macbook air. As I come from a Oracle background and work with Oracle databases primarily I was surprised by the ease of installation and getting things up and running. Up and running without the tuning.

I a couple of simple steps you can get a working copy of MongoDB on your local mac workstation. If you follow these steps you will be set to start exploring MongoDB

1) Go to the mongodb.org website and download the needed .tgz file.

2) Unpack the file and copy the files to a location where you want to have your MongoDB binary files.

3) Create a directory /data/db this is the default location where your data will be stored, you have to create this manually.

4) Go to your MongoDB bin directory and start mongod

5) Open a second terminal and execute in the MongoDB bin directory the mongo command.

Step 5 will put you in the MongoDB shell and you are ready to go and explore the options of MongoDB. This is all you need to start exploring MongoDB.

As a example below you can see the output of the mongod command on my local workstation:

Johan-Louwerss-MacBook-Air:bin suntac$ ./mongod
./mongod --help for help and startup options
Fri May 27 14:48:50 [initandlisten] MongoDB starting : pid=17438 port=27017 dbpath=/data/db/ 32-bit

** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
** see http://blog.mongodb.org/post/137788967/32-bit-limitations
** with --dur, the limit is lower

Fri May 27 14:48:50 [initandlisten] db version v1.8.1, pdfile version 4.5
Fri May 27 14:48:50 [initandlisten] git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04
Fri May 27 14:48:50 [initandlisten] build sys info: Darwin broadway.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Fri May 27 14:48:50 [initandlisten] waiting for connections on port 27017
Fri May 27 14:48:50 [websvr] web admin interface listening on port 28017

No comments: