UpgradingAlthough the major version number has changed, MongoDB 2.0 is a standard, incremental production release and works as a drop-in replacement for MongoDB 1.8. However, there are a few changes you must be aware of before attempting to upgrade:
What's NewCompact CommandA compact command is now available for compacting a single collection and its indexes. Previously, the only way to compact was to repair the entire database. Concurrency ImprovementsWhen going to disk, the server will yield the write lock if the data being acted upon isn't likely to be in memory. The initial implementation of this feature now exists: (SERVER-2563) The specific operations yield in 2.0 are:
Default Stack SizeThe default stack size has been reduced. This can reduce total memory usage when there are many (e.g., 1000+) client connections, as there is a thread per connection. While portions of a thread's stack can be swapped out if unused, some operating systems do this slowly enough that it might be an issue. The stack size will be set to the lesser of the system setting or 1MB. Index Performance Enhancementsv2.0 includes significant improvements to the index structures. Indexes are often 25% smaller and 25% faster (depends on the use case). When upgrading from previous versions, the benefits of the new index type are realized only if you create a new index or re-index an old one. Dates are now signed, and the max index key size has increased slightly from 819 to 1024 bytes. Once you create new indexes, downgrading to 1.8.x will require a re-index of any indexes created using 2.0. Sharding AuthenticationAuthentication can now be used with sharded clusters. Replica SetsPrioritiesEach replica set node can now have a priority value consisting of a floating-point from 0 to 1000, inclusive. Priorities let you control which member of the set you prefer to have as primary: the member with the highest priority that can see a majority of the set will be elected primary. For example, suppose we have a replica set with three nodes:
During normal operation, B will always be chosen as primary. If B goes down, A will be elected primary. See the priorities documentation for more information. Data-center awarenessYou can now "tag" replica set members to indicate their location. You can use these tags to design custom write rules across data centers, racks, specific servers, or any other architecture choice. For example, a DBA could define rules such as "very important write" or "customerData" or "audit-trail" to be replicated to certain servers, racks, data centers, etc. Then in the application code, the developer would say: > db.foo.insert(doc, {w : "very important write"})
which would succeed if it fulfilled the conditions the DBA defined for "very important write". See the tagging documentation for more information. Your driver may also support tag-aware reads. Instead of simply specifying slaveOk, you specify slaveOk with tags indicating which data-centers you want to read from. See your driver for details. w : "majority"You can also set w to "majority" to ensure that a write has been propagated to a majority of nodes, effectively committing it. The value for "majority" will automatically be adjusted as you add or remove nodes from the set. See the majority docs for more information. Reconfiguration with a minority upIf the majority of servers in a set has been permanently lost, you can now force a reconfiguration of the set to bring it back online. See more information on Reconfiguring a replica set when members are down. Primary checks for a caught up secondary before stepping downTo minimize time without a primary, the stepDown command will now fail if the primary does not see a secondary within 10 seconds of its latest optime. You can force the primary to step down anyway, but by default it will return an error message. See also Forcing a Member to be Primary. Extended shutdown on the primary to minimize interruptionWhen you call the shutdown command the primary will refuse to shut down unless there is a secondary whose optime is within 10 seconds of the primary. If such a secondary isn't available, the primary will step down and wait up to a minute for the secondary to be fully caught up before shutting down. Note that to get this behavior, you must issue the shutdown command explicitly; sending a signal to the process will not trigger this behavior. You can also force the primary to shut down, even without an up-to-date secondary available. Maintenance ModeWhen repair or compact is run on a secondary, the secondary will automatically drop into "recovering" mode until the operation is finished. This prevents clients from trying to read from it while it's busy. Geospatial FeaturesMulti-location documentsIndexing is now supported on documents which have multiple location objects, embedded either inline or in nested sub-documents. Additional command options are also supported, allowing results to be returned with not only distance but the location used to generate the distance. See the Geospatial documentation for further information. Polygon searchesPolygonal $within queries are also now supported for simple polygon shapes. Details are here. Journaling enhancements
New ContinueOnError option for bulk insertWhen this flag is set (see your driver on how to set it), bulk insert will continue to insert any remaining documents even if an insert fails (due, for example, to a duplicate key). The getLastError command will report whether any doc inserts have failed (not just last one). If multiple errors occur, only the most recent will be reported by getLastError. See OP_INSERT. Map ReduceOutput to a sharded collectionUsing the new flag "sharded" it is possible to send the result of a map/reduce to a sharded collection. Combined with the "reduce" or "merge" flags, it is possible to keep adding data to very large collections from map/reduce jobs. See documentation of output options. Performance improvementsMap/reduce performance will benefit from the following:
New Querying FeaturesAdditional regex options: sAllows the dot (.) to match all characters including new lines. This is in addition to the currently supported i, m and x. See Using regular expressions in queries. $andA special boolean $and query operator is now available. Command output changesThe output of the Validate Command and the documents in the system.profile collection have both been enhanced to return information as BSON objects with keys for each value rather than as free-form strings. Shell featuresCustom promptYou can define a custom prompt for the mongo shell. You can change the prompt at any time by setting the prompt variable to a string or a custom JavaScript function returning a string. See the documentation for examples. Default shell init scriptOn startup, the shell will check for a .mongorc.js file in the user's home directory. The shell will execute this file after connecting to the database and before displaying the prompt. If you would like the shell not to run the .mongorc.js file automatically, start the shell with --norc. See .mongorc.js documentation. See Also |

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus