Skip to content

Commit 0d5fad8

Browse files
author
Andrew Leung
committed
DOCS-155 Windows Installation Tutorial
1 parent 3327e79 commit 0d5fad8

File tree

1 file changed

+143
-58
lines changed

1 file changed

+143
-58
lines changed

source/tutorial/install-mongodb-on-windows.txt

Lines changed: 143 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,68 @@ This tutorial outlines the basic installation process for
1212
tutorial provides a basic method for installing and running the
1313
MongoDB server (i.e. ":program:`mongod.exe`") and associated tools.
1414

15-
Downloading MongoDB for Windows
16-
-------------------------------
15+
MongoDB for Windows
16+
-------------------
1717

18-
Download the latest production release of MongoDB. The various MongoDB
19-
binaries can be downloaded `here. <http://www.mongodb.org/downloads>`_
18+
MongoDB for Windows is very similar to it MongoDB for other
19+
platforms. MongoDB components work in the same way and with similar
20+
parameters to MongoDB for other platforms. This tutorial will guide
21+
you to install MongoDB on Windows through the :guilabel:`Command
22+
Shell` and setting up MongoDB as a :guilabel:`Windows Service`.
23+
24+
Download MongoDB for Windows
25+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26+
27+
Download the latest production release of MongoDB from `here. <http://www.mongodb.org/downloads>`_
2028

2129
.. note::
2230

23-
Ensure you download the proper version of MongoDB for your version
24-
of Windows. The 64-bit version of MongoDB will not work in 32-bit
25-
version of Windows. You can find the version of your Windows system
26-
using this `guide. <http://windows.microsoft.com/en-US/windows7/find-out-32-or-64-bit>`_
31+
Ensure you download the proper version of MongoDB for your
32+
architecture of Windows. The 64-bit version of MongoDB will not
33+
work in 32-bit Windows.
2734

2835
The 32-bit versions of MongoDB are suitable for testing and
29-
evaluation purposes but cannot use databases larger than 3GB.
36+
evaluation purposes but cannot use databases larger than 2GB.
37+
38+
The architecture of your version of Windows can be found using this
39+
command in the :guilabel:`Command Shell`
40+
41+
.. code-block:: powershell
42+
43+
wmic os get osarchitecture
3044

31-
Once the download is complete, use Windows Explorer to find the
32-
MongoDB download file (typically in the default Downloads directory)
33-
and extract the archive to ``C:\`` by right clicking on the
34-
archive and selecting "Extract All" and browsing to: ``C:\``
45+
In Windows Explorer, find the MongoDB download file, typically in the
46+
default Downloads directory, and extract the archive to ``C:\`` by
47+
right clicking on the archive and selecting :guilabel:`Extract All`
48+
and browsing to: ``C:\``
3549

3650
.. note::
3751

38-
The folder name will be in the format:
52+
The folder name will be either:
53+
54+
.. code-block:: powershell
55+
56+
C:\mongodb-win32-i386-[version]
57+
58+
Or:
59+
60+
.. code-block:: powershell
61+
62+
C:\mongodb-win32-x86_64-[version]
3963

40-
mongodb-win32-ARCH-VERSION
64+
In both examples, replace ``[version]`` with the version of MongoDB
65+
downloaded.
4166

42-
where ARCH is the 32-bit/64-bit version of MongoDB and VERSION is
43-
the version of MongoDB
67+
Set up the environment
68+
~~~~~~~~~~~~~~~~~~~~~~
4469

45-
Start the Command Prompt (Start Menu -> All Programs -> Accessories ->
46-
Command Prompt) by right clicking and selecting 'Run as
47-
Administrator' from the popup menu. In the Command Prompt, run commands:
70+
Start the :guilabel:`Command Shell` by selecting the :guilabel:`Start
71+
Menu`, then :guilabel:`All Programs`, then :guilabel:`Accessories`,
72+
then right click :guilabel:`Command Shell`, and select :guilable:'Run
73+
as Administrator' from the popup menu. In the :guilabel:`Command Shell`,
74+
issue the following commands:
4875

49-
.. code-block:: sh
76+
.. code-block:: powershell
5077

5178
cd \
5279
rename C:\mongodb-win32-* C:\mongodb
@@ -58,86 +85,144 @@ Administrator' from the popup menu. In the Command Prompt, run commands:
5885
may install MongoDB in a different directory such as:
5986
``D:\test\mongodb``
6087

61-
Creating data Folder
62-
~~~~~~~~~~~~~~~~~~~~
88+
By default, MongoDB requires a data folder to store files. By default
89+
this is: ``C:\data\db``. Create this folder in ``C:\`` in the
90+
:guilabel:`Command Shell` by issuing the following commands
6391

64-
By default, MongoDB uses ``C:\data\db`` to write and store data
65-
files. Create this folder in C:\ in the Command Prompt using the
66-
following commands:
67-
68-
.. code-block:: sh
92+
.. code-block:: powershell
6993

7094
mkdir data
7195
mkdir data\db
7296

73-
If this folder does not exist, MongoDB will not start.
74-
7597
.. note::
7698

7799
You can specify an alternate path for data\db folder using the
78100
:option:`--dbpath <mongod --dbpath>` option to
79101
:program:`mongod`. To start mongod.exe with another file path, use
80-
the command: ``C:\mongodb\bin\mongod.exe --dbpath
81-
d:\test\mongodb\data``
102+
the command:
103+
104+
.. code-block:: powershell
82105

106+
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
83107

84-
Starting MongoDB
85-
~~~~~~~~~~~~~~~~
86108

87-
To start MongoDB, execute from the Command Prompt:
109+
Start MongoDB for Windows
110+
~~~~~~~~~~~~~~~~~~~~~~~~~
88111

89-
.. code-block:: sh
112+
To start MongoDB, execute from the :guilabel:`Command Shell`:
113+
114+
.. code-block:: powershell
90115

91116
C:\mongodb\bin\mongod.exe
92117

93-
This will start the main MongoDB database process. To connect using
94-
the ``mongo.exe`` open another Command Prompt and execute:
118+
This will start the main MongoDB database process.
119+
120+
.. note::
121+
122+
Depending on the security level of your system, Windows will issue
123+
a :guilabel:`Security Alert` dialog box about blocking "some
124+
features" of ``C:\\mongodb\bin\mongod.exe`` from communicating on
125+
networks. All users should select ``Private Networks, such as my
126+
home or work network`` and click ``Allow access``. For additional
127+
information on security and MongoDB, please read the
128+
:wiki:`Security and Authentication <Security+and+Authentication>`
129+
wiki page.
130+
131+
.. warning::
132+
133+
Do not make :program:`mongod.exe` accessible to public networks
134+
without authentication (i.e. :setting:`auth`) on a public
135+
network. MongDB is designed to work within secured networks and
136+
will accept connections without authentication.
137+
138+
To connect to MongoDB using the :program:`mongo.exe`, open another
139+
:guilabel:`Command Shell` and issue command:
95140

96-
.. code-block:: sh
141+
.. code-block:: powershell
97142

98143
C:\mongodb\bin\mongo.exe
99144

100145
.. note::
101146

102147
Executing command: ``start C:\mongodb\bin\mongo.exe`` will
103-
automatically start MongoDB in a separate Command Prompt.
148+
automatically start MongoDB in a separate :guilabel:`Command Shell`.
104149

105150
This will connect to the database running on the localhost interface
106-
and port 27017 by default. At the :program:`mongo.exe` prompt, issue
107-
the following two commands to insert a record in the "test"
108-
:term:`collection` of the (default) "test" database and then retrieve
151+
and port ``27017`` by default. At the :program:`mongo.exe` prompt, issue
152+
the following two commands to insert a record in the ``test``
153+
:term:`collection` of the default ``test`` database and then retrieve
109154
that record:
110155

111156
.. code-block:: javascript
112157

113158
> db.test.save( { a: 1 } )
114159
> db.test.find()
115160

116-
Additional MongoDB guides to help you get started:
161+
.. seealso:: ":program:`mongo`" and ":doc:`/reference/javascript`"
162+
163+
164+
MongoDB as Windows Service
165+
--------------------------
166+
167+
.. versionadded:: 2.1.1
168+
169+
Setup MongoDB to be a :guilabel:`Windows Service`, starting
170+
automatically with each reboot.
171+
172+
Configure Windows Service Options
173+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174+
175+
You must specify two options when running MongoDB as a Windows
176+
Service: a directory for the log output and a :doc:`configuration file
177+
</reference/configuration-options>`.
178+
179+
#. Create a specific directory for MongoDB log files:
180+
181+
.. code-block:: powershell
182+
183+
mkdir C:\mongodb\log
184+
185+
#. Create a configuration file for the logpath option for MongoDB in
186+
the :guilabel:`Command Shell` by issuing this command:
187+
188+
.. code-block:: powershell
189+
190+
echo logpath=C:\mongodb\log > C:\mongodb\mongodb.cfg
191+
192+
193+
To Install and Run the MongoDB Service
194+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195+
196+
Run all of the following commands in :guilabel:`Command Shell` with
197+
"Administrative Privileges:"
198+
199+
#. To install the MongoDB service:
200+
201+
.. code-block:: powershell
202+
203+
C:\mongodb\bin\mongod.exe --config C:\mongodb\mongodb.cfg --install
204+
205+
#. To run the MongoDB Service:
117206

118-
.. Documentation for getting started with MongoDB:
207+
.. code-block:: powershell
119208

120-
.. - :doc:`/getting-started`
121-
.. STUB - :doc:`/tutorial/insert-test-data-into-a-mongodb-database`
209+
net start MongoDB
122210

211+
To Stop or Remove the MongoDB Service
212+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123213

214+
#. To stop MongoDB Service:
124215

125-
.. how do we use this??
126-
:program:`mongod.exe`
127-
:program:`mongo.exe`
128-
:program:`mongos.exe`
216+
.. code-block:: powershell
129217

130-
Production Use
131-
~~~~~~~~~~~~~~
218+
net stop MongoDB
132219

133-
If you're deploying MongoDB on a Windows server for production use,
134-
you may want to use the [whatever you call it].
220+
#. To remove MongoDB Service:
135221

136-
Do this...
222+
.. code-block:: powershell
137223

138-
.. code-block:: sh
224+
C:\mongodb\bin\mongod.exe --remove
139225

140-
TODO simple service example.
141226

142227

143228

0 commit comments

Comments
 (0)