How to install 3 popular NoSQL databases for development in MacOSX for newbies Part 1 (mongodb)
This post aims to help all developers (not only Java) that want to develop using NoSQL datastores, specifically MongoDB, Cassandra and Couchbase, in MaOSX. Before starting writing code you need to have the db engines installed and ready for tests. So our goal for these mini posts will be to install all of them in our local environment and then start coding. (My goal is to write some coding posts using all of them, in the upcoming days).
I am currently using MacOSX 10.10.2 (Yosemite), I have already installed Maven 3.2.x and Java JDK 1.8 in my machine. If you need help as a junior java developer in MacOSX, then I suggest you go through this post.
MongoDB
You need to download the binaries for MacOSX, which can be found here. Then, extract the .tgz file to a folder of your choice, for my case is a directory called
\home\work\mongodb\
After doing that you should have within the mongodb directory the following contents, as illustrated in the image below
We are almost there, all we need to do is create with the same director (could be anywhere else actually) a directory called data . As illustrated in the image below.
This is the directory where our mongodb instance will save it’s data files. In order to start up our MongoDB instance, from the command line we need to issue the following command
> cd \home\work\mongodb\bin > mongod --dbpath ../data
We should see something like the following, below :
Since I want to make my life easier, using the .profile file I have created an alias command that will start my test mongo, without having to make the 2 steps above. So if you edit your .profile under your home directory, you can add an alias the like the following:(beware these are my local, paths dont forget to change them).
alias startmongo='/Users/papo/work/mongodb/bin/mongod --dbpath /Users/papo/work/mongodb/data/'
So you can issue from command line the command >startmongo and your mongodb instance will start!
What about a client to check our database, maybe create some documents?
RoboMongo is a nice MongoDB client for MacOSX! Easy to setup and use.
After downloading it, we setup a new connection, with the minimum information.
And we are ready to go.
Easy!
Reference: | How to install 3 popular NoSQL databases for development in MacOSX for newbies Part 1 (mongodb) from our JCG partner Paris Apostolopoulos at the Papo’s log blog. |