Alma/Rocky/CentOS
- If a replica set is used — contact Passwork technical support for proper updating and data preservation.
- If Passwork is installed on a virtual server, it is recommended to create a virtual snapshot of the OS before updating.
The instructions use switchable code blocks to separate commands according to operating system versions.
Preparation and removal of the outdated version
Creating backup
Create a directory:
- shell
mkdir /backup
Create a backup:
- shell
mongodump --out /backup/mongo-$(date +\%Y-\%m-\%d_\%H-\%M-\%S)
Removal
Stop the service:
- shell
systemctl stop mongod.service
Move the configuration file:
- shell
mv /etc/mongod.conf ./
Remove the database with configuration files:
- shell
yum erase mongodb-org* -y
Remove the directory with log files:
- shell
rm -r /var/log/mongodb
Remove MongoDB data files:
- shell
rm -r /var/lib/mongo
Remove the outdated repository for MongoDB 4.x:
- shell
rm -f /etc/yum.repos.d/mongodb-org-4.x.repo
Installation and backup restoration
Installation
Create a file to add the MongoDB repository to the yum package manager:
- shell
nano /etc/yum.repos.d/mongodb-org-6.0.repo
Place the following content in the file:
- OS 9
- OS 8
[mongodb-org-7.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/7.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-7.0.asc
[mongodb-org-7.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/7.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-7.0.asc
Install the database and administration utilities:
- shell
yum install mongodb-org -y
Start the mongod.service:
- shell
systemctl start mongod.service
Enable service autostart:
- shell
systemctl enable mongod.service
Check connection to the shell:
- shell
mongosh mongodb://localhost:27017
Backup restoration
If the connection to the shell is successful, restore the databases from the backup:
- shell
mongorestore --drop /backup/mongo-xxxx-xx-xx_xx-xx-xx
If you made changes to the MongoDB configuration file (mongod.conf), you need to replace the new file with the old one:
- shell
cp ./mongod.conf /etc/
Restart the mongod.service:
- shell
systemctl restart mongod.service
Open Passwork to verify correct operation.