Hello,
recently I have upgrade my rocket.chat to version 4.2 and there was an information about upgrade mongo from 3.6 to 4.2.
I found this page Upgrade MongoDB from 3.4 to 4.0 and enable transactions features | docs-community-dev (opensilex.github.io) how to upgrade.
I did these steps:
- Dump your database
mongodump --host localhost
2.3. mongdb
sudo systemctl status mongodb
sudo systemctl stop mongodb
sudo systemctl status mongodb
- GPG Key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
- Add MongoDB 4.0 repository to apt list files
Install MongoDB Community Edition on Ubuntu — MongoDB Manual
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
ls -lrt /etc/apt/sources.list.d/
- Remove older version and database files
sudo apt-get purge mongodb-org*
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package mongodb-org*
E: Couldn’t find any package by glob ‘mongodb-org*’
E: Couldn’t find any package by regex ‘mongodb-org*’
sudo rm -rf /var/lib/mongodb
sudo mkdir /var/lib/mongodb/
sudo chown -R mongodb:mongodb /var/lib/mongodb/
- Update apt and install new version
sudo apt-get update
sudo apt-get install mongodb-org
…
Unpacking mongodb-org (4.0.27) …
Errors were encountered while processing:
/var/cache/apt/archives/mongodb-org-server_4.0.27_amd64.deb
/var/cache/apt/archives/mongodb-org-mongos_4.0.27_amd64.deb
/var/cache/apt/archives/mongodb-org-tools_4.0.27_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
- Restart MongoDB service
sudo systemctl enable mongodb
Synchronizing state of mongodb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mongodb
Failed to enable unit: Unit file /etc/systemd/system/mongodb.service is masked.
After that error I ran this command:
sudo systemctl unmask mongodb
Removed /etc/systemd/system/mongodb.service
then
sudo systemctl enable mongodb
mongodb.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mongodb
sudo systemctl start mongodb
Job for mongodb.service failed because the control process exited with error code.
See “systemctl status mongodb.service” and “journalctl -xe” for details.
How should I properly upgrade mongodb?