|
| 1 | +:orphan: |
| 2 | + |
1 | 3 | =========================================
|
2 | 4 | Install MongoDB on Debian or Ubuntu Linux
|
3 | 5 | =========================================
|
4 | 6 |
|
5 | 7 | .. default-domain:: mongodb
|
6 | 8 |
|
7 |
| -Synopsis |
8 |
| --------- |
9 |
| - |
10 |
| -This tutorial outlines the basic installation process for installing |
11 |
| -:term:`MongoDB` on Ubuntu and Debian Linux systems. This tutorial uses |
12 |
| -``.deb`` packages as the basis of the installation. 10gen publishes |
13 |
| -packages of the MongoDB releases as ``.deb`` packages for easy |
14 |
| -installation and management for users of Debian systems. While some of |
15 |
| -these distributions include their own MongoDB packages, the 10gen |
16 |
| -packages are generally more up to date. |
17 |
| - |
18 |
| -This tutorial includes: an overview of the available packages, |
19 |
| -instructions for configuring the package manager, the process install |
20 |
| -packages from the 10gen repository, and preliminary MongoDB |
21 |
| -configuration and operation. |
22 |
| - |
23 |
| -.. seealso:: The documentation of following related processes and |
24 |
| - concepts. |
25 |
| - |
26 |
| - Other installation tutorials: |
27 |
| - |
28 |
| - - :doc:`/tutorial/install-mongodb-on-redhat-centos-or-fedora-linux` |
29 |
| - - :doc:`/tutorial/install-mongodb-on-linux` |
30 |
| - - :doc:`/tutorial/install-mongodb-on-os-x` |
31 |
| - |
32 |
| - .. STUB :doc:`/tutorial/install-mongodb-on-windows` |
33 |
| - |
34 |
| - .. Documentation for getting started with MongoDB: |
35 |
| - |
36 |
| - .. - :doc:`/getting-started` |
37 |
| - .. - :doc:`/tutorial/insert-test-data-into-a-mongodb-database` |
38 |
| - |
39 |
| -Package Options |
40 |
| ---------------- |
41 |
| - |
42 |
| -The 10gen repository contains three packages: |
43 |
| - |
44 |
| -- ``mongodb-10gen`` |
45 |
| - |
46 |
| - This package contains the latest **stable** release. Use this for |
47 |
| - production deployments. |
48 |
| - |
49 |
| -- ``mongodb20-10gen`` |
50 |
| - |
51 |
| - This package contains the stable release of v2.0 branch. |
52 |
| - |
53 |
| -- ``mongodb18-10gen`` |
54 |
| - |
55 |
| - This package contains the stable release of v1.8 branch. |
56 |
| - |
57 |
| -You cannot install these packages concurrently with each other or with |
58 |
| -the ``mongodb`` package that your release of Debian or Ubuntu may |
59 |
| -include. |
60 |
| - |
61 |
| -Installing MongoDB |
62 |
| ------------------- |
63 |
| - |
64 |
| -Configure Package Management System (APT) |
65 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
66 |
| - |
67 |
| -The Debian/Ubuntu package management tool (i.e. ``dpkg`` and ``apt``) |
68 |
| -ensure package consistency and authenticity by requiring that |
69 |
| -distributors sign packages with GPG keys. Issue the following command |
70 |
| -to import the `10gen public GPG Key <http://docs.mongodb.org/10gen-gpg-key.asc>`_: |
71 |
| - |
72 |
| -.. code-block:: sh |
73 |
| - |
74 |
| - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 |
75 |
| - |
76 |
| -Create a the ``/etc/apt/sources.list.d/10gen.list`` file and include |
77 |
| -the following line for the 10gen repository. |
78 |
| - |
79 |
| -If you use an Ubuntu version with "Upstart" (i.e. any since version |
80 |
| -9.10 "Karmic,") or are running with Upstart on Debian, use the |
81 |
| -following line: |
82 |
| - |
83 |
| -.. code-block:: sources.list |
84 |
| - |
85 |
| - deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen |
86 |
| - |
87 |
| -If you are using Debian or Ubuntu that uses SysV style init process, |
88 |
| -use the following line: |
89 |
| - |
90 |
| -.. code-block:: sources.list |
91 |
| - |
92 |
| - deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen |
93 |
| - |
94 |
| -Now issue the following command to reload your repository: |
95 |
| - |
96 |
| -.. code-block:: sh |
97 |
| - |
98 |
| - sudo apt-get update |
99 |
| - |
100 |
| -Install Packages |
101 |
| -~~~~~~~~~~~~~~~~ |
102 |
| - |
103 |
| -Issue the following command to install the latest stable version of |
104 |
| -MongoDB: |
105 |
| - |
106 |
| -.. code-block:: sh |
107 |
| - |
108 |
| - sudo apt-get install mongodb-10gen |
109 |
| - |
110 |
| -When this command completes, you have successfully installed MongoDB! |
111 |
| -Continue for configuration and start-up suggestions. |
112 |
| - |
113 |
| -Configure MongoDB |
114 |
| ------------------ |
115 |
| - |
116 |
| -These packages configure MongoDB using the ``/etc/mongodb.conf`` file |
117 |
| -in conjunction with the :term:`control script`. For Upstart-based |
118 |
| -systems, find the control script is at ``/etc/init/mongodb.conf``. For |
119 |
| -all other systems you can find the control script at |
120 |
| -``/etc/init.d/mongodb``. |
121 |
| - |
122 |
| -This MongoDB instance will store its data files in the |
123 |
| -``/var/lib/mongodb`` and its log files in ``/var/log/mongodb``, and |
124 |
| -run using the ``mongodb`` user account. |
125 |
| - |
126 |
| -.. note:: |
127 |
| - |
128 |
| - If you change the user that runs the MongoDB process, you will need |
129 |
| - to modify the access control rights to the ``/var/lib/mongodb`` and |
130 |
| - ``/var/log/mongodb`` directories. |
131 |
| - |
132 |
| -Controlling MongoDB |
133 |
| --------------------- |
134 |
| - |
135 |
| -Starting MongoDB |
136 |
| -~~~~~~~~~~~~~~~~ |
137 |
| - |
138 |
| -Upstart users can start the :program:`mongod` process by issuing the |
139 |
| -following command: |
140 |
| - |
141 |
| -.. code-block:: sh |
142 |
| - |
143 |
| - sudo service mongodb start |
144 |
| - |
145 |
| -All other users can issue the following command to start :program:`mongod`: |
146 |
| - |
147 |
| -.. code-block:: sh |
148 |
| - |
149 |
| - sudo /etc/init.d/mongodb start |
150 |
| - |
151 |
| -You can verify that :program:`mongod` has started successfully by checking the |
152 |
| -contents of the log file at ``/var/log/mongodb/mongodb.log``. |
153 |
| - |
154 |
| -Stopping MongoDB |
155 |
| -~~~~~~~~~~~~~~~~ |
156 |
| - |
157 |
| -Upstart users can stop the :program:`mongod` process by issuing the following |
158 |
| -command: |
159 |
| - |
160 |
| -.. code-block:: sh |
161 |
| - |
162 |
| - sudo service mongodb stop |
163 |
| - |
164 |
| -All other users can issue the following command to stop :program:`mongod`: |
165 |
| - |
166 |
| -.. code-block:: sh |
167 |
| - |
168 |
| - sudo /etc/init.d/mongodb stop |
169 |
| - |
170 |
| -Restarting MongoDB |
171 |
| -~~~~~~~~~~~~~~~~~~ |
172 |
| - |
173 |
| -Upstart users can restart the :program:`mongod` process by issuing the |
174 |
| -following command: |
175 |
| - |
176 |
| -.. code-block:: sh |
177 |
| - |
178 |
| - sudo service mongodb restart |
179 |
| - |
180 |
| -All other users can issue the following command to restart |
181 |
| -:program:`mongod`: |
182 |
| - |
183 |
| -.. code-block:: sh |
184 |
| - |
185 |
| - sudo /etc/init.d/mongodb restart |
186 |
| - |
187 |
| -Controlling :program:`mongos` |
188 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
189 |
| - |
190 |
| -As of the current release, there are no :term:`control scripts |
191 |
| -<control script>` for :program:`mongos`. :program:`mongos` is only |
192 |
| -used in sharding deployments and typically do not run on the same |
193 |
| -systems where :program:`mongod` runs. You can use the ``mongodb`` |
194 |
| -script referenced above to derive your own :program:`mongos` control |
195 |
| -script. |
196 |
| - |
197 |
| -Using MongoDB |
198 |
| -------------- |
199 |
| - |
200 |
| -Among the tools included with the MongoDB package, is the |
201 |
| -:program:`mongo` shell. You can connect to your MongoDB instance by |
202 |
| -issuing the following command at the system prompt: |
203 |
| - |
204 |
| -.. code-block:: sh |
205 |
| - |
206 |
| - mongo |
207 |
| - |
208 |
| -This will connect to the database running on the localhost interface |
209 |
| -by default. At the :program:`mongo` prompt, issue the following two |
210 |
| -commands to insert a record in the "test" :term:`collection` of the |
211 |
| -(default) "test" database. |
| 9 | +10gen publishes packages of the MongoDB releases as ``.deb`` packages |
| 10 | +for easy installation and management for users of Debian and Ubuntu |
| 11 | +systems. While some of these distributions include their own MongoDB |
| 12 | +packages, the 10gen packages are generally more up to date. The |
| 13 | +procedure for installing MongoDB on these systems is generally |
| 14 | +similar; however: |
212 | 15 |
|
213 |
| -.. code-block:: javascript |
| 16 | +#. Users of systems that run "Upstart," which includes versions of |
| 17 | + Ubuntu since 9.10 "Karmic," use the following tutorial: |
214 | 18 |
|
215 |
| - > db.test.save( { a: 1 } ) |
216 |
| - > db.test.find() |
| 19 | + :doc:`/tutorial/install-mongodb-on-ubuntu` |
217 | 20 |
|
218 |
| -.. seealso:: ":program:`mongo`" and ":doc:`/reference/javascript`" |
| 21 | +#. Users of all other systems, which use SysV style init processes, |
| 22 | + should use the following tutorial: |
| 23 | + |
| 24 | + :doc:`/tutorial/install-mongodb-on-debian` |
0 commit comments