Reputation: 1180
I'm moving my database from 1 cluster (replica set of 3 nodes) to a new one and wanted to profit to upgrade my database version. I'm using 3.6 now and want to upgrade to the latest (4.4). I'm allowed to shutdown the service for a couple of hours.
According to what I found as information, here is how I'm planning to do:
db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } )
db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )
Does that look correct?
Upvotes: 0
Views: 709
Reputation: 59436
I would not recommend to combine these two actions. Do it separately.
Would be like this:
Upgrade to Mongo 4.4
db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
Have a look at Post Upgrade tasks for each release. Setting FeatureCompatibilityVersion may also take some time.
Move to new server
Install MongoDB on new host
Add new hosts to Replica Set: rs.add( { host: "new_host_1.example.net:27017" } )
Inital sync takes place and may take some time. I would recommend to add new hosts one-by-one
Step down the replica set PRIMARY member (on old host), ensure new primary run on a new host.
Stop Mongo service on old hosts
Remove old hosts from Replica Set: rs.remove("old_host_1.example.net")
Instead of adding 3 new nodes and then removing 3 old nodes, you can do it of course one-by-one, i.e.
Just ensure when you run rs.add/rs.remove
that all members are either in PRIMARY
or SECONDARY
state!
By this your application has no downtime at all.
Upvotes: 3