发布于 2015-09-14 14:54:26 | 121 次阅读 | 评论: 0 | 来源: 网络整理
See the full index of this page for a complete list of changes included in 1.8.
MongoDB 1.8 is a standard, incremental production release and works as a drop-in replacement for MongoDB 1.6, except:
Read through all release notes before upgrading and ensure that no changes will affect your deployment.
1.8.x secondaries can replicate from 1.6.x primaries.
1.6.x secondaries cannot replicate from 1.8.x primaries.
Thus, to upgrade a replica set you must replace all of your secondaries first, then the primary.
For example, suppose you have a replica set with a primary, an arbiter and several secondaries. To upgrade the set, do the following:
For the arbiter:
Change your config (optional) to prevent election of a new primary.
It is possible that, when you start shutting down members of the set, a new primary will be elected. To prevent this, you can give all of the secondaries a priority of 0 before upgrading, and then change them back afterwards. To do so:
Record your current config. Run rs.config() and paste the results into a text file.
Update your config so that all secondaries have priority 0. For example:
config = rs.conf()
{
"_id" : "foo",
"version" : 3,
"members" : [
{
"_id" : 0,
"host" : "ubuntu:27017"
},
{
"_id" : 1,
"host" : "ubuntu:27018"
},
{
"_id" : 2,
"host" : "ubuntu:27019",
"arbiterOnly" : true
}
{
"_id" : 3,
"host" : "ubuntu:27020"
},
{
"_id" : 4,
"host" : "ubuntu:27021"
},
]
}
config.version++
3
rs.isMaster()
{
"setName" : "foo",
"ismaster" : false,
"secondary" : true,
"hosts" : [
"ubuntu:27017",
"ubuntu:27018"
],
"arbiters" : [
"ubuntu:27019"
],
"primary" : "ubuntu:27018",
"ok" : 1
}
// for each secondary
config.members[0].priority = 0
config.members[3].priority = 0
config.members[4].priority = 0
rs.reconfig(config)
For each secondary:
If you changed the config, change it back to its original state:
config = rs.conf()
config.version++
config.members[0].priority = 1
config.members[3].priority = 1
config.members[4].priority = 1
rs.reconfig(config)
Shut down the primary (the final 1.6 server), and then restart it with the 1.8.x binary from the MongoDB Download Page.
Turn off the balancer:
mongo <a_mongos_hostname>
use config
db.settings.update({_id:"balancer"},{$set : {stopped:true}}, true)
For each shard:
For each mongos:
For each config server:
Turn on the balancer:
use config
db.settings.update({_id:"balancer"},{$set : {stopped:false}})
If for any reason you must move back to 1.6, follow the steps above in reverse. Please be careful that you have not inserted any documents larger than 4MB while running on 1.8 (where the max size has increased to 16MB). If you have you will get errors when the server tries to read those documents.
Returning to 1.6 after using 1.8 Journaling works fine, as journaling does not change anything about the data file format. Suppose you are running 1.8.x with journaling enabled and you decide to switch back to 1.6. There are two scenarios:
MongoDB now supports write-ahead 日志 to facilitate fast crash recovery and durability in the storage engine. With journaling enabled, a mongod can be quickly restarted following a crash without needing to repair the collections. The aggregation framework makes it possible to do aggregation
Sparse Indexes are indexes that only include documents that contain the fields specified in the index. Documents missing the field will not appear in the index at all. This can significantly reduce index size for indexes of fields that contain only a subset of documents within a collection.
Covered Indexes enable MongoDB to answer queries entirely from the index when the query only selects fields that the index contains.
The mapReduce command supports new options that enable incrementally updating existing collections. Previously, a MapReduce job could output either to a temporary collection or to a named permanent collection, which it would overwrite with new data.
You now have several options for the output of your MapReduce jobs:
For more information, see the out field options in the mapReduce document.