The Great Open Source Debate with Elastic, Gluu and GitHub 🎤 Oct 26

MongoDB version 4.0.21 is deprecated, please upgrade your installation

Description

I upgraded Rocket Chat to version 4.0 and now the Rocket Cat user is telling me MongoDB version 4.0.21 is deprecated, please upgrade your installation and then links me to the non-existent webpage https://rocket.chat/docs/installation

Server Setup Information

  • Version of Rocket.Chat Server: 4.0.0
  • Operating System: Ubuntu 17.04
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: v12.22.1
  • MongoDB Version: 4.0.21 / mmapv1 (oplog Enabled)
  • Proxy: nginx
  • Firewalls involved: N/A

Any additional Information

I’m a newbie with linux commands. Hopefully someone can point me in the right direction of some commands I can paste into PuTTY and get Rocket Cat off my back. Thanks.

HI!

The recommended MongoDB version is 4.2, according to here:

As you deployed with docker, you probably has a docker-compose.yml to edit.

You’ll need to edit mongo service, and use the 4.2 version.

after, whenever you do a docker-compose up -d it will recreate the container with the new version.

Please, always backup before any upgrade

Hi you will also need to convert the mmapv1 to wiredtiger. There are many guides how to do this but if you need help let me know I will try to find you a guid when I have time.

I updated the command in mongo to:

command: mongod --replSet rs0 --storageEngine wiredTiger --dbpath “/data/db”

Hope you get it sorted, if you need any help let me know.

1 Like

This is how I understand this. I have yet to test it, but I will update as soon I can.

MongoDB 4.0.x uses an MMAP storage engine. In order to update to a higher 4.x or 5.x, you will need to migrate from MMAP to wiredTiger storage engine first.
Ref: https://docs.rocket.chat/quick-start/installing-and-updating/docker-containers/mongodb-mmap-to-wiredtiger-migration

MongoDB needs to be updated sequentially from my understanding. To upgrade to 5.x, you will have to upgrade from 4.0 to 4.2; then from 4.2 to 4.4, and so on. I don’t think you can just jump from 4.0 to 5.0.
Ref: https://docs.mongodb.com/manual/tutorial/upgrade-revision/

After you migrated from MMAP to wiredTiger engine, (Step 1)stop all docker instances. (Step 2)update your Docker Compose file and change mongo and mongo-init-replica image version to the next sequential version. (Step 3)Then, run the Docker Compose file. Repeat from step 1 to step 3 if needed.
Ref: https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/docker-compose.yml

Backup the database and even the entire server if possible before trying anything, and create a fail-safe solution.

Hope this helps in some way!

1 Like

Hi there. This is what I use on our servers, it may or may not work for you:

#!/usr/bin/env bash
echo "This script will:"
echo " - Stop affectli."
echo " - Make a backup of the mongo database."
echo " - Remove the existing data folder."
echo " - Create a new wiredTiger data folder."
echo " - Restore the backup."
echo " - Upgrade mongo version."
echo " - Removed unused docker images."
read -p "Are you sure? (y/n)" -n 1 -r
echo    # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
sudo docker rm -f rocketchat-mongo-upgrade
set -e
sudo docker pull mongo:4.2.17
sudo docker pull mongo:4.4.9
sudo docker pull mongo:5.0.3
sudo docker start rocketchat-mongo
until sudo docker exec rocketchat-mongo mongo
do
    echo "Waiting for Mongo to start..."
    sleep 1
done
sudo docker exec -u0 rocketchat-mongo rm -r -f /dump
sudo docker exec -u0 rocketchat-mongo mkdir /dump
echo "Starting dump.."
sudo docker exec -u0 rocketchat-mongo mongodump --out=/dump
sudo docker exec -u0 rocketchat-mongo tar -czf /dump.tgz /dump
sudo docker cp rocketchat-mongo:/dump.tgz dump.tgz
echo "Backup complete. Stopping old Mongo"
sudo docker stop rocketchat-mongo
sudo rm -r -f data
echo "Starting new Mongo.."
sudo docker run -d \
  --name rocketchat-mongo-upgrade \
  -v $(pwd)/data:/data/db \
 mongo:4.0.25 \
 mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
sudo docker cp dump.tgz rocketchat-mongo-upgrade:/dump.tgz
sudo docker exec rocketchat-mongo-upgrade tar -xzf /dump.tgz
until sudo docker exec rocketchat-mongo-upgrade mongo
do
    echo "Waiting for Mongo to start..."
    sleep 1
done
echo "Initializing Mongo..."
sudo docker exec rocketchat-mongo-upgrade mongo 127.0.0.1/rocketchat --eval "rs.initiate({_id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' } ]})"
echo "Restoring database.."
sudo docker exec -u0 rocketchat-mongo-upgrade mongorestore /dump
echo "Cleaning up.."
sudo docker stop rocketchat-mongo-upgrade
sudo docker rm -v rocketchat-mongo-upgrade
sudo rm dump.tgz
echo
echo "Upgrading mongo verstion to 4.2.17.."
sudo docker run -d \
  --name rocketchat-mongo-upgrade \
  -v $(pwd)/data:/data/db \
 mongo:4.2.17 \
 mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
until sudo docker exec rocketchat-mongo-upgrade mongo
do
    echo "Waiting for Mongo to start..."
    sleep 1
done
sudo docker exec rocketchat-mongo-upgrade mongo 127.0.0.1/rocketchat --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"4.2\" } )"
sudo docker logs rocketchat-mongo-upgrade
sudo docker stop rocketchat-mongo-upgrade
sudo docker rm -v rocketchat-mongo-upgrade
echo
echo "Upgrading mongo verstion to 4.4.9.."
sudo docker run -d \
  --name rocketchat-mongo-upgrade \
  -v $(pwd)/data:/data/db \
 mongo:4.4.9 \
 mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
until sudo docker exec rocketchat-mongo-upgrade mongo
do
   echo "Waiting for Mongo to start..."
   sleep 1
done
sudo docker exec rocketchat-mongo-upgrade mongo 127.0.0.1/rocketchat --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"4.4\" } )"
sudo docker logs rocketchat-mongo-upgrade
sudo docker stop rocketchat-mongo-upgrade
sudo docker rm -v rocketchat-mongo-upgrade
echo
echo "Cleaning up container images."
sudo docker image prune -a
echo
echo "Done. You can now deploy the new version of mongo (v5) and rocketChat."

Seemed like a pretty straight forward solutions, but I was unable to accomplish my goal for this. I created a separate post regarding the issue I got stuck on.