MongoDB 4.4 Revision Upgrade
-
This document provides standard operational guidelines for upgrading a MongoDB 4.4.x environment to the latest revision in the 4.4 series.
- The current latest revision of the MongoDB 4.4 series is 4.4.30.
Preparation Work
-
Obtain the binary installation package for MongoDB 4.4.30 corresponding to your operating system and upload it to the target server.
- RedHat / CentOS 7.0 x64
- RedHat / CentOS 8.0 x64
- Debian 10.0+ x64
- Others
https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.30.tgzhttps://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.4.30.tgzhttps://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-4.4.30.tgz-
Official Download: For packages targeting other operating systems, visit the MongoDB Community Edition Download Center.
-
Domestic System Compatibility: For systems like EulerOS, Kylin, and UOS, the corresponding CentOS 7/8 packages are generally compatible.
-
Example (Kylin V10): If using the Kylin V10 ARM version, you can download the CentOS 8 ARM 64 architecture package:
-
Extract the installation package and check whether the
mongodprogram in each package has missing dependencies. Install required dependencies based on specific cases.- RedHat / CentOS 7.0 x64
- RedHat / CentOS 8.0 x64
- Debian 10.0+ x64
Extract the installation package for this version:
tar xvf mongodb-linux-x86_64-rhel70-4.4.30.tgzCheck for missing dependencies in the
mongodprogram:ldd mongodb-linux-x86_64-rhel70-4.4.30/bin/mongodExtract the installation package for this version:
tar xvf mongodb-linux-x86_64-rhel80-4.4.30.tgzCheck for missing dependencies in the
mongodprogram:ldd mongodb-linux-x86_64-rhel80-4.4.30/bin/mongodExtract the installation package for this version:
tar xvf mongodb-linux-x86_64-debian10-4.4.30.tgzCheck for missing dependencies in the
mongodprogram:ldd mongodb-linux-x86_64-debian10-4.4.30/bin/mongod
Start Upgrade
- Before upgrading, stop microservices and back up MongoDB data.
- Replica set upgrade sequence: strictly follow the upgrade order from SECONDARY (replica nodes) to PRIMARY (primary node).
- In the example commands of this document, the MongoDB directory is
/usr/local/mongodb/. Modify commands accordingly if your path differs.
- Standalone Node
- Replica Set
-
Upgrade standalone MongoDB node
Steps: Stop the service of the old version and upgrade to version 4.4.30 by replacing the binary files.
# Stop old version service
systemctl stop mongodb
# Backup old binary files
mv /usr/local/mongodb/bin/{mongo,mongo-4.4.bak}
mv /usr/local/mongodb/bin/{mongod,mongod-4.4.bak}
mv /usr/local/mongodb/bin/{mongos,mongos-4.4.bak}
mv /usr/local/mongodb/bin/{mongodump,mongodump-4.4.bak}
mv /usr/local/mongodb/bin/{install_compass,install_compass-4.4.bak}
# Copy the new version binary files to the existing bin directory (execute based on the actual extraction path and installation package name)
cp -p mongodb-linux-x86_64-rhel70-4.4.30/bin/* /usr/local/mongodb/bin/
# Correct ownership and permissions
chown -R mongodb:mongodb /usr/local/mongodb
# Start the service
systemctl start mongodb- Status check: Execute
rs.status()and confirm that this node is in SECONDARY state with normal uptime. - If the service does not start or log in, check the MongoDB program logs first. If slow startup is caused by disk performance issues, wait patiently.
- Status check: Execute
-
Log in to MongoDB and check the version
/usr/local/mongodb/bin/mongo -u root -p password --authenticationDatabase admin
> db.version()- Expected output:
4.4.30
- Expected output:
-
Rotational Upgrade of SECONDARY Nodes
Note: Only upgrade one SECONDARY node at a time. Proceed to the next only after its full recovery.
Steps: Stop the service of the old version and upgrade to version 4.4.30 by replacing the binary files.
# Stop old version service
systemctl stop mongodb
# Backup old binary files
mv /usr/local/mongodb/bin/{mongo,mongo-4.4.bak}
mv /usr/local/mongodb/bin/{mongod,mongod-4.4.bak}
mv /usr/local/mongodb/bin/{mongos,mongos-4.4.bak}
mv /usr/local/mongodb/bin/{mongodump,mongodump-4.4.bak}
mv /usr/local/mongodb/bin/{install_compass,install_compass-4.4.bak}
# Copy the new version binary files to the existing bin directory (execute based on the actual extraction path and installation package name)
cp -p mongodb-linux-x86_64-rhel70-4.4.30/bin/* /usr/local/mongodb/bin/
# Correct ownership and permissions
chown -R mongodb:mongodb /usr/local/mongodb
# Start the service
systemctl start mongodb- If the service does not start or log in, check the MongoDB program logs first. If slow startup is caused by disk performance issues, wait patiently.
Log in to MongoDB and check the version:
/usr/local/mongodb/bin/mongo -u root -p password --authenticationDatabase admin
> db.version()- Expected output:
4.4.30
Check replica set node status:
> rs.status()- Expected result: One PRIMARY node and two SECONDARY nodes.
-
Repeat Procedure
Follow the above steps to complete the upgrade for all SECONDARY nodes in the cluster.
-
Step Down and Switch PRIMARY Node
Log in to the MongoDB primary node and use the
rs.stepDown()command to step down the primary node and force the election of a new primary node./usr/local/mongodb/bin/mongo -u root -p password --authenticationDatabase admin
> rs.stepDown() -
Upgrade Old PRIMARY Node, following the steps used to upgrade SECONDARY nodes.