Upgrade from MongoDB Community Edition to Percona Server for MongoDB¶
Use this procedure to replace MongoDB Community Edition 9.0 with Percona Server for MongoDB 9.0.
Upgrade earlier major versions before you migrate. See Upgrade from 8.0 to 9.0 for the major-version upgrade path.
An in-place upgrade is done by keeping the existing data in the server and replacing the MongoDB binaries. Afterwards, you restart the mongod service with the same dbpath data directory.
An in-place upgrade is suitable for most environments except the ones that use ephemeral storage and/or host addresses.
Procedure¶
Note
MongoDB creates a user that belongs to two groups, which is a potential security risk. This is fixed in Percona Server for MongoDB: the user is included only in the mongod group. To avoid problems with current MongoDB setups, existing user group membership is not changed when you migrate to Percona Server for MongoDB. Instead, a new mongod user is created during installation, and it belongs to the mongod group.
This procedure describes an in-place upgrade of a mongod instance. If you are using data at rest encryption, refer to the Upgrading to Percona Server for MongoDB with data at rest encryption enabled section.
Important
Before starting the upgrade, we recommend to perform a full backup of your data.
-
Save the current configuration file as the backup:
sudo mv /etc/mongod.conf /etc/mongod.conf.bkp -
Stop the
mongodservice:sudo systemctl stop mongod -
Check for installed packages:
sudo dpkg -l | grep mongodSample output
ii mongodb-org 9.0.8 amd64 MongoDB open source document-oriented database system (metapackage) ii mongodb-org-database 9.0.8 amd64 MongoDB open source document-oriented database system (metapackage) ii mongodb-org-database-tools-extra 9.0.8 amd64 Extra MongoDB database tools ii mongodb-org-mongos 9.0.8 amd64 MongoDB sharded cluster query router ii mongodb-org-server 9.0.8 amd64 MongoDB database server ii mongodb-org-shell 9.0.8 amd64 MongoDB shell client ii mongodb-org-tools 9.0.8 amd64 MongoDB tools -
Remove the installed packages:
sudo apt remove \ mongodb-org \ mongodb-org-mongos \ mongodb-org-server \ mongodb-org-shell \ mongodb-org-tools -
Verify that the configuration file includes correct options:
- Copy the required configuration options like custom dbPath/system log path, additional security/replication or sharding options from the backup configuration file (
/etc/mongod.conf) to the current one/etc/mongodb.conf. -
Make sure that the
mongoduser has access to your custom paths. If not, provide it as follows:sudo chown -R mongod:mongod <custom-dbPath> sudo chown -R mongod:mongod <custom-systemLog.path> -
Remove the following configuration from the configuration file if you have it:
processManagement: fork: true pidFilePath: /var/run/mongod.pid
- Copy the required configuration options like custom dbPath/system log path, additional security/replication or sharding options from the backup configuration file (
-
Restart the
mongodservice:sudo systemctl start mongod
-
Stop the
mongodservice:sudo systemctl stop mongod -
Check for installed packages:
sudo rpm -qa | grep mongoSample output
mongodb-org-shell-9.0.8-1.el9.x86_64 mongodb-org-database-9.0.8-1.el9.x86_64 mongodb-org-9.0.8-1.el9.x86_64 mongodb-database-tools-100.20.1-1.x86_64 mongodb-org-server-9.0.8-1.el9.x86_64 mongodb-org-mongos-9.0.8-1.el9.x86_64 mongodb-org-tools-9.0.8-1.el9.x86_64 -
Remove the installed packages:
sudo yum remove \ mongodb-org-shell \ mongodb-org-database \ mongodb-org \ mongodb-database-tools \ mongodb-org-server \ mongodb-org-mongos \ mongodb-org-tools -
Verify that the configuration file includes correct options:
- When you remove old packages, your existing configuration file is saved as
/etc/mongod.conf.rpmsave. Copy the required configuration options like custom dbPath/system log path, additional security/replication or sharding options from the backup configuration file (/etc/mongod.conf.rpmsave) to the current one/etc/mongodb.conf. -
Make sure that the
mongoduser has access to your custom paths. If not, provide it as follows:sudo chown -R mongod:mongod <custom-dbPath> sudo chown -R mongod:mongod <custom-systemLog.path> -
Remove
processManagement.forkandprocessManagement.pidFilePathfrom the configuration file if present. The packagedmongodsystemd service runs in the foreground.
- When you remove old packages, your existing configuration file is saved as
-
Restart the
mongodservice:sudo systemctl start mongod
To upgrade a replica set or a sharded cluster, use the rolling restart method. It allows you to perform the upgrade with minimum downtime. You upgrade the nodes one by one, while the whole cluster / replica set remains operational.
Upgrading to Percona Server for MongoDB with data at rest encryption enabled¶
To enable data-at-rest encryption during migration, use an empty dbPath directory.
The mongod process cannot encrypt existing data files in place.
Replica set members receive encrypted data files through initial sync.
See Switch storage engines for the migration procedure.
Contact Percona for help with your migration plan.