Before working on any of the demos which were prepared for the NoSQL Explained session it is important to have in instance of MongoDB running.
If you are familiar with MongoDB and/or already have an instance running on your machine then skip this post and head straight to the demo posts if not stay close and we’ll cover setting up an instance of MongoDB in a few easy steps.
Getting MongoDB running on your machine
Step 1: Download a version of MongoDB form the MongoDB website http://www.mongodb.org/downloads.
Note: Version 2.0.9 was used for the demos, but since the demos cover very rudimentary functionality a newer version of MongoDB can be downloaded.
Step 2: Once the MongoDB has been downloaded, unzip the zip file to a working folder and find the bin folder, this folder contains all the exe files required to run MongoDB.
Step 3: On your C drive create a folder called “data_mongo” and copy the bin folder from step 2 into this folder.
Step 4: Run the following command to start MongoDB.
c:\data_mongo\bin\mongod --dbpath c:/data_mongo/db
Looking at the command above the following can be noted:
- The executable mongod.exe is the server executable
- The parameter –dbpath defines the path where the databases files reside. Note if the dbpath parameter is not supplied MongoBD will default to the path “c:\data\db”
- The parameter –port can also be included if you with to have MongoDB run off a different port. By default MongoDB will run off port 27017 if no port parameter has been inlcuded
You now have an instance of MongoDB running on your machine. The instance is listening on port 27017 and will write data to the path “c:\data_mongo\db”.
Proceed to the first demo to start creating a database and inserting data.