|
| 1 | +============================= |
| 2 | +Release Notes for MongoDB 2.0 |
| 3 | +============================= |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +.. contents:: See the :doc:`full index of this page <2.0-changes>` for |
| 8 | + a complete list of changes included in 2.0. |
| 9 | + :backlinks: none |
| 10 | + :local: |
| 11 | + :depth: 1 |
| 12 | + |
| 13 | +Upgrading |
| 14 | +--------- |
| 15 | + |
| 16 | +Although the major version number has changed, MongoDB 2.0 is a |
| 17 | +standard, incremental production release and works as a drop-in |
| 18 | +replacement for MongoDB 1.8. |
| 19 | + |
| 20 | +Preparation |
| 21 | +~~~~~~~~~~~ |
| 22 | + |
| 23 | +There are a few changes you must be aware of before attempting to |
| 24 | +upgrade. Read through all release notes before upgrading, and ensure |
| 25 | +that no changes will affect your deployment. |
| 26 | + |
| 27 | +If you create new indexes in 2.0, then downgrading to 1.8 |
| 28 | +:wiki:`is possible <mongo+-+Index+Versions>` |
| 29 | +but reindexing the new collections will be required. |
| 30 | + |
| 31 | +``mongoimport`` and ``mongoexport`` now correctly adhere to the CSV spec |
| 32 | +for handling CSV input/output. This may break existing import/export |
| 33 | +workflows if they relied on the broken behavior. For more information |
| 34 | +see the related `JIRA case <https://jira.mongodb.org/browse/SERVER-1097>`_. |
| 35 | + |
| 36 | +`Journaling <http://api.mongodb.org/wiki/current/Journaling.html>`_ is |
| 37 | +**enabled by default** in 2.0 for 64-bit builds. If you still prefer to |
| 38 | +run without journaling, start :program:`mongod` with the ``--nojournal`` |
| 39 | +option. Otherwise, the journal files will be created on startup. The |
| 40 | +first time you start :program:`mongod` with journaling, you will see a |
| 41 | +delay while the new files are being created. In addition, you may see |
| 42 | +reduced write throughput. |
| 43 | + |
| 44 | +2.0 processes can talk to 1.8 processes and vice versa, so you can |
| 45 | +upgrade various parts of a cluster in any order. |
| 46 | + |
| 47 | +.. _2.0-upgrade-standalone: |
| 48 | + |
| 49 | +Upgrading a Standalone ``mongod`` |
| 50 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 51 | + |
| 52 | +1. Download the v2.0.x binaries from the `MongoDB Download Page`_. |
| 53 | + |
| 54 | +#. Shutdown your :program:`mongod` instance. Replace the existing |
| 55 | + binary with the 2.0.x :program:`mongod` binary and restart MongoDB. |
| 56 | + |
| 57 | +.. _`MongoDB Download Page`: http://downloads.mongodb.org/ |
| 58 | + |
| 59 | +.. _2.0-upgrade-replica-set: |
| 60 | + |
| 61 | +Upgrading a Replica Set |
| 62 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 63 | + |
| 64 | +1. Upgrade the :term:`secondary` members of the set one at a time by |
| 65 | + shutting down the :program:`mongod` and replacing the 1.8 binary |
| 66 | + with the 2.0.x binary from the `MongoDB Download Page`_. |
| 67 | + |
| 68 | +#. To avoid losing the last few updates on failover you can |
| 69 | + temporarily halt your application (failover should take less than 10 |
| 70 | + seconds) or change your application code to |
| 71 | + `confirm that each update reaches multiple servers <http://api.mongodb.org/wiki/current/Verifying%20Propagation%20of%20Writes%20with%20getLastError.html>`_. |
| 72 | + |
| 73 | +#. Use the :method:`rs.stepDown()` to step down the primary to allow |
| 74 | + the normal :ref:`failover <mongo+-+replica-set-failover>` procedure. |
| 75 | + |
| 76 | + :method:`rs.stepDown()` and :dbcommand:`replSetStepDown` provide for |
| 77 | + shorter and more consistent failover procedures than simply |
| 78 | + shutting down the primary directly. |
| 79 | + |
| 80 | + When the primary has stepped down, shut down its instance and |
| 81 | + upgrade by replacing the :program:`mongod` binary with the 2.0.x |
| 82 | + binary. |
| 83 | + |
| 84 | +.. _2.0-upgrade-shard-cluster: |
| 85 | + |
| 86 | +Upgrading a Shard Cluster |
| 87 | +~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 88 | + |
| 89 | +1. Upgrade all :program:`mongos` instances *first*, in any order. Since |
| 90 | + config servers use two-phase commit, `shard` configuration metadata |
| 91 | + updates will halt until all are up and running. |
| 92 | + |
| 93 | +#. Upgrade :program:`mongos` routers in any order. |
| 94 | + |
| 95 | +Changes |
| 96 | +------- |
| 97 | + |
| 98 | +Compact Command |
| 99 | +~~~~~~~~~~~~~~~ |
| 100 | + |
| 101 | +A :dbcommand:`compact` command is now available for compacting a single |
| 102 | +collection and its indexes. Previously, the only way to compact was to |
| 103 | +repair the entire database. |
| 104 | + |
| 105 | +Concurrency Improvements |
| 106 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 107 | + |
| 108 | +When going to disk, the server will yield the write lock if the data |
| 109 | +being acted upon isn't likely to be in memory. The initial |
| 110 | +implementation of this feature now exists: |
| 111 | +`(SERVER-2563) <https://jira.mongodb.org/browse/SERVER-2563>`_ |
| 112 | + |
| 113 | +The specific operations yield in 2.0 are: |
| 114 | + |
| 115 | +- Updates by _id |
| 116 | + |
| 117 | +- Removes |
| 118 | + |
| 119 | +- Long cursor iterations |
| 120 | + |
| 121 | +Default Stack Size |
| 122 | +~~~~~~~~~~~~~~~~~~ |
| 123 | + |
| 124 | +The default stack size has been reduced. This can reduce total memory |
| 125 | +usage when there are many (e.g., 1000+) client connections, as there is |
| 126 | +a thread per connection. While portions of a thread's stack can be |
| 127 | +swapped out if unused, some operating systems do this slowly enough that |
| 128 | +it might be an issue. The stack size will be set to the lesser of the |
| 129 | +system setting or 1MB. |
| 130 | + |
| 131 | +Index Performance Enhancements |
| 132 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 133 | + |
| 134 | +v2.0 includes `significant improvements to the index structures <http://api.mongodb.org/wiki/current/Index%20Versions.html>`_. |
| 135 | +Indexes are often 25% smaller and 25% faster (depends on the use case). |
| 136 | +When upgrading from previous versions, the benefits of the new index |
| 137 | +type are realized only if you create a new index or re-index an old one. |
| 138 | + |
| 139 | +Dates are now signed, and the max index key size has increased slightly |
| 140 | +from 819 to 1024 bytes. |
| 141 | + |
| 142 | +Once you create new indexes, downgrading to 1.8.x will require a |
| 143 | +re-index of any indexes created using 2.0. |
| 144 | + |
| 145 | +Sharding Authentication |
| 146 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 147 | + |
| 148 | +Authentication can now be used with :term:`sharded clusters <shard cluster>`. |
| 149 | + |
| 150 | +Replica Sets |
| 151 | +~~~~~~~~~~~~ |
| 152 | + |
| 153 | +Priorities |
| 154 | +`````````` |
| 155 | + |
| 156 | +Each :term:`replica set` member can now have a priority value consisting of a |
| 157 | +floating-point from 0 to 1000, inclusive. Priorities let you control |
| 158 | +which member of the set you prefer to have as :term:`primary`: the member with |
| 159 | +the highest priority that can see a majority of the set will be elected |
| 160 | +primary. |
| 161 | + |
| 162 | +For example, suppose we have a replica set with three members, ``A``, ``B``, and |
| 163 | +``C``, and that their priorities are set as follows: |
| 164 | + |
| 165 | +- ``A``'s priority is ``2``. |
| 166 | + |
| 167 | +- ``B``'s priority is ``3``. |
| 168 | + |
| 169 | +- ``C``'s priority is ``1``. |
| 170 | + |
| 171 | +During normal operation, ``B`` will always be chosen as primary. If ``B`` goes |
| 172 | +down, ``A`` will be elected primary. |
| 173 | + |
| 174 | +See the :ref:`Node Priority` documentation for more information. |
| 175 | + |
| 176 | +Data-center awareness |
| 177 | +`````````````````````` |
| 178 | + |
| 179 | +You can now "tag" :term:`replica set` members to indicate their |
| 180 | +location. You can use these tags to design custom :term:`write rules <write concern>` |
| 181 | +across data centers, racks, specific servers, or any other |
| 182 | +architecture choice. |
| 183 | + |
| 184 | +For example, a DBA could define rules such as "very important write" or |
| 185 | +"customerData" or "audit-trail" to be replicated to certain servers, |
| 186 | +racks, data centers, etc. Then in the application code, the developer |
| 187 | +would say: |
| 188 | + |
| 189 | +.. code-block:: javascript |
| 190 | + |
| 191 | + db.foo.insert(doc, {w : "very important write"}) |
| 192 | + |
| 193 | +which would succeed if it fulfilled the conditions the DBA defined for |
| 194 | +"very important write". |
| 195 | + |
| 196 | +For more information, see the |
| 197 | +`tagging documentation <http://api.mongodb.org/wiki/current/Data%20Center%20Awareness.html#DataCenterAwareness-Tagging%28version2.0%29>`_. |
| 198 | + |
| 199 | +Your driver may also support tag-aware reads. Instead of simply |
| 200 | +specifying ``slaveOk``, you specify ``slaveOk`` with tags indicating which |
| 201 | +data-centers you want to read from. See your |
| 202 | +`driver <http://docs.mongodb.org/manual/applications/drivers/>`_ |
| 203 | +for details. |
| 204 | + |
| 205 | +``w`` : ``majority`` |
| 206 | +```````````````````` |
| 207 | + |
| 208 | +You can also set ``w`` to ``majority`` to ensure that a write has been |
| 209 | +propagated to a majority of nodes, effectively committing it. The value |
| 210 | +for "majority" will automatically be adjusted as you add or remove nodes |
| 211 | +from the set. |
| 212 | + |
| 213 | +For more information, see :ref:`replica-set-write-concern`. |
| 214 | + |
| 215 | +Reconfiguration with a minority up |
| 216 | +`````````````````````````````````` |
| 217 | + |
| 218 | +If the majority of servers in a set has been permanently lost, you can |
| 219 | +now force a reconfiguration of the set to bring it back online. |
| 220 | + |
| 221 | +See more information on :ref:`Reconfiguring a replica set when members are down <mongo+-+http://www.mongodb.org/display/DOCS/Reconfiguring+a+replica+set+when+members+are+down>`. |
| 222 | + |
| 223 | +Primary checks for a caught up secondary before stepping down |
| 224 | +````````````````````````````````````````````````````````````` |
| 225 | + |
| 226 | +To minimize time without a :term:`primary`, the :method:`rs.stepDown()` |
| 227 | +method will now fail if the primary does not see a :term:`secondary` |
| 228 | +within 10 seconds of its latest optime. You can force the primary to |
| 229 | +step down anyway, but by default it will return an error message. |
| 230 | + |
| 231 | +See also |
| 232 | +:ref:`Forcing a Member to be Primary <mongo+-+http://www.mongodb.org/display/DOCS/Forcing+a+Member+to+be+Primary>`. |
| 233 | + |
| 234 | +Extended shutdown on the primary to minimize interruption |
| 235 | +````````````````````````````````````````````````````````` |
| 236 | + |
| 237 | +When you call the :dbcommand:`shutdown` command, the :term:`primary` |
| 238 | +will refuse to shut down unless there is a :term:`secondary` whose |
| 239 | +optime is within 10 seconds of the primary. If such a secondary isn't |
| 240 | +available, the primary will step down and wait up to a minute for the |
| 241 | +secondary to be fully caught up before shutting down. |
| 242 | + |
| 243 | +Note that to get this behavior, you must issue the :dbcommand:`shutdown` |
| 244 | +command explicitly; sending a signal to the process will not trigger |
| 245 | +this behavior. |
| 246 | + |
| 247 | +You can also force the primary to shut down, even without an up-to-date |
| 248 | +secondary available. |
| 249 | + |
| 250 | +Maintenance Mode |
| 251 | +```````````````` |
| 252 | + |
| 253 | +When ``repair`` or ``compact`` is run on a :term:`secondary`, the |
| 254 | +secondary will automatically drop into "recovering" mode until the |
| 255 | +operation is finished. This prevents clients from trying to read from it |
| 256 | +while it's busy. |
| 257 | + |
| 258 | +Geospatial Features |
| 259 | +~~~~~~~~~~~~~~~~~~~ |
| 260 | + |
| 261 | +Multi-location documents |
| 262 | +```````````````````````` |
| 263 | + |
| 264 | +Indexing is now supported on documents which have multiple location |
| 265 | +objects, embedded either inline or in nested sub-documents. Additional |
| 266 | +command options are also supported, allowing results to be returned with |
| 267 | +not only distance but the location used to generate the distance. |
| 268 | + |
| 269 | +For more information, see the :ref:`Geospatial documentation <mongo+-+http://www.mongodb.org/display/DOCS/Geospatial+Indexing#GeospatialIndexing-MultilocationDocuments>`. |
| 270 | + |
| 271 | +Polygon searches |
| 272 | +```````````````` |
| 273 | + |
| 274 | +Polygonal ``$within`` queries are also now supported for simple polygon |
| 275 | +shapes. For details, see the :operator:`$within` operator documentation. |
| 276 | + |
| 277 | +Journaling enhancements |
| 278 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 279 | + |
| 280 | +- Journaling is now enabled by default for 64-bit platforms. Use the |
| 281 | + ``--nojournal`` command line option to disable it. |
| 282 | + |
| 283 | +- The journal is now compressed for faster commits to disk. |
| 284 | + |
| 285 | +- A new :option:`--journalCommitInterval` command line option exists for |
| 286 | + specifying your own group commit interval. 100ms is the default (same as |
| 287 | + in 1.8). |
| 288 | + |
| 289 | +- A new :dbcommand:`getLastError{j: true} <getLastError>` option is |
| 290 | + available to wait for the group commit. The group commit will happen |
| 291 | + sooner when a client is waiting on ``{j: true}``. If journaling is |
| 292 | + disabled, ``{j: true}`` is a no-op. |
| 293 | + |
| 294 | +New ``ContinueOnError`` option for bulk insert |
| 295 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 296 | + |
| 297 | +When this flag is set (see your |
| 298 | +`driver <http://docs.mongodb.org/manual/applications/drivers/>`_ |
| 299 | +on how to set it), bulk insert will continue to insert any remaining |
| 300 | +documents even if an insert fails (due, for example, to a duplicate |
| 301 | +key). The :dbcommand:`getLastError` command will report whether any |
| 302 | +doc inserts have failed (not just last one). If multiple errors occur, |
| 303 | +only the most recent will be reported by :dbcommand:`getLastError`. |
| 304 | + |
| 305 | +See :ref:`OP_INSERT <mongo+-+http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPINSERT>`. |
| 306 | + |
| 307 | +Map Reduce |
| 308 | +~~~~~~~~~~ |
| 309 | + |
| 310 | +Output to a sharded collection |
| 311 | +`````````````````````````````` |
| 312 | + |
| 313 | +Using the new flag ``sharded`` it is possible to send the result of a |
| 314 | +map/reduce to a sharded collection. Combined with the ``reduce`` or |
| 315 | +``merge`` flags, it is possible to keep adding data to very large |
| 316 | +collections from map/reduce jobs. |
| 317 | + |
| 318 | +For more information, see the |
| 319 | +:ref:`output options <mongo+-+http://www.mongodb.org/display/DOCS/MapReduce#MapReduce-Outputoptions>`. |
| 320 | +documentation. |
| 321 | + |
| 322 | +Performance improvements |
| 323 | +```````````````````````` |
| 324 | + |
| 325 | +Map/reduce performance will benefit from the following: |
| 326 | + |
| 327 | +- Larger in-memory buffer sizes, reducing the amount of disk I/O needed |
| 328 | + during a job |
| 329 | + |
| 330 | +- Larger javascript heap size, allowing for larger objects |
| 331 | + and less GC |
| 332 | + |
| 333 | +- Supports pure JS execution with the jsMode flag. See :doc:`mapReduce`. |
| 334 | + |
| 335 | +New Querying Features |
| 336 | +~~~~~~~~~~~~~~~~~~~~~ |
| 337 | + |
| 338 | +Additional regex options: ``s`` |
| 339 | +``````````````````````````````` |
| 340 | + |
| 341 | +Allows the dot (.) to match all characters including new lines. This is |
| 342 | +in addition to the currently supported ``i``, ``m`` and ``x``. See |
| 343 | +:ref:`Using regular expressions in queries <mongo+-+http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-RegularExpressions>`. |
| 344 | + |
| 345 | +$and |
| 346 | +```` |
| 347 | + |
| 348 | +A special boolean :operator:`$and` query operator is now available. |
| 349 | + |
| 350 | +Command output changes |
| 351 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 352 | + |
| 353 | +The output of the :dbcommand:`validate` command and the documents in the |
| 354 | +``system.profile`` collection have both been enhanced to return |
| 355 | +information as BSON objects with keys for each value rather than as |
| 356 | +free-form strings. |
| 357 | + |
| 358 | +Shell features |
| 359 | +~~~~~~~~~~~~~~ |
| 360 | + |
| 361 | +Custom prompt |
| 362 | +````````````` |
| 363 | + |
| 364 | +You can define a custom prompt for the :program:`mongo` shell. You can |
| 365 | +change the prompt at any time by setting the prompt variable to a string |
| 366 | +or a custom JavaScript function returning a string. For examples, see the |
| 367 | +documentation on |
| 368 | +:ref:`Custom Prompt <mongo+-+http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell#Overview-TheMongoDBInteractiveShell-CustomPrompt>`. |
| 369 | + |
| 370 | +Default shell init script |
| 371 | +````````````````````````` |
| 372 | + |
| 373 | +On startup, the shell will check for a ``.mongorc.js`` file in the |
| 374 | +user's home directory. The shell will execute this file after connecting |
| 375 | +to the database and before displaying the prompt. |
| 376 | + |
| 377 | +If you would like the shell not to run the ``.mongorc.js`` file |
| 378 | +automatically, start the shell with ``--norc``. |
| 379 | + |
| 380 | +For more information, see :doc:`mongo`. |
| 381 | + |
| 382 | +Resources |
| 383 | +--------- |
| 384 | + |
| 385 | +- `MongoDB Downloads <http://mongodb.org/downloads>`_ |
| 386 | +- `All JIRA Issues resolved in 2.0 <https://jira.mongodb.org/secure/IssueNavigator.jspa?mode=hide&requestId=11002>`_ |
| 387 | +- `All Backward Incompatible Changes <https://jira.mongodb.org/secure/IssueNavigator.jspa?requestId=11023>_` |
0 commit comments