How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to...
Transcript of How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to...
![Page 1: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/1.jpg)
How to upgrade MongoDB without downtime
![Page 2: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/2.jpg)
me - @adamotonete
Adamo Tonete, Senior Technical EngineerBrazil
![Page 3: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/3.jpg)
3
Agenda
● Versioning● Upgrades● Operations that always require downtime● Upgrading a replica-set● Upgrading a sharded cluster● Live demo - changing versions● Review● Q&A
![Page 4: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/4.jpg)
Versioning
![Page 5: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/5.jpg)
5
Versioning
Production-ready releases are even numbers:
2.2, 3.0, 3.2
Never EVER use an odd version in production.
2.3, 3.3 are testing versions.
![Page 6: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/6.jpg)
6
Versioning
How to read version numbers:
3.2.15
3.2 = release series
15 = revision
![Page 7: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/7.jpg)
Upgrading
![Page 8: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/8.jpg)
8
Major and Minor upgrades
Minor upgrades are very straight forward, just drop in replacement.
What is a minor upgrade?
Replacing 3.2.14 with 3.2.15 is a revision upgrade.
Database still in the same versions, some fixes were added and might some new features without breaking backwards compatibility.
![Page 9: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/9.jpg)
9
Major and Minor upgrades
Minor upgrades may add features from new versions.
MongoDB 3.2.10 has some features and enhancements that were introduced in 3.4...
Such as config servers as replica-set and improvements on wiredTiger.
![Page 10: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/10.jpg)
10
Major and Minor upgrades
Major upgrades
Moving from 2.6.x to 3.0.x is considered a major upgrade.
It usually requires driver updates and some testing.
Sometimes there are differences in the database architecture.
If a rollback is necessary, it is way more complicated than updating.
![Page 11: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/11.jpg)
11
Major and Minor upgrades
A few examples:
● 2.4 to 2.6 new authentication algorithm.● 3.0 to 3.2 pluggable storage engine. WiredTiger.● 3.2 to 3.4 config servers are now replicasets, data new types, huge
changes in WiredTiger, improvements on initial sync.● 3.4 to 3.6 pre transactions, sessions.● 3.6 to 4.0 transactions.
![Page 12: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/12.jpg)
12
Major and Minor upgrades - Rollbacks
Sometimes upgrades don't work as we expect, and a version rollback is necessary.
It is usually possible to rollback, but please check the documented steps before upgrading.
![Page 13: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/13.jpg)
13
Feature Compatibility Version
Since version 3.4 it has been possible to turn off new version features to keep compatibility with previous versions.
With that option, it is possible to make 3.4 behave like 3.2, and the same is true for 3.6
![Page 14: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/14.jpg)
Operations that require downtime
![Page 15: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/15.jpg)
15
Operations that require downtime
● Enable security● Change cluster shared key● Change listen ip
![Page 16: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/16.jpg)
Upgrading a replica-set
![Page 17: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/17.jpg)
17
Upgrading a replica-set
In order to upgrade a replica-set, we will take advantage of high availability.
![Page 18: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/18.jpg)
18
Upgrading a replica-set
Removing a secondary or setting the instance as hidden:
![Page 19: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/19.jpg)
19
Upgrading a replica-set
Then drivers will see this configuration:
![Page 20: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/20.jpg)
20
Upgrading a replica-set
Repeat the process in the remaining secondaries:
![Page 21: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/21.jpg)
21
Upgrading a replica-set
Step the primary down and replace the remaining old instance.
![Page 22: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/22.jpg)
22
Upgrading a replica-set
It is not necessary to remove the old versions while updating. We can set the instance as hidden : true in the rs.config() before removing them.
The application driver must be aware of the replica-set configuration, otherwise the application may face downtime.
It is preferable to trigger an election (to step down the primary) as the last operation in the upgrade.
![Page 23: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/23.jpg)
Upgrading a sharded environment
![Page 24: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/24.jpg)
24
Upgrading a sharded environment
A sharded cluster is one or more shards (replica-sets) managed by the mongo config servers and mongos processes.
In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets. However, there is a sequence to be respected when upgrading a sharded cluster.
![Page 25: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/25.jpg)
25
Upgrading a sharded cluster
1. Stop the balancer2. Upgrade the config servers3. Upgrade the shards4. Upgrade the mongos5. Re-enable the balancer
![Page 26: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/26.jpg)
Live Demo
![Page 27: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/27.jpg)
27
This can be a bit boring...
![Page 28: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/28.jpg)
Upgrading Replica-set
![Page 29: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/29.jpg)
Changing the storage engine on the fly
![Page 30: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/30.jpg)
Review
![Page 31: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/31.jpg)
31
Review
● The driver plays a very important part in keeping the application online.● Do not move from an ancient version to a new one.● Test the new version before applying it in production.● Create backups before upgrading.
![Page 32: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/32.jpg)
Q&A
![Page 33: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/33.jpg)
33
Rate Our Session
![Page 34: How to upgrade MongoDB without downtime · mongo config servers and mongos processes. In order to upgrade the shards, we can follow exactly the same steps as we've used in the replicasets.](https://reader036.fdocuments.net/reader036/viewer/2022081515/5f04f3be7e708231d41085fa/html5/thumbnails/34.jpg)
Thank you!