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:
Saving the Database Content¶
-
Open a shell.
-
Start MongoDB, if necessary:
sudo systemctl start mongod
Hint - cluster
In a cluster, you have to start all members of the replica set.
-
Save the stored data:
-
Single server:
mongodump --ssl --tlsInsecure --gzip --out /tmp/mongodump
-
Cluster:
mongodump --uri="mongodb://<server1>:27017,<server2>:27017,<server3>:27017/?replicaSet=p5&readPreference=secondary" --ssl --tlsInsecure --oplog --gzip --out /tmp/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 set before you restore the database.
-
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 "Literature - further information" Please refer to the documentations of the installed products for further information about stopping the corresponding services.
-
Stop MongoDB:
sudo systemctl stop mongod
-
Remove all subdirectories and files in the
/opt/seal/data/seal-mongodb
directory, except of the base directory itself:sudo rm -rf /opt/seal/data/seal-mongodb/*
-
In the
/opt/seal/etc/mongod.conf
file, remove thejournal: enabled
option from thestorage:
section, if it exists.The
storage:
section is to look like this:storage: dbPath: /opt/seal/data/seal-mongodb
-
In single systems or the replica set primary, reinitialize the database.
Restoring the Database Content¶
Hint - Cluster
In a cluster, you have to perform the following instructions on the replica set primary only.
-
Remove the directory of the admin database dump:
sudo rm -rf /tmp/mongodump/admin
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 must remove this directory before you restore the data.
-
Restore the data:
-
Single server:
mongorestore --ssl --sslAllowInvalidCertificates --drop --gzip /tmp/mongodump
-
Cluster:
mongorestore --uri="mongodb://<server1>:27017,<server2>:27017,<server3>:27017/?replicaSet=p5" --ssl --sslAllowInvalidCertificates --drop --oplogReplay --gzip /tmp/mongodump
Hint - cluster
In a cluster, you have to perform the above instructions on one server only.
-
-
Restart MongoDB:
sudo systemctl start mongod
-
Restart all dependent services.
Literature - further information
Please refer to the documentations of the installed products for further information about starting the corresponding services.
Updating Older Versions¶
For details on updating earlier SEAL MongoDB versions, see the corresponding SEAL MongoDB documentation.