Upgrade from 3.6 to 4.0
In case the system is connected to the internet, create a text file /etc/yum.repos.d/mongodb-org-4.0.repo with the following content (on all the members of the ReplicaSet, in case of such configuration).
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
In case of an offline installation create the directory mongo-4.0 and put inside the mongo db version 4.0 files.
Standalone upgrade
Run the following command as root for the offline installation:
service nemo stop
service mongod stop
cd mongo-4.0
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service nemo stop
service mongod stop
yum upgrade mongodb-org-server
Enable backwards-incompatible 4.0 features
Execute the following commands:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
ReplicaSet upgrade
The upgrade must be done in the right order: first the secondary node(s), then the arbiter, and finally the primary node. Before starting the upgrade, stop the nemo service on all the nodes:
service nemo stop
Secondary node(s) and arbiter upgrade
Run the following commands as root for the online installation:
service mongod stop
cd mongo-4.0
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Primary node upgrade
Run the following command as root for the offline installation:
service mongod stop
cd mongo-4.0
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server
Enable backwards-incompatible 4.0 features
Enable backwards-incompatible 4.0 features Execute the following commands on the primary node:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Test switchover
Verify that the switchover works correctly. Connect to the primary node and execute the following command:
# mongo
[...]
nemo:PRIMARY> rs.stepDown()
The primary will become secondary, and the secondary will be elected primary.
Upgrade from 4.0 to 4.2
In case the system is connected to the internet, create a text file /etc/yum.repos.d/mongodb-org-4.2.repo with the following content (on all the members of the ReplicaSet, in case of such configuration).
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
Also disable the repository of the version 4.0, removing the file /etc/yum.repos.d/mongodb-org-4.0.repo. In case of an offline installation create the directory mongo-4.2 and put inside the mongo db version 4.2 files.
Standalone upgrade
Run the following command as root for the offline installation:
service nemo stop
service mongod stop
cd mongo-4.2
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service nemo stop
service mongod stop
yum upgrade mongodb-org-server
Enable backwards-incompatible 4.2 features
Execute the following commands:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } )
ReplicaSet upgrade
The upgrade must be done in the right order: first the secondary node(s), then the arbiter, and finally the primary node. Before starting the upgrade, stop the nemo service on all the nodes:
service nemo stop
Secondary node(s) and arbiter upgrade
Run the following commands as root for the online installation:
service mongod stop
cd mongo-4.2
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Primary node upgrade
Run the following command as root for the offline installation:
service mongod stop
cd mongo-4.2
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server
Enable backwards-incompatible 4.2 features
Enable backwards-incompatible 4.2 features Execute the following commands on the primary node:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } )
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Test switchover
Verify that the switchover works correctly. Connect to the primary node and execute the following command:
# mongo
[...]
nemo:PRIMARY> rs.stepDown()
The primary will become secondary, and the secondary will be elected primary.
Upgrade from 4.2 to 4.4
In case the system is connected to the internet, create a text file /etc/yum.repos.d/mongodb-org-4.4.repo with the following content (on all the members of the ReplicaSet, in case of such configuration).
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
Also disable the repository of the version 4.2, removing the file /etc/yum.repos.d/mongodb-org-4.2.repo. In case of an offline installation create the directory mongo-4.4 and put inside the mongo db version 4.4 files.
Standalone upgrade
Run the following command as root for the offline installation:
service nemo stop
service mongod stop
cd mongo-4.4
yum upgrade mongodb-*
In case the command fails due to missing dependencies of cyrus packages, run the following:
yum install cyrus*
Then repeat again the command
yum install mongodb-*
Run the following commands as root for the online installation:
service nemo stop
service mongod stop
yum upgrade mongodb-org-server
Disable fork configuration
Mongodb 4.4 will not start up if the fork: enable command is configured in the /etc/mongod.conf
file. To remove the fork: true configuration, run the following commands
sed -i.bak '/fork: true/d' /etc/mongod.conf
systemctl start mongod.service
At this point, mongod process should be running and stable.
Enable backwards-incompatible 4.4 features
Execute the following commands:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )
ReplicaSet upgrade
The upgrade must be done in the right order: first the secondary node(s), then the arbiter, and finally the primary node. Before starting the upgrade, stop the nemo service on all the nodes:
service nemo stop
Secondary node(s) and arbiter upgrade
Run the following commands as root for the online installation:
service mongod stop
cd mongo-4.4
yum upgrade mongodb-*
In case the command fails due to missing dependencies of cyrus packages, run the following:
yum install cyrus*
Then repeat again the command
yum install mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server
Disable fork cofiguration
Mongodb 4.4 will not start up if the fork: enable
command is configured in the /etc/mongod.conf
file. To remove it, run the following commands:
sed -i.bak '/fork: true/d' /etc/mongod.conf
systemctl start mongod.service
At this point, mongod process should be running and stable.
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Primary node upgrade
Run the following command as root for the offline installation:
service mongod stop
cd mongo-4.4
yum upgrade mongodb-*
In case the command fails due to missing dependencies of cyrus packages, run the following:
yum install cyrus*
Then repeat again the command
yum install mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server
Disable fork cofiguration
Mongodb 4.4 will not start up if the fork: enable command is configured in the /etc/mongod.conf
file. To remove the fork: true configuration, run the following commands
sed -i.bak '/fork: true/d' /etc/mongod.conf
systemctl start mongod.service
At this point, mongod process should be running and stable.
Enable backwards-incompatible 4.4 features
Execute the following commands on the primary node:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Test switchover
Verify that the switchover works correctly. Connect to the primary node and execute the following command:
# mongo
[...]
nemo:PRIMARY> rs.stepDown()
The primary will become secondary, and the secondary will be elected primary.
Upgrade from 4.4 to 5.0
In case the system is connected to the internet, create a text file /etc/yum.repos.d/mongodb-org-5.0.repo with the following content (on all the members of the ReplicaSet, in case of such configuration).
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
Also disable the repository of the version 4.4, removing the file /etc/yum.repos.d/mongodb-org-4.4.repo. In case of an offline installation create the directory mongo-5.0 and put inside the mongo db version 5.0 files.
Standalone upgrade
Run the following command as root for the offline installation:
service nemo stop
service mongod stop
cd mongo-5.0
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service nemo stop
service mongod stop
yum upgrade mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org mongodb-org-database-tools-extra mongodb-org-tools mongodb-mongosh mongodb-org-database mongodb-database-tools
Disable enableMajorityReadConcern configuration
Mongodb 5.0 will not start up if the enableMajorityReadConcern
is configured: the option is no more necessary, since the write concern is set to majority by default. To remove it, run the following commands
sed -i.bak '/enableMajorityReadConcern: false/d' /etc/mongod.conf
systemctl start mongod.service
At this point, mongod process should be running and stable.
Enable backwards-incompatible 5.0 features
Execute the following commands:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )
Configure the default read and write concern
Execute the following commands:
# mongo
[...]
db.adminCommand({
"setDefaultRWConcern" : 1,
"defaultWriteConcern" : {
"w" : 1
}
})
ReplicaSet upgrade
The upgrade must be done in the right order: first the secondary node(s), then the arbiter, and finally the primary node. Before starting the upgrade, stop the nemo service on all the nodes:
service nemo stop
Secondary node(s) and arbiter upgrade
Run the following commands as root for the online installation:
service mongod stop
cd mongo-5.0
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org mongodb-org-database-tools-extra mongodb-org-tools mongodb-mongosh mongodb-org-database mongodb-database-tools
Disable enableMajorityReadConcern configuration
Mongodb 5.0 will not start up if the enableMajorityReadConcern
is configured: the option is no more necessary, since the write concern is set to majority by default. To remove it, run the following commands
sed -i.bak '/enableMajorityReadConcern: false/d' /etc/mongod.conf
systemctl start mongod.service
At this point, mongod process should be running and stable.
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Primary node upgrade
Run the following command as root for the offline installation:
service mongod stop
cd mongo-5.0
yum upgrade mongodb-*
Run the following commands as root for the online installation:
service mongod stop
yum upgrade mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org mongodb-org-database-tools-extra mongodb-org-tools mongodb-mongosh mongodb-org-database mongodb-database-tools
Disable enableMajorityReadConcern configuration
Mongodb 5.0 will not start up if the enableMajorityReadConcern
is configured: the option is no more necessary, since the write concern is set to majority by default. To remove it, run the following commands
sed -i.bak '/enableMajorityReadConcern: false/d' /etc/mongod.conf
systemctl start mongod.service
At this point, mongod process should be running and stable.
Enable backwards-incompatible 5.0 features
Execute the following commands on the primary node:
# mongo
[...]
> db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )
Verify that mongo is running after the upgrade, and that it is in the right state (see example below):
# mongo
[...]
nemo:SECONDARY>
Configure the default read and write concern
Execute the following commands:
# mongo
[...]
db.adminCommand({
"setDefaultRWConcern" : 1,
"defaultWriteConcern" : {
"w" : 1
}
})
Test switchover
Verify that the switchover works correctly. Connect to the primary node and execute the following command:
# mongo
[...]
nemo:PRIMARY> rs.stepDown()
The primary will become secondary, and the secondary will be elected primary.