Skip to main content

MongoDB 4.4 Revision Upgrade

Tip
  • 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

  1. Obtain the binary installation package for MongoDB 4.4.30 corresponding to your operating system and upload it to the target server.

    https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.30.tgz
  2. Extract the installation package and check whether the mongod program in each package has missing dependencies. Install required dependencies based on specific cases.

    Extract the installation package for this version:

    tar xvf mongodb-linux-x86_64-rhel70-4.4.30.tgz

    Check for missing dependencies in the mongod program:

    ldd mongodb-linux-x86_64-rhel70-4.4.30/bin/mongod

Start Upgrade

Tip
  • 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.
  1. 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.
  2. 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