Set Up MongoDB on Windows
Download the MongoDB binary archive
For Windows platform, MongoDB distributes zip
archive. Go to following downloads page from browser http://www.mongodb.org/downloads
Depends on system
architecture, it comes in two distribution as
- 32-bit
- 64-bit
Downloading the
64-bit is recommended
After you download,
you will get zip archive in follwing format-
mongodb—.zip
Extract MongoDB archive (D:\MongoDB)
Now extract archive
using any zip extract program. After extracting, you will get the directories
inside archive as follows
here , bin directory contains the binaries in form of
executable , such as mongod.exe, mongo.exe, monogexport.exe etc.
Setup up configuration parameters and start/stop
MongoDB
For starting and stopping the MongoDB server, we
need only the bin/mongod.exe, which is the daemon process executable
for MongoDB. In short, it is the executable which starts up the MongoDB Server.
For starting up, we
need to provide the parameters for executable, which i call it here as config
parameters or params.
We can setup the
config parameters using the two ways
- Using command line options or
- Using config file
Now create two folders one is data in D:\MongoDB and other is
log in D:\MongoDB which looks like
Using command line options
Run command line as
administrator.
Use the following
commands to start the server process
Change to bin directory
cd D:\MongoDB\bin
|
now type following
command to start the mongod process
mongod --dbpath D:\MongoDB\data --port 27017
|
As we specify the
logpath option, then logging will direct to that log file instead of showing up
on standard console
$> mongod --dbpath D:\MongoDB\data --port 27017 --logpath D:\MongoDB\log\mongod.log
|
Using the
config file
Create a folder config in D:\MongoDB\config
Instead of specifying command line option, we can specify same
with use of file, which i call it here as config file Config file is just text
file, containing the parameters in the key=value form and each one is specified
on the every line of file In this, we basically provide path to file (which
contains the configurations) as command line option as “-f” or “–config”
Following is the snippet for the config file
dbpath = D:\MongoDB\data port
= 27017 logpath = D:\MongoDB\log\mongo.log
You can save this file with any extension, but specify full path
with extension, while stating process as shown in following commands. From
command prompt, you will use either of following
mongod -f D:\MongoDB\config\mongodb.sharjeel
or
mongod --config D:\MongoDB\config\mongodb.conf
Comments
Post a Comment