Skip to content

Updating MongoDB 4.4 to 7.0


The following instructions include the update of both, single system and cluster.

In case of a single system perform all instructions, except of those concerning the replica set.

In case of a cluster perfom the instructions as stated in the subchapters.

Caution - incompatibility

Due to incompatibility of the MongoDB service versions 4.4 and 7.0 you must export the stored data before updating and reimport them afterwards.

The standard procedure is as follows:

  1. Save the database content

  2. Update the database

  3. Restore the database content


Saving the Database Content

  1. Open a PowerShell (Administrator).

  2. Start MongoDB, if necessary:

    Start-Service seal-mongodb
    

    Hint - cluster

    In a cluster, you have to start all members of the replica set.

  3. Save the stored data:

    • Single server

      & "C:\Program Files\MongoDB\Tools\100\bin\mongodump.exe" /ssl /tlsInsecure /gzip /out "$env:TEMP\mongodump"
      
    • Cluster

      & "C:\Program Files\MongoDB\Tools\100\bin\mongodump.exe" /uri:"mongodb://<server1>:27017,<server2>:27017,<server3>:27017/?replicaSet=p5" /ssl /tlsInsecure /oplog /gzip /out "$env:TEMP\mongodump"
      

      Hint - cluster

      In a cluster, you need to perform the above instructions on one server only. This will not affect the operation of the replica set primary.


Updating the Database

Hint - Cluster

In a cluster, you have to perform the following instructions except of the initializing of the database on every member of the replica set.

Caution - updating members of the replica set

In a cluster, you have to upgrade and reconfigure all members of the replica before you restore the database.

  1. Stop all dependent services.

    Hint - services with database access

    Services that access the database will restart continuously while you are updating the database. To prevent this unnecessary server load, you need to stop all services.

    Literature - further information

    Please refer to the documentations of the installed products for further information about stopping the corresponding services.

  2. Stop MongoDB:

    Stop-Service seal-mongodb -Force
    
  3. Remove all subdirectories and files in the C:\ProgramData\SEAL Systems\data\seal-mongodb directory, except of the base directory itself:

    Remove-Item "C:\ProgramData\SEAL Systems\data\seal-mongodb\*" -Force -Recurse
    
  4. Install MongoDB.

    1. In the C:\ProgramData\SEAL Systems\config\mongod.conf file, remove the journal: enabled option from the storage: section, if it exists.

    The storage: section is to look like this:

    storage:
      dbPath: C:\ProgramData\SEAL Systems\data\seal-mongodb
    
  5. Reconfigure the shared replica set.

  6. In single systems or the replica set primary, reinitialize the database.

  7. Reconnect the database servers to the cluster.

  8. Check the status of the database.


Restoring the Database Content

Hint - Cluster

In case of a cluster you have to perform the following instructions on the replica set primary only.

  1. Remove the directory of the admin database dump:

    Remove-Item "$env:TEMP\mongodump\admin" -Force -Recurse
    

    Caution - admin database

    MongoDB uses the admin database for storing internal configuration and runtime information. After the update, this information will no longer match the new configuration. Therefore, you have to remove this directory before you restore the data.

  2. Restore the data:

    • Single server

      & "C:\Program Files\MongoDB\Tools\100\bin\mongorestore.exe" /ssl /tlsInsecure /drop /gzip "$env:TEMP\mongodump"
      
    • Cluster

      & "C:\Program Files\MongoDB\Tools\100\bin\mongorestore.exe" /uri:"mongodb://<server1>:27017,<server2>:27017,<server3>:27017/?replicaSet=p5" /ssl /tlsInsecure /drop /oplogReplay /gzip "$env:TEMP\mongodump"
      

      Hint - cluster

      In a cluster, you have to perform the above instructions on one server only.

  3. Restart MongoDB:

    Restart-Service seal-mongodb -Force
    
  4. Restart all dependent services.

    Literature - further information

    Please refer to the documentations of the installed products for further information about starting the corresponding services.


Back to top